Skip to content

Commit

Permalink
refactor(exporter-prometheus): replace MetricAttributes to Attributes (
Browse files Browse the repository at this point in the history
  • Loading branch information
david-luna authored Sep 17, 2024
1 parent 92b0c36 commit 32e25c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 2 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ All notable changes to experimental packages in this project will be documented

### :house: (Internal)

* refactor(exporter-prometheus): replace `MetricAttributes` and `MetricAttributeValues` with `Attributes` and `AttributeValues` [#4993](https://github.com/open-telemetry/opentelemetry-js/pull/4993)

## 0.53.0

### :boom: Breaking Change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
* limitations under the License.
*/

import {
diag,
MetricAttributes,
MetricAttributeValue,
} from '@opentelemetry/api';
import { diag, Attributes, AttributeValue } from '@opentelemetry/api';
import {
ResourceMetrics,
InstrumentType,
Expand Down Expand Up @@ -48,7 +44,7 @@ function escapeString(str: string) {
*
* `undefined` is converted to an empty string.
*/
function escapeAttributeValue(str: MetricAttributeValue = '') {
function escapeAttributeValue(str: AttributeValue = '') {
if (typeof str !== 'string') {
str = JSON.stringify(str);
}
Expand Down Expand Up @@ -136,10 +132,10 @@ function toPrometheusType(metricData: MetricData): PrometheusDataTypeLiteral {

function stringify(
metricName: string,
attributes: MetricAttributes,
attributes: Attributes,
value: number,
timestamp?: number,
additionalAttributes?: MetricAttributes
additionalAttributes?: Attributes
) {
let hasAttribute = false;
let attributesStr = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import * as assert from 'assert';
import { MetricAttributes, UpDownCounter } from '@opentelemetry/api';
import { Attributes, UpDownCounter } from '@opentelemetry/api';
import {
Aggregation,
AggregationTemporality,
Expand Down Expand Up @@ -610,7 +610,7 @@ describe('PrometheusSerializer', () => {
NaN: NaN,
null: null,
undefined: undefined,
} as unknown as MetricAttributes);
} as unknown as Attributes);
});

assert.strictEqual(
Expand Down Expand Up @@ -649,7 +649,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 MetricAttributes);
} as unknown as Attributes);
});

assert.strictEqual(
Expand All @@ -674,7 +674,7 @@ describe('PrometheusSerializer', () => {
// error while linting: text format parsing error in line 282: expected '=' after label name, found '-'
counter.add(1, {
'account-id': '123456',
} as unknown as MetricAttributes);
} as unknown as Attributes);
});

assert.strictEqual(result, 'test_total{account_id="123456"} 1\n');
Expand Down

0 comments on commit 32e25c3

Please sign in to comment.