Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/

### :bug: (Bug Fix)

* fix(opentelemetry-exporter-prometheus): Update default PrometheusExporter to not append a timestamp to match the text based exposition format [#3961](https://github.com/open-telemetry/opentelemetry-js/pull/3961) @JacksonWeber
* fix(sdk-metrics): Update default Histogram's boundary to match OTEL's spec [#3893](https://github.com/open-telemetry/opentelemetry-js/pull/3893/) @chigia001
* fix(sdk-metrics): preserve startTime for cumulative ExponentialHistograms [#3934](https://github.com/open-telemetry/opentelemetry-js/pull/3934/) @aabmass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class PrometheusExporter extends MetricReader {
port: 9464,
endpoint: '/metrics',
prefix: '',
appendTimestamp: true,
appendTimestamp: false,
};

private readonly _host?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class PrometheusSerializer {
private _prefix: string | undefined;
private _appendTimestamp: boolean;

constructor(prefix?: string, appendTimestamp = true) {
constructor(prefix?: string, appendTimestamp = false) {
if (prefix) {
this._prefix = prefix + '_';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import * as sinon from 'sinon';
import * as http from 'http';
import { PrometheusExporter } from '../src';
import {
mockedHrTimeMs,
mockHrTime,
sdkLanguage,
sdkName,
sdkVersion,
serviceName,
mockedHrTimeMs,
} from './util';
import { SinonStubbedInstance } from 'sinon';

Expand Down Expand Up @@ -290,7 +290,7 @@ describe('PrometheusExporter', () => {
...serializedDefaultResourceLines,
'# HELP counter_total a test description',
'# TYPE counter_total counter',
`counter_total{key1="attributeValue1"} 10 ${mockedHrTimeMs}`,
'counter_total{key1="attributeValue1"} 10',
'',
]);
});
Expand Down Expand Up @@ -320,7 +320,7 @@ describe('PrometheusExporter', () => {
...serializedDefaultResourceLines,
'# HELP metric_observable_gauge a test description',
'# TYPE metric_observable_gauge gauge',
`metric_observable_gauge{pid="123",core="1"} 0.999 ${mockedHrTimeMs}`,
'metric_observable_gauge{pid="123",core="1"} 0.999',
'',
]);
});
Expand All @@ -340,8 +340,8 @@ describe('PrometheusExporter', () => {
...serializedDefaultResourceLines,
'# HELP counter_total a test description',
'# TYPE counter_total counter',
`counter_total{counterKey1="attributeValue1"} 10 ${mockedHrTimeMs}`,
`counter_total{counterKey1="attributeValue2"} 20 ${mockedHrTimeMs}`,
'counter_total{counterKey1="attributeValue1"} 10',
'counter_total{counterKey1="attributeValue2"} 20',
'',
]);
});
Expand Down Expand Up @@ -389,7 +389,7 @@ describe('PrometheusExporter', () => {
...serializedDefaultResourceLines,
'# HELP counter_total description missing',
'# TYPE counter_total counter',
`counter_total{key1="attributeValue1"} 10 ${mockedHrTimeMs}`,
'counter_total{key1="attributeValue1"} 10',
'',
]);
});
Expand All @@ -406,7 +406,7 @@ describe('PrometheusExporter', () => {
...serializedDefaultResourceLines,
'# HELP counter_bad_name_total description missing',
'# TYPE counter_bad_name_total counter',
`counter_bad_name_total{key1="attributeValue1"} 10 ${mockedHrTimeMs}`,
'counter_bad_name_total{key1="attributeValue1"} 10',
'',
]);
});
Expand All @@ -424,7 +424,7 @@ describe('PrometheusExporter', () => {
...serializedDefaultResourceLines,
'# HELP counter a test description',
'# TYPE counter gauge',
`counter{key1="attributeValue1"} 20 ${mockedHrTimeMs}`,
'counter{key1="attributeValue1"} 20',
'',
]);
});
Expand Down Expand Up @@ -453,7 +453,7 @@ describe('PrometheusExporter', () => {
...serializedDefaultResourceLines,
'# HELP metric_observable_counter a test description',
'# TYPE metric_observable_counter counter',
`metric_observable_counter{key1="attributeValue1"} 20 ${mockedHrTimeMs}`,
'metric_observable_counter{key1="attributeValue1"} 20',
'',
]);
});
Expand Down Expand Up @@ -484,7 +484,7 @@ describe('PrometheusExporter', () => {
...serializedDefaultResourceLines,
'# HELP metric_observable_up_down_counter a test description',
'# TYPE metric_observable_up_down_counter gauge',
`metric_observable_up_down_counter{key1="attributeValue1"} 20 ${mockedHrTimeMs}`,
'metric_observable_up_down_counter{key1="attributeValue1"} 20',
'',
]);
});
Expand All @@ -503,24 +503,24 @@ describe('PrometheusExporter', () => {
...serializedDefaultResourceLines,
'# HELP test_histogram a test description',
'# TYPE test_histogram histogram',
`test_histogram_count{key1="attributeValue1"} 1 ${mockedHrTimeMs}`,
`test_histogram_sum{key1="attributeValue1"} 20 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="0"} 0 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="5"} 0 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="10"} 0 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="25"} 1 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="50"} 1 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="75"} 1 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="100"} 1 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="250"} 1 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="500"} 1 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="750"} 1 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="1000"} 1 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="2500"} 1 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="5000"} 1 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="7500"} 1 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="10000"} 1 ${mockedHrTimeMs}`,
`test_histogram_bucket{key1="attributeValue1",le="+Inf"} 1 ${mockedHrTimeMs}`,
'test_histogram_count{key1="attributeValue1"} 1',
'test_histogram_sum{key1="attributeValue1"} 20',
'test_histogram_bucket{key1="attributeValue1",le="0"} 0',
'test_histogram_bucket{key1="attributeValue1",le="5"} 0',
'test_histogram_bucket{key1="attributeValue1",le="10"} 0',
'test_histogram_bucket{key1="attributeValue1",le="25"} 1',
'test_histogram_bucket{key1="attributeValue1",le="50"} 1',
'test_histogram_bucket{key1="attributeValue1",le="75"} 1',
'test_histogram_bucket{key1="attributeValue1",le="100"} 1',
'test_histogram_bucket{key1="attributeValue1",le="250"} 1',
'test_histogram_bucket{key1="attributeValue1",le="500"} 1',
'test_histogram_bucket{key1="attributeValue1",le="750"} 1',
'test_histogram_bucket{key1="attributeValue1",le="1000"} 1',
'test_histogram_bucket{key1="attributeValue1",le="2500"} 1',
'test_histogram_bucket{key1="attributeValue1",le="5000"} 1',
'test_histogram_bucket{key1="attributeValue1",le="7500"} 1',
'test_histogram_bucket{key1="attributeValue1",le="10000"} 1',
'test_histogram_bucket{key1="attributeValue1",le="+Inf"} 1',
'',
]);
});
Expand Down Expand Up @@ -562,7 +562,7 @@ describe('PrometheusExporter', () => {
...serializedDefaultResourceLines,
'# HELP test_prefix_counter_total description missing',
'# TYPE test_prefix_counter_total counter',
`test_prefix_counter_total{key1="attributeValue1"} 10 ${mockedHrTimeMs}`,
'test_prefix_counter_total{key1="attributeValue1"} 10',
'',
]);

