feat: track error count for unexpected errors during schema publish/check (#6480)

This commit is contained in:
Laurin Quast 2025-02-06 14:59:14 +01:00 committed by GitHub
parent 1b3086facc
commit 05c292cd55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -69,6 +69,18 @@ const schemaPublishCount = new promClient.Counter({
labelNames: ['model', 'projectType', 'conclusion'],
});
const schemaPublishUnexpectedErrorCount = new promClient.Counter({
name: 'registry_publish_unexpected_error_count',
help: 'Unexpected, not gracefully handled errors. E.g. from GitHub or other third-party services.',
labelNames: ['errorName'],
});
const schemaCheckUnexpectedErrorCount = new promClient.Counter({
name: 'registry_check_unexpected_error_count',
help: 'Unexpected, not gracefully handled errors. E.g. from GitHub or other third-party services.',
labelNames: ['errorName'],
});
const schemaDeleteCount = new promClient.Counter({
name: 'registry_delete_count',
help: 'Number of schema deletes',
@ -250,7 +262,7 @@ export class SchemaPublisher {
};
}
@traceFn('SchemaPublisher.check', {
@traceFn('SchemaPublisher.internalCheck', {
initAttributes: input => ({
'hive.organization.slug': input.target?.bySelector?.organizationSlug,
'hive.project.slug': input.target?.bySelector?.projectSlug,
@ -261,7 +273,7 @@ export class SchemaPublisher {
'hive.check.result': result.__typename,
}),
})
async check(input: CheckInput) {
private async internalCheck(input: CheckInput) {
this.logger.info('Checking schema (input=%o)', lodash.omit(input, ['sdl']));
const selector = await this.idTranslator.resolveTargetReference({
@ -959,6 +971,18 @@ export class SchemaPublisher {
} as const;
}
async check(input: CheckInput) {
return await this.internalCheck(input).catch(error => {
if (error instanceof HiveError === false) {
schemaCheckUnexpectedErrorCount.inc({
errorName: (error instanceof Error && error.name) || 'unknown',
});
}
throw error;
});
}
@traceFn('SchemaPublisher.publish', {
initAttributes: (input, _) => ({
'hive.organization.slug': input.target?.bySelector?.organizationSlug,
@ -1082,6 +1106,12 @@ export class SchemaPublisher {
} satisfies PublishResult;
}
if (error instanceof HiveError === false) {
schemaPublishUnexpectedErrorCount.inc({
errorName: (error instanceof Error && error.name) || 'unknown',
});
}
throw error;
});
}