Skip to content

update metric names to semconv METRIC_* exports #5956

@trentm

Description

@trentm

(Part of #4572)

Using rg (ripgrep) because I know it and it is great. Here is grep for possible hits to update:

rg '\b(createGauge|createHistogram|createCounter|createUpDownCounter|createObservableGauge|createObservableCounter|createObservableUpDownCounter)\b' -A1

Here are potential places to update in the contrib repo:

% rg '\b(createGauge|createHistogram|createCounter|createUpDownCounter|createObservableGauge|createObservableCounter|createObservableUpDownCounter)\b' -A1
packages/instrumentation-runtime-node/src/metrics/eventLoopDelayCollector.ts
83:    const delayMin = meter.createObservableGauge(
84-      `${this.namePrefix}.${NodeJsEventLoopDelayAttributes.min}`,
--
91:    const delayMax = meter.createObservableGauge(
92-      `${this.namePrefix}.${NodeJsEventLoopDelayAttributes.max}`,
--
99:    const delayMean = meter.createObservableGauge(
100-      `${this.namePrefix}.${NodeJsEventLoopDelayAttributes.mean}`,
--
107:    const delayStddev = meter.createObservableGauge(
108-      `${this.namePrefix}.${NodeJsEventLoopDelayAttributes.stddev}`,
--
115:    const delayp50 = meter.createObservableGauge(
116-      `${this.namePrefix}.${NodeJsEventLoopDelayAttributes.p50}`,
--
123:    const delayp90 = meter.createObservableGauge(
124-      `${this.namePrefix}.${NodeJsEventLoopDelayAttributes.p90}`,
--
131:    const delayp99 = meter.createObservableGauge(
132-      `${this.namePrefix}.${NodeJsEventLoopDelayAttributes.p99}`,

packages/instrumentation-runtime-node/src/metrics/gcCollector.ts
59:    this._gcDurationByKindHistogram = meter.createHistogram(
60-      `${this.namePrefix}.${ATTR_NODEJS_GC_DURATION_SECONDS}`,

packages/instrumentation-runtime-node/src/metrics/eventLoopTimeCollector.ts
34:    const timeCounter = meter.createObservableCounter(
35-      `${this.namePrefix}.${ATTR_NODEJS_EVENT_LOOP_TIME}`,

packages/instrumentation-runtime-node/src/metrics/heapSpacesSizeAndUsedCollector.ts
55:    const heapLimit = meter.createObservableGauge(
56-      `${this.namePrefix}.${V8HeapSpaceMetrics.heapLimit}`,
--
62:    const heapSpaceUsed = meter.createObservableGauge(
63-      `${this.namePrefix}.${V8HeapSpaceMetrics.used}`,
--
69:    const heapSpaceAvailable = meter.createObservableGauge(
70-      `${this.namePrefix}.${V8HeapSpaceMetrics.available}`,
--
76:    const heapSpacePhysical = meter.createObservableGauge(
77-      `${this.namePrefix}.${V8HeapSpaceMetrics.physical}`,

packages/instrumentation-runtime-node/src/metrics/eventLoopUtilizationCollector.ts
37:      .createObservableGauge(
38-        `${this.namePrefix}.${ATTR_NODEJS_EVENT_LOOP_UTILIZATION}`,

packages/host-metrics/src/metric.ts
197:    this._cpuTime = this._meter.createObservableCounter(METRIC_NAMES.CPU_TIME, {
198-      description: 'Cpu time in seconds',
--
201:    this._cpuUtilization = this._meter.createObservableGauge(
202-      METRIC_NAMES.CPU_UTILIZATION,
--
208:    this._memoryUsage = this._meter.createObservableGauge(
209-      METRIC_NAMES.MEMORY_USAGE,
--
214:    this._memoryUtilization = this._meter.createObservableGauge(
215-      METRIC_NAMES.MEMORY_UTILIZATION,
--
221:    this._networkDropped = this._meter.createObservableCounter(
222-      METRIC_NAMES.NETWORK_DROPPED,
--
227:    this._networkErrors = this._meter.createObservableCounter(
228-      METRIC_NAMES.NETWORK_ERRORS,
--
233:    this._networkIo = this._meter.createObservableCounter(
234-      METRIC_NAMES.NETWORK_IO,
--
240:    this._processCpuTime = this._meter.createObservableCounter(
241-      METRIC_NAMES.PROCESS_CPU_TIME,
--
247:    this._processCpuUtilization = this._meter.createObservableGauge(
248-      METRIC_NAMES.PROCESS_CPU_UTILIZATION,
--
253:    this._processMemoryUsage = this._meter.createObservableGauge(
254-      METRIC_NAMES.PROCESS_MEMORY_USAGE,

packages/instrumentation-mysql/src/instrumentation.ts
65:    this._connectionsUsage = this.meter.createUpDownCounter(
66-      'db.client.connections.usage', //TODO:: use semantic convention

packages/instrumentation-pg/src/instrumentation.ts
105:    this._operationDuration = this.meter.createHistogram(
106-      METRIC_DB_CLIENT_OPERATION_DURATION,
--
124:    this._connectionsCount = this.meter.createUpDownCounter(
125-      METRIC_DB_CLIENT_CONNECTION_COUNT,
--
132:    this._connectionPendingRequests = this.meter.createUpDownCounter(
133-      METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS,

packages/instrumentation-kafkajs/src/instrumentation.ts
176:    this._clientDuration = this.meter.createHistogram(
177-      METRIC_MESSAGING_CLIENT_OPERATION_DURATION,
--
180:    this._sentMessages = this.meter.createCounter(
181-      METRIC_MESSAGING_CLIENT_SENT_MESSAGES
--
183:    this._consumedMessages = this.meter.createCounter(
184-      METRIC_MESSAGING_CLIENT_CONSUMED_MESSAGES
--
186:    this._processDuration = this.meter.createHistogram(
187-      METRIC_MESSAGING_PROCESS_DURATION,

packages/instrumentation-aws-sdk/src/services/bedrock-runtime.ts
65:    this.tokenUsage = meter.createHistogram('gen_ai.client.token.usage', {
66-      unit: '{token}',
--
78:    this.operationDuration = meter.createHistogram(
79-      'gen_ai.client.operation.duration',

packages/instrumentation-mongodb/src/instrumentation.ts
76:    this._connectionsUsage = this.meter.createUpDownCounter(
77-      'db.client.connections.usage',

packages/instrumentation-openai/src/instrumentation.ts
143:    this._genaiClientOperationDuration = this.meter.createHistogram(
144-      METRIC_GEN_AI_CLIENT_OPERATION_DURATION,
--
156:    this._genaiClientTokenUsage = this.meter.createHistogram(
157-      METRIC_GEN_AI_CLIENT_TOKEN_USAGE,

packages/instrumentation-undici/src/undici.ts
138:    this._httpClientDurationHistogram = this.meter.createHistogram(
139-      'http.client.request.duration',

AFAIK there is nothing to update in the core repo. The only instrumentation there that I see creating metrics is instrumentation-http and it is already using METRIC_* appropriately.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions