refactor(core): Track metrics state and categories in telemetry (no-changelog) (#10483)

This commit is contained in:
Iván Ovejero 2024-08-20 18:50:35 +02:00 committed by GitHub
parent c410aed4c2
commit aad3e5b677
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 1 deletions

View file

@ -20,7 +20,22 @@ const flushPromises = async () => await new Promise((resolve) => setImmediate(re
describe('TelemetryEventRelay', () => { describe('TelemetryEventRelay', () => {
const telemetry = mock<Telemetry>(); const telemetry = mock<Telemetry>();
const license = mock<License>(); const license = mock<License>();
const globalConfig = mock<GlobalConfig>({ userManagement: { emails: { mode: 'smtp' } } }); const globalConfig = mock<GlobalConfig>({
userManagement: {
emails: {
mode: 'smtp',
},
},
endpoints: {
metrics: {
enable: true,
includeDefaultMetrics: true,
includeApiEndpoints: false,
includeCacheMetrics: false,
includeMessageEventBusMetrics: false,
},
},
});
const workflowRepository = mock<WorkflowRepository>(); const workflowRepository = mock<WorkflowRepository>();
const nodeTypes = mock<NodeTypes>(); const nodeTypes = mock<NodeTypes>();
const sharedWorkflowRepository = mock<SharedWorkflowRepository>(); const sharedWorkflowRepository = mock<SharedWorkflowRepository>();
@ -927,6 +942,13 @@ describe('TelemetryEventRelay', () => {
'Instance started', 'Instance started',
expect.objectContaining({ expect.objectContaining({
earliest_workflow_created: firstWorkflow.createdAt, earliest_workflow_created: firstWorkflow.createdAt,
metrics: {
metrics_enabled: true,
metrics_category_default: true,
metrics_category_routes: false,
metrics_category_cache: false,
metrics_category_logs: false,
},
}), }),
); );
}); });

View file

@ -762,6 +762,13 @@ export class TelemetryEventRelay extends EventRelay {
license_tenant_id: config.getEnv('license.tenantId'), license_tenant_id: config.getEnv('license.tenantId'),
binary_data_s3: isS3Available && isS3Selected && isS3Licensed, binary_data_s3: isS3Available && isS3Selected && isS3Licensed,
multi_main_setup_enabled: config.getEnv('multiMainSetup.enabled'), multi_main_setup_enabled: config.getEnv('multiMainSetup.enabled'),
metrics: {
metrics_enabled: this.globalConfig.endpoints.metrics.enable,
metrics_category_default: this.globalConfig.endpoints.metrics.includeDefaultMetrics,
metrics_category_routes: this.globalConfig.endpoints.metrics.includeApiEndpoints,
metrics_category_cache: this.globalConfig.endpoints.metrics.includeCacheMetrics,
metrics_category_logs: this.globalConfig.endpoints.metrics.includeMessageEventBusMetrics,
},
}; };
const firstWorkflow = await this.workflowRepository.findOne({ const firstWorkflow = await this.workflowRepository.findOne({