Skip to content

Commit

Permalink
refactor(core): Track metrics state and categories in telemetry (no-c…
Browse files Browse the repository at this point in the history
…hangelog) (n8n-io#10483)
  • Loading branch information
ivov authored Aug 20, 2024
1 parent c410aed commit aad3e5b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
24 changes: 23 additions & 1 deletion packages/cli/src/events/__tests__/telemetry-event-relay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,22 @@ const flushPromises = async () => await new Promise((resolve) => setImmediate(re
describe('TelemetryEventRelay', () => {
const telemetry = mock<Telemetry>();
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 nodeTypes = mock<NodeTypes>();
const sharedWorkflowRepository = mock<SharedWorkflowRepository>();
Expand Down Expand Up @@ -927,6 +942,13 @@ describe('TelemetryEventRelay', () => {
'Instance started',
expect.objectContaining({
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,
},
}),
);
});
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/src/events/telemetry-event-relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,13 @@ export class TelemetryEventRelay extends EventRelay {
license_tenant_id: config.getEnv('license.tenantId'),
binary_data_s3: isS3Available && isS3Selected && isS3Licensed,
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({
Expand Down

0 comments on commit aad3e5b

Please sign in to comment.