diff --git a/opencti-platform/opencti-graphql/src/config/tracing.ts b/opencti-platform/opencti-graphql/src/config/tracing.ts index 235b09a7d29f..c07b7794a55c 100644 --- a/opencti-platform/opencti-graphql/src/config/tracing.ts +++ b/opencti-platform/opencti-graphql/src/config/tracing.ts @@ -1,7 +1,7 @@ import { SEMATTRS_ENDUSER_ID } from '@opentelemetry/semantic-conventions'; import { MeterProvider, MetricReader, PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics'; import { ValueType } from '@opentelemetry/api-metrics'; -import type { Counter } from '@opentelemetry/api-metrics/build/src/types/Metric'; +import type { Counter, Histogram } from '@opentelemetry/api-metrics/build/src/types/Metric'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import nodeMetrics from 'opentelemetry-node-metrics'; @@ -20,7 +20,7 @@ class MeterManager { private errors: Counter | null = null; - private latencyGauge: Gauge | null = null; + private latencyHistogram: Histogram | null = null; private directBulkGauge: Gauge | null = null; @@ -39,7 +39,7 @@ class MeterManager { } latency(val: number, attributes: any) { - this.latencyGauge?.record(val, attributes); + this.latencyHistogram?.record(val, attributes); } directBulk(val: number, attributes: any) { @@ -62,9 +62,10 @@ class MeterManager { description: 'Counts total number of errors' }); // - Gauges - this.latencyGauge = meter.createGauge('opencti_api_latency', { + this.latencyHistogram = meter.createHistogram('opencti_api_latency', { valueType: ValueType.INT, - description: 'Latency computing per query' + description: 'Latency computing per query', + advice: { explicitBucketBoundaries: [0, 10, 100, 500, 2000] } }); this.directBulkGauge = meter.createGauge('opencti_api_direct_bulk', { valueType: ValueType.INT,