diff --git a/experimental/packages/opentelemetry-api-metrics/src/NoopMeter.ts b/experimental/packages/opentelemetry-api-metrics/src/NoopMeter.ts index 54b99b658f..a5568b545d 100644 --- a/experimental/packages/opentelemetry-api-metrics/src/NoopMeter.ts +++ b/experimental/packages/opentelemetry-api-metrics/src/NoopMeter.ts @@ -17,7 +17,7 @@ import { Meter } from './types/Meter'; import { MetricOptions, - Labels, + Attributes, Counter, Histogram, ObservableGauge, @@ -109,15 +109,15 @@ export class NoopMeter implements Meter { export class NoopMetric {} export class NoopCounterMetric extends NoopMetric implements Counter { - add(_value: number, _labels: Labels): void {} + add(_value: number, _attributes: Attributes): void {} } export class NoopUpDownCounterMetric extends NoopMetric implements UpDownCounter { - add(_value: number, _labels: Labels): void {} + add(_value: number, _attributes: Attributes): void {} } export class NoopHistogramMetric extends NoopMetric implements Histogram { - record(_value: number, _labels: Labels): void {} + record(_value: number, _attributes: Attributes): void {} } export class NoopObservableBaseMetric extends NoopMetric implements ObservableBase { diff --git a/experimental/packages/opentelemetry-api-metrics/src/types/Meter.ts b/experimental/packages/opentelemetry-api-metrics/src/types/Meter.ts index a3e37538ea..ce4d57a4f8 100644 --- a/experimental/packages/opentelemetry-api-metrics/src/types/Meter.ts +++ b/experimental/packages/opentelemetry-api-metrics/src/types/Meter.ts @@ -39,7 +39,7 @@ export interface MeterOptions { * An interface to allow the recording metrics. * * {@link Metric}s are used for recording pre-defined aggregation (`Counter`), - * or raw values (`Histogram`) in which the aggregation and labels + * or raw values (`Histogram`) in which the aggregation and attributes * for the exported metric are deferred. */ export interface Meter { diff --git a/experimental/packages/opentelemetry-api-metrics/src/types/Metric.ts b/experimental/packages/opentelemetry-api-metrics/src/types/Metric.ts index 90fc93fdac..3ba86d3e87 100644 --- a/experimental/packages/opentelemetry-api-metrics/src/types/Metric.ts +++ b/experimental/packages/opentelemetry-api-metrics/src/types/Metric.ts @@ -37,8 +37,8 @@ export interface MetricOptions { */ unit?: string; - /** The map of constant labels for the Metric. */ - constantLabels?: Map; + /** The map of constant attributes for the Metric. */ + constantAttributes?: Map; /** * Indicates the metric is a verbose metric that is disabled by default @@ -93,30 +93,30 @@ export enum AggregationTemporality { */ export interface Counter { /** - * Adds the given value to the current value. Values cannot be negative. + * Increment value of counter by the input. Inputs may not be negative. */ - add(value: number, labels?: Labels): void; + add(value: number, attributes?: Attributes): void; } export interface UpDownCounter { /** - * Adds the given value to the current value. Values can be negative. + * Increment value of counter by the input. Inputs may be negative. */ - add(value: number, labels?: Labels): void; + add(value: number, attributes?: Attributes): void; } export interface Histogram { /** * Records the given value to this histogram. */ - record(value: number, labels?: Labels): void; + record(value: number, attributes?: Attributes): void; } /** Base interface for the Observable metrics. */ export interface ObservableBase { observation: ( value: number, - labels?: Labels, + attributes?: Attributes, ) => Observation; } @@ -132,4 +132,4 @@ export type ObservableCounter = ObservableBase; /** * key-value pairs passed by the user. */ -export type Labels = { [key: string]: string }; +export type Attributes = { [key: string]: string }; diff --git a/experimental/packages/opentelemetry-api-metrics/src/types/ObservableResult.ts b/experimental/packages/opentelemetry-api-metrics/src/types/ObservableResult.ts index c909833ab9..74f71d4acc 100644 --- a/experimental/packages/opentelemetry-api-metrics/src/types/ObservableResult.ts +++ b/experimental/packages/opentelemetry-api-metrics/src/types/ObservableResult.ts @@ -14,11 +14,11 @@ * limitations under the License. */ -import { Labels } from './Metric'; +import { Attributes } from './Metric'; /** * Interface that is being used in callback function for Observable Metric */ export interface ObservableResult { - observe(value: number, labels: Labels): void; + observe(value: number, attributes: Attributes): void; } diff --git a/experimental/packages/opentelemetry-api-metrics/test/noop-implementations/noop-meter.test.ts b/experimental/packages/opentelemetry-api-metrics/test/noop-implementations/noop-meter.test.ts index b09c2cdd0e..4d5fced1f9 100644 --- a/experimental/packages/opentelemetry-api-metrics/test/noop-implementations/noop-meter.test.ts +++ b/experimental/packages/opentelemetry-api-metrics/test/noop-implementations/noop-meter.test.ts @@ -25,16 +25,16 @@ describe('NoopMeter', () => { it('should not crash', () => { const meter = new NoopMeterProvider().getMeter('test-noop'); const counter = meter.createCounter('some-name'); - const labels = {}; + const attributes = {}; // ensure NoopMetric does not crash. - counter.add(1, labels); + counter.add(1, attributes); // ensure the correct noop const is returned assert.strictEqual(counter, NOOP_COUNTER_METRIC); const histogram = meter.createHistogram('some-name'); - histogram.record(1, labels); + histogram.record(1, attributes); // ensure the correct noop const is returned assert.strictEqual(histogram, NOOP_HISTOGRAM_METRIC); diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/transformMetrics.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/transformMetrics.ts index c7b9169563..b63947c28b 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/transformMetrics.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/transformMetrics.ts @@ -15,7 +15,7 @@ */ import { SpanAttributes, HrTime } from '@opentelemetry/api'; -import { Labels, ValueType } from '@opentelemetry/api-metrics'; +import { Attributes as Labels, ValueType } from '@opentelemetry/api-metrics'; import * as core from '@opentelemetry/core'; import { AggregatorKind, @@ -54,7 +54,7 @@ export function toAggregationTemporality( } /** - * Returns an DataPoint which can have integers or doublle values + * Returns an DataPoint which can have integers or double values * @param metric * @param startTime */ @@ -63,7 +63,7 @@ export function toDataPoint( startTime: number ): otlpTypes.opentelemetryProto.metrics.v1.DataPoint { return { - labels: toCollectorLabels(metric.labels), + labels: toCollectorLabels(metric.attributes), value: metric.aggregator.toPoint().value as number, startTimeUnixNano: startTime, timeUnixNano: core.hrTimeToNanoseconds( @@ -86,7 +86,7 @@ export function toHistogramPoint( timestamp: HrTime; }; return { - labels: toCollectorLabels(metric.labels), + labels: toCollectorLabels(metric.attributes), sum: value.sum, count: value.count, startTimeUnixNano: startTime, diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/common/transformMetrics.test.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/common/transformMetrics.test.ts index b14e1b96d5..3169c02c80 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/common/transformMetrics.test.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/common/transformMetrics.test.ts @@ -158,7 +158,7 @@ describe('transformMetrics', () => { ); }); - it('should convert metric labels value to string', () => { + it('should convert metric attributes value to string', () => { const metric = transform.toCollectorMetric( { descriptor: { @@ -168,7 +168,7 @@ describe('transformMetrics', () => { metricKind: 0, valueType: 0, }, - labels: { foo: (1 as unknown) as string }, + attributes: { foo: (1 as unknown) as string }, aggregator: new SumAggregator(), resource: new Resource({}), aggregationTemporality: 0, diff --git a/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusLabelsBatcher.ts b/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusAttributesBatcher.ts similarity index 90% rename from experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusLabelsBatcher.ts rename to experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusAttributesBatcher.ts index d04e87f532..1ac7bb5ac9 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusLabelsBatcher.ts +++ b/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusAttributesBatcher.ts @@ -26,7 +26,7 @@ interface BatcherCheckpoint { records: Map; } -export class PrometheusLabelsBatcher { +export class PrometheusAttributesBatcher { private _batchMap = new Map(); get hasMetric(): boolean { @@ -45,10 +45,10 @@ export class PrometheusLabelsBatcher { this._batchMap.set(name, item); } const recordMap = item.records; - const labels = Object.keys(record.labels) - .map(k => `${k}=${record.labels[k]}`) + const attributes = Object.keys(record.attributes) + .map(k => `${k}=${record.attributes[k]}`) .join(','); - recordMap.set(labels, record); + recordMap.set(attributes, record); } checkPointSet(): PrometheusCheckpoint[] { diff --git a/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts b/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts index 3028f22723..807b7a6636 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts +++ b/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts @@ -25,7 +25,7 @@ import { createServer, IncomingMessage, Server, ServerResponse } from 'http'; import * as url from 'url'; import { ExporterConfig } from './export/types'; import { PrometheusSerializer } from './PrometheusSerializer'; -import { PrometheusLabelsBatcher } from './PrometheusLabelsBatcher'; +import { PrometheusAttributesBatcher } from './PrometheusAttributesBatcher'; export class PrometheusExporter implements MetricExporter { static readonly DEFAULT_OPTIONS = { @@ -43,10 +43,10 @@ export class PrometheusExporter implements MetricExporter { private readonly _prefix?: string; private readonly _appendTimestamp: boolean; private _serializer: PrometheusSerializer; - private _batcher = new PrometheusLabelsBatcher(); + private _batcher = new PrometheusAttributesBatcher(); // This will be required when histogram is implemented. Leaving here so it is not forgotten - // Histogram cannot have a label named 'le' + // Histogram cannot have a attribute named 'le' // private static readonly RESERVED_HISTOGRAM_LABEL = 'le'; /** diff --git a/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusSerializer.ts b/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusSerializer.ts index 35473b14a3..c08943cffa 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusSerializer.ts +++ b/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusSerializer.ts @@ -19,7 +19,7 @@ import { MetricKind, } from '@opentelemetry/sdk-metrics-base'; import { PrometheusCheckpoint } from './types'; -import { Labels } from '@opentelemetry/api-metrics'; +import { Attributes } from '@opentelemetry/api-metrics'; import { hrTimeToMilliseconds } from '@opentelemetry/core'; type PrometheusDataTypeLiteral = @@ -33,7 +33,7 @@ function escapeString(str: string) { return str.replace(/\\/g, '\\\\').replace(/\n/g, '\\n'); } -function escapeLabelValue(str: string) { +function escapeAttributeValue(str: string) { if (typeof str !== 'string') { str = String(str); } @@ -45,7 +45,7 @@ const invalidCharacterRegex = /[^a-z0-9_]/gi; * Ensures metric names are valid Prometheus metric names by removing * characters allowed by OpenTelemetry but disallowed by Prometheus. * - * https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels + * https://prometheus.io/docs/concepts/data_model/#metric-names-and-attributes * * 1. Names must match `[a-zA-Z_:][a-zA-Z0-9_:]*` * @@ -123,33 +123,33 @@ function toPrometheusType( function stringify( metricName: string, - labels: Labels, + attributes: Attributes, value: number, timestamp?: number, - additionalLabels?: Labels + additionalAttributes?: Attributes ) { - let hasLabel = false; - let labelsStr = ''; + let hasAttribute = false; + let attributesStr = ''; - for (const [key, val] of Object.entries(labels)) { - const sanitizedLabelName = sanitizePrometheusMetricName(key); - hasLabel = true; - labelsStr += `${ - labelsStr.length > 0 ? ',' : '' - }${sanitizedLabelName}="${escapeLabelValue(val)}"`; + for (const [key, val] of Object.entries(attributes)) { + const sanitizedAttributeName = sanitizePrometheusMetricName(key); + hasAttribute = true; + attributesStr += `${ + attributesStr.length > 0 ? ',' : '' + }${sanitizedAttributeName}="${escapeAttributeValue(val)}"`; } - if (additionalLabels) { - for (const [key, val] of Object.entries(additionalLabels)) { - const sanitizedLabelName = sanitizePrometheusMetricName(key); - hasLabel = true; - labelsStr += `${ - labelsStr.length > 0 ? ',' : '' - }${sanitizedLabelName}="${escapeLabelValue(val)}"`; + if (additionalAttributes) { + for (const [key, val] of Object.entries(additionalAttributes)) { + const sanitizedAttributeName = sanitizePrometheusMetricName(key); + hasAttribute = true; + attributesStr += `${ + attributesStr.length > 0 ? ',' : '' + }${sanitizedAttributeName}="${escapeAttributeValue(val)}"`; } } - if (hasLabel) { - metricName += `{${labelsStr}}`; + if (hasAttribute) { + metricName += `{${attributesStr}}`; } return `${metricName} ${valueString(value)}${ @@ -219,7 +219,7 @@ export class PrometheusSerializer { const timestamp = hrTimeToMilliseconds(hrtime); results += stringify( name, - record.labels, + record.attributes, value, this._appendTimestamp ? timestamp : undefined, undefined @@ -233,7 +233,7 @@ export class PrometheusSerializer { for (const key of ['count', 'sum'] as ('count' | 'sum')[]) { results += stringify( name + '_' + key, - record.labels, + record.attributes, value[key], this._appendTimestamp ? timestamp : undefined, undefined @@ -260,7 +260,7 @@ export class PrometheusSerializer { } results += stringify( name + '_bucket', - record.labels, + record.attributes, cumulativeSum, this._appendTimestamp ? timestamp : undefined, { diff --git a/experimental/packages/opentelemetry-exporter-prometheus/test/ExactProcessor.ts b/experimental/packages/opentelemetry-exporter-prometheus/test/ExactProcessor.ts index 6330e93eb5..f69b716ad4 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/test/ExactProcessor.ts +++ b/experimental/packages/opentelemetry-exporter-prometheus/test/ExactProcessor.ts @@ -41,9 +41,9 @@ export class ExactProcessor extends Processor { } process(record: MetricRecord): void { - const labels = Object.keys(record.labels) - .map(k => `${k}=${record.labels[k]}`) + const attributes = Object.keys(record.attributes) + .map(k => `${k}=${record.attributes[k]}`) .join(','); - this._batchMap.set(record.descriptor.name + labels, record); + this._batchMap.set(record.descriptor.name + attributes, record); } } diff --git a/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts b/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts index 3528df2c42..8808c092ee 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts +++ b/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts @@ -243,14 +243,14 @@ describe('PrometheusExporter', () => { description: 'a test description', }); - counter.add(10, { key1: 'labelValue1' }); + counter.add(10, { key1: 'attributeValue1' }); meter.collect().then(() => { exporter.export(meter.getProcessor().checkPointSet(), () => { // TODO: Remove this special case once the PR is ready. // This is to test the special case where counters are destroyed // and recreated in the exporter in order to get around prom-client's // aggregation and use ours. - counter.add(10, { key1: 'labelValue1' }); + counter.add(10, { key1: 'attributeValue1' }); exporter.export(meter.getProcessor().checkPointSet(), () => { http .get('http://localhost:9464/metrics', res => { @@ -266,7 +266,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP counter_total a test description', '# TYPE counter_total counter', - `counter_total{key1="labelValue1"} 20 ${mockedHrTimeMs}`, + `counter_total{key1="attributeValue1"} 20 ${mockedHrTimeMs}`, '', ]); @@ -321,13 +321,13 @@ describe('PrometheusExporter', () => { }); }); - it('should export multiple labels', done => { + it('should export multiple attributes', done => { const counter = meter.createCounter('counter_total', { description: 'a test description', }) as CounterMetric; - counter.add(10, { counterKey1: 'labelValue1' }); - counter.add(20, { counterKey1: 'labelValue2' }); + counter.add(10, { counterKey1: 'attributeValue1' }); + counter.add(20, { counterKey1: 'attributeValue2' }); meter.collect().then(() => { exporter.export(meter.getProcessor().checkPointSet(), () => { http @@ -339,8 +339,8 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP counter_total a test description', '# TYPE counter_total counter', - `counter_total{counterKey1="labelValue1"} 10 ${mockedHrTimeMs}`, - `counter_total{counterKey1="labelValue2"} 20 ${mockedHrTimeMs}`, + `counter_total{counterKey1="attributeValue1"} 10 ${mockedHrTimeMs}`, + `counter_total{counterKey1="attributeValue2"} 20 ${mockedHrTimeMs}`, '', ]); @@ -352,14 +352,14 @@ describe('PrometheusExporter', () => { }); }); - it('should export multiple labels on manual shutdown', done => { + it('should export multiple attributes on manual shutdown', done => { const counter = meter.createCounter('counter_total', { description: 'a test description', }) as CounterMetric; - counter.add(10, { counterKey1: 'labelValue1' }); - counter.add(20, { counterKey1: 'labelValue2' }); - counter.add(30, { counterKey1: 'labelValue3' }); + counter.add(10, { counterKey1: 'attributeValue1' }); + counter.add(20, { counterKey1: 'attributeValue2' }); + counter.add(30, { counterKey1: 'attributeValue3' }); meterProvider.shutdown().then(() => { // exporter has been shut down along with meter provider. http @@ -393,7 +393,7 @@ describe('PrometheusExporter', () => { it('should add a description if missing', done => { const counter = meter.createCounter('counter_total'); - counter.add(10, { key1: 'labelValue1' }); + counter.add(10, { key1: 'attributeValue1' }); meter.collect().then(() => { exporter.export(meter.getProcessor().checkPointSet(), () => { http @@ -405,7 +405,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP counter_total description missing', '# TYPE counter_total counter', - `counter_total{key1="labelValue1"} 10 ${mockedHrTimeMs}`, + `counter_total{key1="attributeValue1"} 10 ${mockedHrTimeMs}`, '', ]); @@ -420,7 +420,7 @@ describe('PrometheusExporter', () => { it('should sanitize names', done => { const counter = meter.createCounter('counter.bad-name'); - counter.add(10, { key1: 'labelValue1' }); + counter.add(10, { key1: 'attributeValue1' }); meter.collect().then(() => { exporter.export(meter.getProcessor().checkPointSet(), () => { http @@ -432,7 +432,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP counter_bad_name_total description missing', '# TYPE counter_bad_name_total counter', - `counter_bad_name_total{key1="labelValue1"} 10 ${mockedHrTimeMs}`, + `counter_bad_name_total{key1="attributeValue1"} 10 ${mockedHrTimeMs}`, '', ]); @@ -449,7 +449,7 @@ describe('PrometheusExporter', () => { description: 'a test description', }); - counter.add(20, { key1: 'labelValue1' }); + counter.add(20, { key1: 'attributeValue1' }); meter.collect().then(() => { exporter.export(meter.getProcessor().checkPointSet(), () => { http @@ -458,7 +458,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(chunk.toString().split('\n'), [ '# HELP counter a test description', '# TYPE counter gauge', - `counter{key1="labelValue1"} 20 ${mockedHrTimeMs}`, + `counter{key1="attributeValue1"} 20 ${mockedHrTimeMs}`, '', ]); @@ -482,7 +482,7 @@ describe('PrometheusExporter', () => { }, (observableResult: ObservableResult) => { observableResult.observe(getValue(), { - key1: 'labelValue1', + key1: 'attributeValue1', }); } ); @@ -498,7 +498,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP metric_observable_counter a test description', '# TYPE metric_observable_counter gauge', - `metric_observable_counter{key1="labelValue1"} 20 ${mockedHrTimeMs}`, + `metric_observable_counter{key1="attributeValue1"} 20 ${mockedHrTimeMs}`, '', ]); }); @@ -522,7 +522,7 @@ describe('PrometheusExporter', () => { }, (observableResult: ObservableResult) => { observableResult.observe(getValue(), { - key1: 'labelValue1', + key1: 'attributeValue1', }); } ); @@ -538,7 +538,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP metric_observable_up_down_counter a test description', '# TYPE metric_observable_up_down_counter gauge', - `metric_observable_up_down_counter{key1="labelValue1"} 20 ${mockedHrTimeMs}`, + `metric_observable_up_down_counter{key1="attributeValue1"} 20 ${mockedHrTimeMs}`, '', ]); }); @@ -555,7 +555,7 @@ describe('PrometheusExporter', () => { description: 'a test description', }); - histogram.record(20, { key1: 'labelValue1' }); + histogram.record(20, { key1: 'attributeValue1' }); meter.collect().then(() => { exporter.export(meter.getProcessor().checkPointSet(), () => { @@ -568,9 +568,9 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP test_histogram a test description', '# TYPE test_histogram histogram', - `test_histogram_count{key1="labelValue1"} 1 ${mockedHrTimeMs}`, - `test_histogram_sum{key1="labelValue1"} 20 ${mockedHrTimeMs}`, - `test_histogram_bucket{key1="labelValue1",le="+Inf"} 1 ${mockedHrTimeMs}`, + `test_histogram_count{key1="attributeValue1"} 1 ${mockedHrTimeMs}`, + `test_histogram_sum{key1="attributeValue1"} 20 ${mockedHrTimeMs}`, + `test_histogram_bucket{key1="attributeValue1",le="+Inf"} 1 ${mockedHrTimeMs}`, '', ]); @@ -591,7 +591,7 @@ describe('PrometheusExporter', () => { beforeEach(() => { meter = new MeterProvider().getMeter('test-prometheus'); counter = meter.createCounter('counter') as CounterMetric; - counter.add(10, { key1: 'labelValue1' }); + counter.add(10, { key1: 'attributeValue1' }); }); afterEach(done => { @@ -620,7 +620,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP test_prefix_counter_total description missing', '# TYPE test_prefix_counter_total counter', - `test_prefix_counter_total{key1="labelValue1"} 10 ${mockedHrTimeMs}`, + `test_prefix_counter_total{key1="attributeValue1"} 10 ${mockedHrTimeMs}`, '', ]); @@ -650,7 +650,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP counter_total description missing', '# TYPE counter_total counter', - `counter_total{key1="labelValue1"} 10 ${mockedHrTimeMs}`, + `counter_total{key1="attributeValue1"} 10 ${mockedHrTimeMs}`, '', ]); @@ -680,7 +680,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP counter_total description missing', '# TYPE counter_total counter', - `counter_total{key1="labelValue1"} 10 ${mockedHrTimeMs}`, + `counter_total{key1="attributeValue1"} 10 ${mockedHrTimeMs}`, '', ]); @@ -710,7 +710,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP counter_total description missing', '# TYPE counter_total counter', - 'counter_total{key1="labelValue1"} 10', + 'counter_total{key1="attributeValue1"} 10', '', ]); diff --git a/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusLabelsBatcher.test.ts b/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusLabelsBatcher.test.ts index 8ef180a27e..0f1f00f370 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusLabelsBatcher.test.ts +++ b/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusLabelsBatcher.test.ts @@ -14,14 +14,14 @@ * limitations under the License. */ import * as assert from 'assert'; -import { PrometheusLabelsBatcher } from '../src/PrometheusLabelsBatcher'; +import { PrometheusAttributesBatcher } from '../src/PrometheusAttributesBatcher'; import { CounterMetric, AggregatorKind, MeterProvider, Meter, } from '@opentelemetry/sdk-metrics-base'; -import { Labels } from '@opentelemetry/api-metrics'; +import { Attributes } from '@opentelemetry/api-metrics'; describe('PrometheusBatcher', () => { let meter: Meter; @@ -31,14 +31,14 @@ describe('PrometheusBatcher', () => { describe('constructor', () => { it('should construct a batcher', () => { - const batcher = new PrometheusLabelsBatcher(); - assert(batcher instanceof PrometheusLabelsBatcher); + const batcher = new PrometheusAttributesBatcher(); + assert(batcher instanceof PrometheusAttributesBatcher); }); }); describe('process', () => { it('should aggregate metric records with same metric name', async () => { - const batcher = new PrometheusLabelsBatcher(); + const batcher = new PrometheusAttributesBatcher(); const counter = meter.createCounter('test_counter') as CounterMetric; counter.add(1, { val: '1' }); counter.add(1, { val: '2' }); @@ -53,20 +53,20 @@ describe('PrometheusBatcher', () => { assert.strictEqual(checkPointSet[0].records.length, 2); }); - it('should recognize identical labels with different key-insertion order', async () => { - const batcher = new PrometheusLabelsBatcher(); + it('should recognize identical attributes with different key-insertion order', async () => { + const batcher = new PrometheusAttributesBatcher(); const counter = meter.createCounter('test_counter') as CounterMetric; - const label1: Labels = {}; - label1.key1 = '1'; - label1.key2 = '2'; + const attribute1: Attributes = {}; + attribute1.key1 = '1'; + attribute1.key2 = '2'; - const label2: Labels = {}; - label2.key2 = '2'; - label2.key1 = '1'; + const attribute2: Attributes = {}; + attribute2.key2 = '2'; + attribute2.key1 = '1'; - counter.add(1, label1); - counter.add(1, label2); + counter.bind(attribute1).add(1); + counter.bind(attribute2).add(1); const records = await counter.getMetricRecord(); records.forEach(it => batcher.process(it)); diff --git a/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts b/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts index 88a5422344..865353b116 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts +++ b/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts @@ -25,13 +25,13 @@ import { } from '@opentelemetry/sdk-metrics-base'; import { diag, DiagLogLevel } from '@opentelemetry/api'; import * as assert from 'assert'; -import { Labels } from '@opentelemetry/api-metrics'; +import { Attributes } from '@opentelemetry/api-metrics'; import { PrometheusSerializer } from '../src/PrometheusSerializer'; -import { PrometheusLabelsBatcher } from '../src/PrometheusLabelsBatcher'; +import { PrometheusAttributesBatcher } from '../src/PrometheusAttributesBatcher'; import { ExactProcessor } from './ExactProcessor'; import { mockedHrTimeMs, mockAggregator } from './util'; -const labels = { +const attributes = { foo1: 'bar1', foo2: 'bar2', }; @@ -55,7 +55,7 @@ describe('PrometheusSerializer', () => { processor: new ExactProcessor(SumAggregator), }).getMeter('test'); const counter = meter.createCounter('test_total') as CounterMetric; - counter.add(1, labels); + counter.add(1, attributes); const records = await counter.getMetricRecord(); const record = records[0]; @@ -77,7 +77,7 @@ describe('PrometheusSerializer', () => { processor: new ExactProcessor(SumAggregator), }).getMeter('test'); const counter = meter.createCounter('test_total') as CounterMetric; - counter.add(1, labels); + counter.add(1, attributes); const records = await counter.getMetricRecord(); const record = records[0]; @@ -103,7 +103,7 @@ describe('PrometheusSerializer', () => { 'test', {}, observableResult => { - observableResult.observe(1, labels); + observableResult.observe(1, attributes); } ) as ObservableGaugeMetric; await meter.collect(); @@ -130,7 +130,7 @@ describe('PrometheusSerializer', () => { 'test', {}, observableResult => { - observableResult.observe(1, labels); + observableResult.observe(1, attributes); } ) as ObservableGaugeMetric; await meter.collect(); @@ -157,7 +157,7 @@ describe('PrometheusSerializer', () => { description: 'foobar', }) as HistogramMetric; - histogram.record(5, labels); + histogram.record(5, attributes); const records = await histogram.getMetricRecord(); const record = records[0]; @@ -185,7 +185,7 @@ describe('PrometheusSerializer', () => { description: 'foobar', boundaries: [1, 10, 100], }) as HistogramMetric; - histogram.record(5, labels); + histogram.record(5, attributes); const records = await histogram.getMetricRecord(); const record = records[0]; @@ -213,7 +213,7 @@ describe('PrometheusSerializer', () => { const histogram = meter.createHistogram('test', { description: 'foobar', }) as HistogramMetric; - histogram.record(5, labels); + histogram.record(5, attributes); const records = await histogram.getMetricRecord(); const record = records[0]; @@ -245,7 +245,7 @@ describe('PrometheusSerializer', () => { const meter = new MeterProvider({ processor: new ExactProcessor(SumAggregator), }).getMeter('test'); - const processor = new PrometheusLabelsBatcher(); + const processor = new PrometheusAttributesBatcher(); const counter = meter.createCounter('test_total', { description: 'foobar', }) as CounterMetric; @@ -272,7 +272,7 @@ describe('PrometheusSerializer', () => { const meter = new MeterProvider({ processor: new ExactProcessor(SumAggregator), }).getMeter('test'); - const processor = new PrometheusLabelsBatcher(); + const processor = new PrometheusAttributesBatcher(); const counter = meter.createCounter('test_total', { description: 'foobar', }) as CounterMetric; @@ -303,14 +303,14 @@ describe('PrometheusSerializer', () => { const meter = new MeterProvider({ processor: new ExactProcessor(LastValueAggregator), }).getMeter('test'); - const processor = new PrometheusLabelsBatcher(); + const processor = new PrometheusAttributesBatcher(); const observableGauge = meter.createObservableGauge( 'test', { description: 'foobar', }, observableResult => { - observableResult.observe(1, labels); + observableResult.observe(1, attributes); } ) as ObservableGaugeMetric; await meter.collect(); @@ -346,9 +346,9 @@ describe('PrometheusSerializer', () => { histogram.record(5, { val: '2' }); const records = await histogram.getMetricRecord(); - const labelBatcher = new PrometheusLabelsBatcher(); - records.forEach(it => labelBatcher.process(it)); - const checkPointSet = labelBatcher.checkPointSet(); + const attributeBatcher = new PrometheusAttributesBatcher(); + records.forEach(it => attributeBatcher.process(it)); + const checkPointSet = attributeBatcher.checkPointSet(); const result = serializer.serialize(checkPointSet); assert.strictEqual( @@ -425,7 +425,7 @@ describe('PrometheusSerializer', () => { describe('with SumAggregator', () => { mockAggregator(SumAggregator); - it('should serialize records without labels', async () => { + it('should serialize records without attributes', async () => { const serializer = new PrometheusSerializer(); const meter = new MeterProvider({ @@ -444,7 +444,7 @@ describe('PrometheusSerializer', () => { assert.strictEqual(result, `test_total 1 ${mockedHrTimeMs}\n`); }); - it('should serialize non-string label values', async () => { + it('should serialize non-string attribute values', async () => { const serializer = new PrometheusSerializer(); const meter = new MeterProvider({ @@ -456,7 +456,7 @@ describe('PrometheusSerializer', () => { NaN: NaN, null: null, undefined: undefined, - } as unknown) as Labels); + } as unknown) as Attributes); const records = await counter.getMetricRecord(); const record = records[0]; @@ -485,7 +485,7 @@ describe('PrometheusSerializer', () => { const counter = meter.createUpDownCounter( 'test' ) as UpDownCounterMetric; - counter.add(esac[0], labels); + counter.add(esac[0], attributes); const records = await counter.getMetricRecord(); const record = records[0]; @@ -500,7 +500,7 @@ describe('PrometheusSerializer', () => { } }); - it('should escape backslash (\\), double-quote ("), and line feed (\\n) in label values', async () => { + it('should escape backslash (\\), double-quote ("), and line feed (\\n) in attribute values', async () => { const serializer = new PrometheusSerializer(); const meter = new MeterProvider({ @@ -514,7 +514,7 @@ describe('PrometheusSerializer', () => { backslashN: '\u005c\u006e', // \n => \\n (\u005c\u005c\u006e) backslashDoubleQuote: '\u005c\u0022', // \" => \\\" (\u005c\u005c\u005c\u0022) backslashLineFeed: '\u005c\u000a', // \↵ => \\\n (\u005c\u005c\u005c\u006e) - } as unknown) as Labels); + } as unknown) as Attributes); const records = await counter.getMetricRecord(); const record = records[0]; @@ -535,19 +535,19 @@ describe('PrometheusSerializer', () => { ); }); - it('should sanitize label names', async () => { + it('should sanitize attribute names', async () => { const serializer = new PrometheusSerializer(); const meter = new MeterProvider({ processor: new ExactProcessor(SumAggregator), }).getMeter('test_total'); const counter = meter.createCounter('test') as CounterMetric; - // if you try to use a label name like account-id prometheus will complain + // if you try to use a attribute name like account-id prometheus will complain // with an error like: // error while linting: text format parsing error in line 282: expected '=' after label name, found '-' counter.add(1, ({ 'account-id': '123456', - } as unknown) as Labels); + } as unknown) as Attributes); const records = await counter.getMetricRecord(); const record = records[0]; diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/README.md b/experimental/packages/opentelemetry-sdk-metrics-base/README.md index b89b7658e8..cf1d5bcdc2 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/README.md +++ b/experimental/packages/opentelemetry-sdk-metrics-base/README.md @@ -36,8 +36,8 @@ const counter = meter.createCounter('metric_name', { description: 'Example of a counter' }); -const labels = { pid: process.pid }; -counter.add(10, labels); +const attributes = { pid: process.pid }; +counter.add(10, attributes); ``` ### UpDownCounter @@ -61,8 +61,8 @@ const counter = meter.createUpDownCounter('metric_name', { description: 'Example of a UpDownCounter' }); -const labels = { pid: process.pid }; -counter.add(Math.random() > 0.5 ? 1 : -1, labels); +const attributes = { pid: process.pid }; +counter.add(Math.random() > 0.5 ? 1 : -1, attributes); ``` ### Observable Gauge @@ -81,7 +81,7 @@ meter.createObservableGauge('your_metric_name', { description: 'Example of an async observable gauge with callback', }, async (observableResult) => { const value = await getAsyncValue(); - observableResult.observe(value, { label: '1' }); + observableResult.observe(value, { attribute: '1' }); }); function getAsyncValue() { @@ -96,8 +96,8 @@ function getAsyncValue() { meter.createObservableGauge('your_metric_name', { description: 'Example of a sync observable gauge with callback', }, (observableResult) => { - observableResult.observe(getRandomValue(), { label: '1' }); - observableResult.observe(getRandomValue(), { label: '2' }); + observableResult.observe(getRandomValue(), { attribute: '1' }); + observableResult.observe(getRandomValue(), { attribute: '2' }); }); function getRandomValue() { @@ -120,7 +120,7 @@ meter.createObservableUpDownCounter('your_metric_name', { description: 'Example of an async observable up down counter with callback', }, async (observableResult) => { const value = await getAsyncValue(); - observableResult.observe(value, { label: '1' }); + observableResult.observe(value, { attribute: '1' }); }); function getAsyncValue() { @@ -135,7 +135,7 @@ function getAsyncValue() { meter.createObservableUpDownCounter('your_metric_name', { description: 'Example of a sync observable up down counter with callback', }, (observableResult) => { - observableResult.observe(getRandomValue(), { label: '1' }); + observableResult.observe(getRandomValue(), { attribute: '1' }); }); function getRandomValue() { @@ -159,7 +159,7 @@ meter.createObservableCounter('example_metric', { description: 'Example of an async observable counter with callback', }, async (observableResult) => { const value = await getAsyncValue(); - observableResult.observe(value, { label: '1' }); + observableResult.observe(value, { attribute: '1' }); }); function getAsyncValue() { @@ -175,7 +175,7 @@ meter.createObservableCounter('example_metric', { description: 'Example of a sync observable counter with callback', }, (observableResult) => { const value = getRandomValue(); - observableResult.observe(value, { label: '1' }); + observableResult.observe(value, { attribute: '1' }); }); function getRandomValue() { diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/BoundInstrument.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/BoundInstrument.ts index e09524e3a2..71d330626b 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/BoundInstrument.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/BoundInstrument.ts @@ -23,15 +23,15 @@ import { Aggregator } from './export/types'; * the TimeSeries. */ export class BaseBoundInstrument { - protected _labels: api.Labels; + protected _attributes: api.Attributes; constructor( - labels: api.Labels, + attributes: api.Attributes, private readonly _disabled: boolean, private readonly _valueType: api.ValueType, private readonly _aggregator: Aggregator ) { - this._labels = labels; + this._attributes = attributes; } update(value: number): void { @@ -39,7 +39,7 @@ export class BaseBoundInstrument { if (typeof value !== 'number') { diag.error( `Metric cannot accept a non-number value for ${Object.values( - this._labels + this._attributes )}.` ); return; @@ -48,7 +48,7 @@ export class BaseBoundInstrument { if (this._valueType === api.ValueType.INT && !Number.isInteger(value)) { diag.warn( `INT value type cannot accept a floating-point value for ${Object.values( - this._labels + this._attributes )}, ignoring the fractional digits.` ); value = Math.trunc(value); @@ -57,8 +57,8 @@ export class BaseBoundInstrument { this._aggregator.update(value); } - getLabels(): api.Labels { - return this._labels; + getAttributes(): api.Attributes { + return this._attributes; } getAggregator(): Aggregator { @@ -68,23 +68,23 @@ export class BaseBoundInstrument { /** * BoundCounter allows the SDK to observe/record a single metric event. The - * value of single instrument in the `Counter` associated with specified Labels. + * value of single instrument in the `Counter` associated with specified Attributes. */ export class BoundCounter extends BaseBoundInstrument implements api.Counter { constructor( - labels: api.Labels, + attributes: api.Attributes, disabled: boolean, valueType: api.ValueType, aggregator: Aggregator ) { - super(labels, disabled, valueType, aggregator); + super(attributes, disabled, valueType, aggregator); } add(value: number): void { if (value < 0) { - diag.error(`Counter cannot descend for ${Object.values(this._labels)}`); + diag.error(`Counter cannot descend for ${Object.values(this._attributes)}`); return; } @@ -95,18 +95,18 @@ export class BoundCounter /** * BoundUpDownCounter allows the SDK to observe/record a single metric event. * The value of single instrument in the `UpDownCounter` associated with - * specified Labels. + * specified Attributes. */ export class BoundUpDownCounter extends BaseBoundInstrument implements api.UpDownCounter { constructor( - labels: api.Labels, + attributes: api.Attributes, disabled: boolean, valueType: api.ValueType, aggregator: Aggregator ) { - super(labels, disabled, valueType, aggregator); + super(attributes, disabled, valueType, aggregator); } add(value: number): void { @@ -121,12 +121,12 @@ export class BoundHistogram extends BaseBoundInstrument implements api.Histogram { constructor( - labels: api.Labels, + attributes: api.Attributes, disabled: boolean, valueType: api.ValueType, aggregator: Aggregator ) { - super(labels, disabled, valueType, aggregator); + super(attributes, disabled, valueType, aggregator); } record(value: number): void { @@ -139,11 +139,11 @@ export class BoundHistogram */ export class BoundObservable extends BaseBoundInstrument { constructor( - labels: api.Labels, + attributes: api.Attributes, disabled: boolean, valueType: api.ValueType, aggregator: Aggregator ) { - super(labels, disabled, valueType, aggregator); + super(attributes, disabled, valueType, aggregator); } } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/CounterMetric.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/CounterMetric.ts index 4f4fe3f04d..cda71ac921 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/CounterMetric.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/CounterMetric.ts @@ -33,9 +33,9 @@ export class CounterMetric extends Metric implements api.Counter { ) { super(name, options, MetricKind.COUNTER, resource, instrumentationLibrary); } - protected _makeInstrument(labels: api.Labels): BoundCounter { + protected _makeInstrument(attributes: api.Attributes): BoundCounter { return new BoundCounter( - labels, + attributes, this._disabled, this._valueType, this._processor.aggregatorFor(this._descriptor) @@ -45,10 +45,10 @@ export class CounterMetric extends Metric implements api.Counter { /** * Adds the given value to the current value. Values cannot be negative. * @param value the value to add. - * @param [labels = {}] key-values pairs that are associated with a specific metric + * @param [attributes = {}] key-values pairs that are associated with a specific metric * that you want to record. */ - add(value: number, labels: api.Labels = {}): void { - this.bind(labels).add(value); + add(value: number, attributes: api.Attributes = {}): void { + this.bind(attributes).add(value); } } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/HistogramMetric.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/HistogramMetric.ts index 20a7ade3a7..07c969b51d 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/HistogramMetric.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/HistogramMetric.ts @@ -42,16 +42,16 @@ export class HistogramMetric ); } - protected _makeInstrument(labels: api.Labels): BoundHistogram { + protected _makeInstrument(attributes: api.Attributes): BoundHistogram { return new BoundHistogram( - labels, + attributes, this._disabled, this._valueType, this._processor.aggregatorFor(this._descriptor) ); } - record(value: number, labels: api.Labels = {}): void { - this.bind(labels).record(value); + record(value: number, attributes: api.Attributes = {}): void { + this.bind(attributes).record(value); } } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/Metric.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/Metric.ts index 4dc8b96878..dd7ad028fa 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/Metric.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/Metric.ts @@ -18,7 +18,7 @@ import { InstrumentationLibrary } from '@opentelemetry/core'; import { Resource } from '@opentelemetry/resources'; import { BaseBoundInstrument } from './BoundInstrument'; import { MetricDescriptor, MetricKind, MetricRecord } from './export/types'; -import { hashLabels } from './Utils'; +import { hashAttributes } from './Utils'; /** This is a SDK implementation of {@link Metric} interface. */ export abstract class Metric { @@ -50,28 +50,28 @@ export abstract class Metric { } /** - * Returns an Instrument associated with specified Labels. + * Returns an Instrument associated with specified Attributes. * It is recommended to keep a reference to the Instrument instead of always * calling this method for each operation. - * @param labels key-values pairs that are associated with a specific metric + * @param attributes key-values pairs that are associated with a specific metric * that you want to record. */ - bind(labels: api.Labels): T { - const hash = hashLabels(labels); + bind(attributes: api.Attributes): T { + const hash = hashAttributes(attributes); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion if (this._instruments.has(hash)) return this._instruments.get(hash)!; - const instrument = this._makeInstrument(labels); + const instrument = this._makeInstrument(attributes); this._instruments.set(hash, instrument); return instrument; } /** * Removes the Instrument from the metric, if it is present. - * @param labels key-values pairs that are associated with a specific metric. + * @param attributes key-values pairs that are associated with a specific metric. */ - unbind(labels: api.Labels): void { - this._instruments.delete(hashLabels(labels)); + unbind(attributes: api.Attributes): void { + this._instruments.delete(hashAttributes(attributes)); } /** @@ -97,7 +97,7 @@ export abstract class Metric { resolve( Array.from(this._instruments.values()).map(instrument => ({ descriptor: this._descriptor, - labels: instrument.getLabels(), + attributes: instrument.getAttributes(), aggregator: instrument.getAggregator(), aggregationTemporality: this.getAggregationTemporality(), resource: this.resource, @@ -118,5 +118,5 @@ export abstract class Metric { }; } - protected abstract _makeInstrument(labels: api.Labels): T; + protected abstract _makeInstrument(attributes: api.Attributes): T; } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableBaseMetric.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableBaseMetric.ts index 60626680a5..a5c24c9c0b 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableBaseMetric.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableBaseMetric.ts @@ -47,9 +47,9 @@ export abstract class ObservableBaseMetric this._callback = callback || NOOP_CALLBACK; } - protected _makeInstrument(labels: api.Labels): BoundObservable { + protected _makeInstrument(attributes: api.Attributes): BoundObservable { return new BoundObservable( - labels, + attributes, this._disabled, this._valueType, this._processor.aggregatorFor(this._descriptor) @@ -66,8 +66,8 @@ export abstract class ObservableBaseMetric } protected _processResults(observableResult: ObservableResult): void { - observableResult.values.forEach((value, labels) => { - const instrument = this.bind(labels); + observableResult.values.forEach((value, attributes) => { + const instrument = this.bind(attributes); instrument.update(value); }); } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableCounterMetric.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableCounterMetric.ts index 5465f14eff..e4b79b5878 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableCounterMetric.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableCounterMetric.ts @@ -46,8 +46,8 @@ export class ObservableCounterMetric } protected override _processResults(observableResult: ObservableResult): void { - observableResult.values.forEach((value, labels) => { - const instrument = this.bind(labels); + observableResult.values.forEach((value, attributes) => { + const instrument = this.bind(attributes); // ObservableCounter is monotonic which means it should only accept values // greater or equal then previous value const previous = instrument.getAggregator().toPoint(); diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableResult.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableResult.ts index 51fc07899e..3ad7ee8a60 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableResult.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableResult.ts @@ -16,16 +16,16 @@ import { ObservableResult as TypeObservableResult, - Labels, + Attributes, } from '@opentelemetry/api-metrics'; /** * Implementation of {@link TypeObservableResult} */ export class ObservableResult implements TypeObservableResult { - values: Map = new Map(); + values: Map = new Map(); - observe(value: number, labels: Labels): void { - this.values.set(labels, value); + observe(value: number, attributes: Attributes): void { + this.values.set(attributes, value); } } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/UpDownCounterMetric.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/UpDownCounterMetric.ts index 491a4647dc..6706ee01f7 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/UpDownCounterMetric.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/UpDownCounterMetric.ts @@ -41,9 +41,9 @@ export class UpDownCounterMetric instrumentationLibrary ); } - protected _makeInstrument(labels: api.Labels): BoundUpDownCounter { + protected _makeInstrument(attributes: api.Attributes): BoundUpDownCounter { return new BoundUpDownCounter( - labels, + attributes, this._disabled, this._valueType, this._processor.aggregatorFor(this._descriptor) @@ -53,10 +53,10 @@ export class UpDownCounterMetric /** * Adds the given value to the current value. Values cannot be negative. * @param value the value to add. - * @param [labels = {}] key-values pairs that are associated with a specific + * @param [attributes = {}] key-values pairs that are associated with a specific * metric that you want to record. */ - add(value: number, labels: api.Labels = {}): void { - this.bind(labels).add(value); + add(value: number, attributes: api.Attributes = {}): void { + this.bind(attributes).add(value); } } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/Utils.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/Utils.ts index 6b0fa1503d..8de8687fe6 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/Utils.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/Utils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Labels } from '@opentelemetry/api-metrics'; +import { Attributes } from '@opentelemetry/api-metrics'; /** * Type guard to remove nulls from arrays @@ -26,11 +26,11 @@ export function notNull(value: T | null): value is T { } /** - * Converting the unordered labels into unique identifier string. - * @param labels user provided unordered Labels. + * Converting the unordered attributes into unique identifier string. + * @param attributes user provided unordered Attributes. */ -export function hashLabels(labels: Labels): string { - let keys = Object.keys(labels); +export function hashAttributes(attributes: Attributes): string { + let keys = Object.keys(attributes); if (keys.length === 0) return ''; keys = keys.sort(); @@ -38,6 +38,6 @@ export function hashLabels(labels: Labels): string { if (result.length > 2) { result += ','; } - return (result += key + ':' + labels[key]); + return (result += key + ':' + attributes[key]); }, '|#'); } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/ConsoleMetricExporter.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/ConsoleMetricExporter.ts index acade23dc7..ccdcc8400d 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/ConsoleMetricExporter.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/ConsoleMetricExporter.ts @@ -30,7 +30,7 @@ export class ConsoleMetricExporter implements MetricExporter { ): void { for (const metric of metrics) { console.log(metric.descriptor); - console.log(metric.labels); + console.log(metric.attributes); const point = metric.aggregator.toPoint(); if (typeof point.value === 'number') { console.log('value: ' + point.value); diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/Processor.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/Processor.ts index 3cc23c70f0..519ffe99d4 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/Processor.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/Processor.ts @@ -44,7 +44,7 @@ export abstract class Processor { } /** - * Processor which retains all dimensions/labels. It accepts all records and + * Processor which retains all dimensions/attributes. It accepts all records and * passes them for exporting. */ export class UngroupedProcessor extends Processor { @@ -70,9 +70,9 @@ export class UngroupedProcessor extends Processor { } process(record: MetricRecord): void { - const labels = Object.keys(record.labels) - .map(k => `${k}=${record.labels[k]}`) + const attributes = Object.keys(record.attributes) + .map(k => `${k}=${record.attributes[k]}`) .join(','); - this._batchMap.set(record.descriptor.name + labels, record); + this._batchMap.set(record.descriptor.name + attributes, record); } } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/types.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/types.ts index 61b22f4513..0f64af0901 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/types.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/types.ts @@ -16,7 +16,7 @@ import { HrTime } from '@opentelemetry/api'; import { - Labels, + Attributes, AggregationTemporality, ValueType, } from '@opentelemetry/api-metrics'; @@ -77,7 +77,7 @@ export type PointValueType = Sum | LastValue | Histogram; export interface MetricRecord { readonly descriptor: MetricDescriptor; - readonly labels: Labels; + readonly attributes: Attributes; readonly aggregator: Aggregator; readonly aggregationTemporality: AggregationTemporality; readonly resource: Resource; diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/test/Meter.test.ts b/experimental/packages/opentelemetry-sdk-metrics-base/test/Meter.test.ts index 851ba684eb..7d227177dc 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/test/Meter.test.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/test/Meter.test.ts @@ -38,7 +38,7 @@ import { import { SumAggregator } from '../src/export/aggregators'; import { ObservableCounterMetric } from '../src/ObservableCounterMetric'; import { ObservableUpDownCounterMetric } from '../src/ObservableUpDownCounterMetric'; -import { hashLabels } from '../src/Utils'; +import { hashAttributes } from '../src/Utils'; const nonNumberValues = [ // type undefined @@ -71,7 +71,7 @@ describe('Meter', () => { let meter: Meter; const keya = 'keya'; const keyb = 'keyb'; - const labels: api.Labels = { [keyb]: 'value2', [keya]: 'value1' }; + const attributes: api.Attributes = { [keyb]: 'value2', [keya]: 'value1' }; beforeEach(() => { meter = new MeterProvider().getMeter('test-meter'); @@ -100,7 +100,7 @@ describe('Meter', () => { it('should be able to call add() directly on counter', async () => { const counter = meter.createCounter('name') as CounterMetric; - counter.add(10, labels); + counter.add(10, attributes); await meter.collect(); const [record1] = meter.getProcessor().checkPointSet(); @@ -110,7 +110,7 @@ describe('Meter', () => { hrTimeToNanoseconds(lastTimestamp) > hrTimeToNanoseconds(performanceTimeOrigin) ); - counter.add(10, labels); + counter.add(10, attributes); assert.strictEqual(record1.aggregator.toPoint().value, 20); assert.ok( @@ -119,7 +119,7 @@ describe('Meter', () => { ); }); - it('should be able to call add with no labels', async () => { + it('should be able to call add with no attributes', async () => { const counter = meter.createCounter('name', { description: 'desc', unit: '1', @@ -156,7 +156,7 @@ describe('Meter', () => { describe('.bind()', () => { it('should create a counter instrument', async () => { const counter = meter.createCounter('name') as CounterMetric; - const boundCounter = counter.bind(labels); + const boundCounter = counter.bind(attributes); boundCounter.add(10); await meter.collect(); const [record1] = meter.getProcessor().checkPointSet(); @@ -168,15 +168,15 @@ describe('Meter', () => { it('should return the aggregator', () => { const counter = meter.createCounter('name') as CounterMetric; - const boundCounter = counter.bind(labels); + const boundCounter = counter.bind(attributes); boundCounter.add(20); assert.ok(boundCounter.getAggregator() instanceof SumAggregator); - assert.strictEqual(boundCounter.getLabels(), labels); + assert.strictEqual(boundCounter.getAttributes(), attributes); }); it('should add positive values only', async () => { const counter = meter.createCounter('name') as CounterMetric; - const boundCounter = counter.bind(labels); + const boundCounter = counter.bind(attributes); boundCounter.add(10); assert.strictEqual(meter.getProcessor().checkPointSet().length, 0); await meter.collect(); @@ -191,18 +191,18 @@ describe('Meter', () => { const counter = meter.createCounter('name', { disabled: true, }) as CounterMetric; - const boundCounter = counter.bind(labels); + const boundCounter = counter.bind(attributes); boundCounter.add(10); await meter.collect(); const [record1] = meter.getProcessor().checkPointSet(); assert.strictEqual(record1.aggregator.toPoint().value, 0); }); - it('should return same instrument on same label values', async () => { + it('should return same instrument on same attribute values', async () => { const counter = meter.createCounter('name') as CounterMetric; - const boundCounter = counter.bind(labels); + const boundCounter = counter.bind(attributes); boundCounter.add(10); - const boundCounter1 = counter.bind(labels); + const boundCounter1 = counter.bind(attributes); boundCounter1.add(10); await meter.collect(); const [record1] = meter.getProcessor().checkPointSet(); @@ -215,11 +215,11 @@ describe('Meter', () => { describe('.unbind()', () => { it('should remove a counter instrument', () => { const counter = meter.createCounter('name') as CounterMetric; - const boundCounter = counter.bind(labels); + const boundCounter = counter.bind(attributes); assert.strictEqual(counter['_instruments'].size, 1); - counter.unbind(labels); + counter.unbind(attributes); assert.strictEqual(counter['_instruments'].size, 0); - const boundCounter1 = counter.bind(labels); + const boundCounter1 = counter.bind(attributes); assert.strictEqual(counter['_instruments'].size, 1); assert.notStrictEqual(boundCounter, boundCounter1); }); @@ -231,7 +231,7 @@ describe('Meter', () => { it('should clear all instruments', () => { const counter = meter.createCounter('name') as CounterMetric; - counter.bind(labels); + counter.bind(attributes); assert.strictEqual(counter['_instruments'].size, 1); counter.clear(); assert.strictEqual(counter['_instruments'].size, 0); @@ -241,13 +241,13 @@ describe('Meter', () => { describe('.registerMetric()', () => { it('skip already registered Metric', async () => { const counter1 = meter.createCounter('name1') as CounterMetric; - counter1.bind(labels).add(10); + counter1.bind(attributes).add(10); // should skip below metric const counter2 = meter.createCounter('name1', { valueType: api.ValueType.INT, }) as CounterMetric; - counter2.bind(labels).add(500); + counter2.bind(attributes).add(500); await meter.collect(); const record = meter.getProcessor().checkPointSet(); @@ -319,7 +319,7 @@ describe('Meter', () => { it('should be able to call add() directly on UpDownCounter', async () => { const upDownCounter = meter.createUpDownCounter('name'); - upDownCounter.add(10, labels); + upDownCounter.add(10, attributes); await meter.collect(); const [record1] = meter.getProcessor().checkPointSet(); @@ -329,7 +329,7 @@ describe('Meter', () => { hrTimeToNanoseconds(lastTimestamp) > hrTimeToNanoseconds(performanceTimeOrigin) ); - upDownCounter.add(10, labels); + upDownCounter.add(10, attributes); assert.strictEqual(record1.aggregator.toPoint().value, 20); assert.ok( @@ -338,7 +338,7 @@ describe('Meter', () => { ); }); - it('should be able to call add with no labels', async () => { + it('should be able to call add with no attributes', async () => { const upDownCounter = meter.createUpDownCounter('name', { description: 'desc', unit: '1', @@ -365,7 +365,7 @@ describe('Meter', () => { describe('.bind()', () => { it('should create a UpDownCounter instrument', async () => { const upDownCounter = meter.createUpDownCounter('name') as UpDownCounterMetric; - const boundCounter = upDownCounter.bind(labels); + const boundCounter = upDownCounter.bind(attributes); boundCounter.add(10); await meter.collect(); const [record1] = meter.getProcessor().checkPointSet(); @@ -379,28 +379,28 @@ describe('Meter', () => { const upDownCounter = meter.createUpDownCounter( 'name' ) as UpDownCounterMetric; - const boundCounter = upDownCounter.bind(labels); + const boundCounter = upDownCounter.bind(attributes); boundCounter.add(20); assert.ok(boundCounter.getAggregator() instanceof SumAggregator); - assert.strictEqual(boundCounter.getLabels(), labels); + assert.strictEqual(boundCounter.getAttributes(), attributes); }); it('should not add the instrument data when disabled', async () => { const upDownCounter = meter.createUpDownCounter('name', { disabled: true, }) as UpDownCounterMetric; - const boundCounter = upDownCounter.bind(labels); + const boundCounter = upDownCounter.bind(attributes); boundCounter.add(10); await meter.collect(); const [record1] = meter.getProcessor().checkPointSet(); assert.strictEqual(record1.aggregator.toPoint().value, 0); }); - it('should return same instrument on same label values', async () => { + it('should return same instrument on same attribute values', async () => { const upDownCounter = meter.createUpDownCounter('name') as UpDownCounterMetric; - const boundCounter = upDownCounter.bind(labels); + const boundCounter = upDownCounter.bind(attributes); boundCounter.add(10); - const boundCounter1 = upDownCounter.bind(labels); + const boundCounter1 = upDownCounter.bind(attributes); boundCounter1.add(10); await meter.collect(); const [record1] = meter.getProcessor().checkPointSet(); @@ -413,7 +413,7 @@ describe('Meter', () => { const upDownCounter = meter.createUpDownCounter('name', { valueType: api.ValueType.INT, }) as UpDownCounterMetric; - const boundCounter = upDownCounter.bind(labels); + const boundCounter = upDownCounter.bind(attributes); [-1.1, 2.2].forEach(val => { boundCounter.add(val); @@ -427,7 +427,7 @@ describe('Meter', () => { const upDownCounter = meter.createUpDownCounter('name', { valueType: api.ValueType.DOUBLE, }) as UpDownCounterMetric; - const boundCounter = upDownCounter.bind(labels); + const boundCounter = upDownCounter.bind(attributes); await Promise.all( nonNumberValues.map(async val => { @@ -445,7 +445,7 @@ describe('Meter', () => { const upDownCounter = meter.createUpDownCounter('name', { valueType: api.ValueType.DOUBLE, }) as UpDownCounterMetric; - const boundCounter = upDownCounter.bind(labels); + const boundCounter = upDownCounter.bind(attributes); await Promise.all( nonNumberValues.map(async val => { @@ -465,11 +465,11 @@ describe('Meter', () => { const upDownCounter = meter.createUpDownCounter( 'name' ) as UpDownCounterMetric; - const boundCounter = upDownCounter.bind(labels); + const boundCounter = upDownCounter.bind(attributes); assert.strictEqual(upDownCounter['_instruments'].size, 1); - upDownCounter.unbind(labels); + upDownCounter.unbind(attributes); assert.strictEqual(upDownCounter['_instruments'].size, 0); - const boundCounter1 = upDownCounter.bind(labels); + const boundCounter1 = upDownCounter.bind(attributes); assert.strictEqual(upDownCounter['_instruments'].size, 1); assert.notStrictEqual(boundCounter, boundCounter1); }); @@ -483,7 +483,7 @@ describe('Meter', () => { const upDownCounter = meter.createUpDownCounter( 'name' ) as CounterMetric; - upDownCounter.bind(labels); + upDownCounter.bind(attributes); assert.strictEqual(upDownCounter['_instruments'].size, 1); upDownCounter.clear(); assert.strictEqual(upDownCounter['_instruments'].size, 0); @@ -493,13 +493,13 @@ describe('Meter', () => { describe('.registerMetric()', () => { it('skip already registered Metric', async () => { const counter1 = meter.createCounter('name1') as CounterMetric; - counter1.bind(labels).add(10); + counter1.bind(attributes).add(10); // should skip below metric const counter2 = meter.createCounter('name1', { valueType: api.ValueType.INT, }) as CounterMetric; - counter2.bind(labels).add(500); + counter2.bind(attributes).add(500); await meter.collect(); const record = meter.getProcessor().checkPointSet(); @@ -641,7 +641,7 @@ describe('Meter', () => { const histogram = meter.createHistogram( 'name' ) as HistogramMetric; - const boundHistogram = histogram.bind(labels); + const boundHistogram = histogram.bind(attributes); assert.doesNotThrow(() => boundHistogram.record(10)); }); @@ -649,7 +649,7 @@ describe('Meter', () => { const histogram = meter.createHistogram('name', { disabled: true, }) as HistogramMetric; - const boundHistogram = histogram.bind(labels); + const boundHistogram = histogram.bind(attributes); boundHistogram.record(10); await meter.collect(); @@ -669,7 +669,7 @@ describe('Meter', () => { it('should accept negative (and positive) values', async () => { const histogram = meter.createHistogram('name') as HistogramMetric; - const boundHistogram = histogram.bind(labels); + const boundHistogram = histogram.bind(attributes); boundHistogram.record(-10); boundHistogram.record(50); @@ -692,13 +692,13 @@ describe('Meter', () => { ); }); - it('should return same instrument on same label values', async () => { + it('should return same instrument on same attribute values', async () => { const histogram = meter.createHistogram( 'name' ) as HistogramMetric; - const boundHistogram1 = histogram.bind(labels); + const boundHistogram1 = histogram.bind(attributes); boundHistogram1.record(10); - const boundHistogram2 = histogram.bind(labels); + const boundHistogram2 = histogram.bind(attributes); boundHistogram2.record(100); await meter.collect(); const [record1] = meter.getProcessor().checkPointSet(); @@ -720,7 +720,7 @@ describe('Meter', () => { const histogram = meter.createHistogram( 'name' ) as HistogramMetric; - const boundHistogram = histogram.bind(labels); + const boundHistogram = histogram.bind(attributes); await Promise.all( nonNumberValues.map(async val => { @@ -749,11 +749,11 @@ describe('Meter', () => { const histogram = meter.createHistogram( 'name' ) as HistogramMetric; - const boundHistogram = histogram.bind(labels); + const boundHistogram = histogram.bind(attributes); assert.strictEqual(histogram['_instruments'].size, 1); - histogram.unbind(labels); + histogram.unbind(attributes); assert.strictEqual(histogram['_instruments'].size, 0); - const boundHistogram2 = histogram.bind(labels); + const boundHistogram2 = histogram.bind(attributes); assert.strictEqual(histogram['_instruments'].size, 1); assert.notStrictEqual(boundHistogram, boundHistogram2); }); @@ -767,7 +767,7 @@ describe('Meter', () => { const histogram = meter.createHistogram( 'name' ) as HistogramMetric; - histogram.bind(labels); + histogram.bind(attributes); assert.strictEqual(histogram['_instruments'].size, 1); histogram.clear(); assert.strictEqual(histogram['_instruments'].size, 0); @@ -834,7 +834,7 @@ describe('Meter', () => { let point = metricRecords[0].aggregator.toPoint(); assert.strictEqual(point.value, -1); assert.strictEqual( - hashLabels(metricRecords[0].labels), + hashAttributes(metricRecords[0].attributes), '|#core:1,pid:123' ); @@ -975,10 +975,10 @@ describe('Meter', () => { const metric2 = metricRecords[1]; const metric3 = metricRecords[2]; const metric4 = metricRecords[3]; - assert.strictEqual(hashLabels(metric1.labels), '|#core:1,pid:123'); - assert.strictEqual(hashLabels(metric2.labels), '|#core:2,pid:123'); - assert.strictEqual(hashLabels(metric3.labels), '|#core:3,pid:123'); - assert.strictEqual(hashLabels(metric4.labels), '|#core:4,pid:123'); + assert.strictEqual(hashAttributes(metric1.attributes), '|#core:1,pid:123'); + assert.strictEqual(hashAttributes(metric2.attributes), '|#core:2,pid:123'); + assert.strictEqual(hashAttributes(metric3.attributes), '|#core:3,pid:123'); + assert.strictEqual(hashAttributes(metric4.attributes), '|#core:4,pid:123'); ensureMetric(metric1); ensureMetric(metric2); @@ -1058,7 +1058,7 @@ describe('Meter', () => { let point = metricRecords[0].aggregator.toPoint(); assert.strictEqual(point.value, 3); assert.strictEqual( - hashLabels(metricRecords[0].labels), + hashAttributes(metricRecords[0].attributes), '|#core:1,pid:123' ); @@ -1149,8 +1149,8 @@ describe('Meter', () => { const counter = meter.createCounter('counter', { description: 'test', }) as CounterMetric; - const labels = { [key]: 'counter-value' }; - const boundCounter = counter.bind(labels); + const attributes = { [key]: 'counter-value' }; + const boundCounter = counter.bind(attributes); boundCounter.add(10.45); await meter.collect(); @@ -1164,7 +1164,7 @@ describe('Meter', () => { unit: '1', valueType: api.ValueType.DOUBLE, }); - assert.strictEqual(record[0].labels, labels); + assert.strictEqual(record[0].attributes, attributes); const value = record[0].aggregator.toPoint().value as Sum; assert.strictEqual(value, 10.45); }); @@ -1175,8 +1175,8 @@ describe('Meter', () => { description: 'test', valueType: api.ValueType.INT, }) as CounterMetric; - const labels = { [key]: 'counter-value' }; - const boundCounter = counter.bind(labels); + const attributes = { [key]: 'counter-value' }; + const boundCounter = counter.bind(attributes); boundCounter.add(10.45); await meter.collect(); @@ -1190,7 +1190,7 @@ describe('Meter', () => { unit: '1', valueType: api.ValueType.INT, }); - assert.strictEqual(record[0].labels, labels); + assert.strictEqual(record[0].attributes, attributes); const value = record[0].aggregator.toPoint().value as Sum; assert.strictEqual(value, 10); }); diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/test/Processor.test.ts b/experimental/packages/opentelemetry-sdk-metrics-base/test/Processor.test.ts index cb1a459b03..72af5f7bb6 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/test/Processor.test.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/test/Processor.test.ts @@ -40,7 +40,7 @@ describe('Processor', () => { const checkPointSet = meter.getProcessor().checkPointSet(); assert.strictEqual(checkPointSet.length, 2); for (const record of checkPointSet) { - switch (record.labels.key) { + switch (record.attributes.key) { case 'foo': assert.strictEqual(record.aggregator.toPoint().value, 1); break; @@ -48,7 +48,7 @@ describe('Processor', () => { assert.strictEqual(record.aggregator.toPoint().value, 3); break; default: - throw new Error('Unknown labelset'); + throw new Error('Unknown attributeset'); } } }); diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/test/export/ConsoleMetricExporter.test.ts b/experimental/packages/opentelemetry-sdk-metrics-base/test/export/ConsoleMetricExporter.test.ts index 4935c498d8..10168b0174 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/test/export/ConsoleMetricExporter.test.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/test/export/ConsoleMetricExporter.test.ts @@ -45,15 +45,15 @@ describe('ConsoleMetricExporter', () => { description: 'a test description', }) as CounterMetric; const boundCounter = counter.bind({ - key1: 'labelValue1', - key2: 'labelValue2', + key1: 'attributeValue1', + key2: 'attributeValue2', }); boundCounter.add(10); await meter.collect(); consoleExporter.export(meter.getProcessor().checkPointSet(), () => {}); assert.strictEqual(spyConsole.args.length, 3); - const [descriptor, labels, value] = spyConsole.args; + const [descriptor, attributes, value] = spyConsole.args; assert.deepStrictEqual(descriptor, [ { description: 'a test description', @@ -63,10 +63,10 @@ describe('ConsoleMetricExporter', () => { valueType: ValueType.DOUBLE, }, ]); - assert.deepStrictEqual(labels, [ + assert.deepStrictEqual(attributes, [ { - key1: 'labelValue1', - key2: 'labelValue2', + key1: 'attributeValue1', + key2: 'attributeValue2', }, ]); assert.deepStrictEqual(value[0], 'value: 10');