Skip to content

Commit 32e25c3

Browse files
authored
refactor(exporter-prometheus): replace MetricAttributes to Attributes (#4993)
1 parent 92b0c36 commit 32e25c3

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

experimental/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ All notable changes to experimental packages in this project will be documented
2121

2222
### :house: (Internal)
2323

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

2628
### :boom: Breaking Change

experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusSerializer.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {
18-
diag,
19-
MetricAttributes,
20-
MetricAttributeValue,
21-
} from '@opentelemetry/api';
17+
import { diag, Attributes, AttributeValue } from '@opentelemetry/api';
2218
import {
2319
ResourceMetrics,
2420
InstrumentType,
@@ -48,7 +44,7 @@ function escapeString(str: string) {
4844
*
4945
* `undefined` is converted to an empty string.
5046
*/
51-
function escapeAttributeValue(str: MetricAttributeValue = '') {
47+
function escapeAttributeValue(str: AttributeValue = '') {
5248
if (typeof str !== 'string') {
5349
str = JSON.stringify(str);
5450
}
@@ -136,10 +132,10 @@ function toPrometheusType(metricData: MetricData): PrometheusDataTypeLiteral {
136132

137133
function stringify(
138134
metricName: string,
139-
attributes: MetricAttributes,
135+
attributes: Attributes,
140136
value: number,
141137
timestamp?: number,
142-
additionalAttributes?: MetricAttributes
138+
additionalAttributes?: Attributes
143139
) {
144140
let hasAttribute = false;
145141
let attributesStr = '';

experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import * as assert from 'assert';
18-
import { MetricAttributes, UpDownCounter } from '@opentelemetry/api';
18+
import { Attributes, UpDownCounter } from '@opentelemetry/api';
1919
import {
2020
Aggregation,
2121
AggregationTemporality,
@@ -610,7 +610,7 @@ describe('PrometheusSerializer', () => {
610610
NaN: NaN,
611611
null: null,
612612
undefined: undefined,
613-
} as unknown as MetricAttributes);
613+
} as unknown as Attributes);
614614
});
615615

616616
assert.strictEqual(
@@ -649,7 +649,7 @@ describe('PrometheusSerializer', () => {
649649
backslashN: '\u005c\u006e', // \n => \\n (\u005c\u005c\u006e)
650650
backslashDoubleQuote: '\u005c\u0022', // \" => \\\" (\u005c\u005c\u005c\u0022)
651651
backslashLineFeed: '\u005c\u000a', // \↵ => \\\n (\u005c\u005c\u005c\u006e)
652-
} as unknown as MetricAttributes);
652+
} as unknown as Attributes);
653653
});
654654

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

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

0 commit comments

Comments
 (0)