From aad3e5b67783f33c1ba31a5e35fee357f6b8c9d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Tue, 20 Aug 2024 18:50:35 +0200 Subject: [PATCH] refactor(core): Track metrics state and categories in telemetry (no-changelog) (#10483) --- .../__tests__/telemetry-event-relay.test.ts | 24 ++++++++++++++++++- .../cli/src/events/telemetry-event-relay.ts | 7 ++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts b/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts index 387a60e625..56149a1e9e 100644 --- a/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts +++ b/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts @@ -20,7 +20,22 @@ const flushPromises = async () => await new Promise((resolve) => setImmediate(re describe('TelemetryEventRelay', () => { const telemetry = mock(); const license = mock(); - const globalConfig = mock({ userManagement: { emails: { mode: 'smtp' } } }); + const globalConfig = mock({ + userManagement: { + emails: { + mode: 'smtp', + }, + }, + endpoints: { + metrics: { + enable: true, + includeDefaultMetrics: true, + includeApiEndpoints: false, + includeCacheMetrics: false, + includeMessageEventBusMetrics: false, + }, + }, + }); const workflowRepository = mock(); const nodeTypes = mock(); const sharedWorkflowRepository = mock(); @@ -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, + }, }), ); }); diff --git a/packages/cli/src/events/telemetry-event-relay.ts b/packages/cli/src/events/telemetry-event-relay.ts index 6b0ae37a44..d09481f911 100644 --- a/packages/cli/src/events/telemetry-event-relay.ts +++ b/packages/cli/src/events/telemetry-event-relay.ts @@ -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({