Skip to content

Commit

Permalink
[backend] Change latency to histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-julien committed Jan 3, 2025
1 parent ecdb633 commit c34ce5d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions opencti-platform/opencti-graphql/src/config/tracing.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;

Expand All @@ -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) {
Expand All @@ -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,
Expand Down

0 comments on commit c34ce5d

Please sign in to comment.