Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(exporter-prometheus): replace MetricAttributes to Attributes #4993

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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