Expand Down Expand Up @@ -591,7 +591,7 @@ describe('PrometheusExporter', () => {
...serializedDefaultResourceLines,
'# HELP counter_total description missing',
'# TYPE counter_total counter',
`counter_total{key1="attributeValue1"} 10 ${mockedHrTimeMs}`,
'counter_total{key1="attributeValue1"} 10',
'',
]);

Expand Down Expand Up @@ -620,7 +620,7 @@ describe('PrometheusExporter', () => {
...serializedDefaultResourceLines,
'# HELP counter_total description missing',
'# TYPE counter_total counter',
`counter_total{key1="attributeValue1"} 10 ${mockedHrTimeMs}`,
'counter_total{key1="attributeValue1"} 10',
'',
]);

Expand All @@ -632,10 +632,10 @@ describe('PrometheusExporter', () => {
);
});

it('should export a metric without timestamp', done => {
it('should export a metric with timestamp', done => {
exporter = new PrometheusExporter(
{
appendTimestamp: false,
appendTimestamp: true,
},
async () => {
setup(exporter);
Expand All @@ -649,7 +649,7 @@ describe('PrometheusExporter', () => {
...serializedDefaultResourceLines,
'# HELP counter_total description missing',
'# TYPE counter_total counter',
'counter_total{key1="attributeValue1"} 10',
`counter_total{key1="attributeValue1"} 10 ${mockedHrTimeMs}`,
'',
]);

Expand Down
Loading