Skip to content

Commit

Permalink
Merge branch 'main' into attrs-in-record-exception
Browse files Browse the repository at this point in the history
  • Loading branch information
brianphillips authored Jan 17, 2025
2 parents f72fbb3 + fc0edd8 commit d42664a
Show file tree
Hide file tree
Showing 55 changed files with 846 additions and 6,544 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se
* chore!: update typescript to version `5.0.4` [#5145](https://github.com/open-telemetry/opentelemetry-js/pull/5145) @david-luna
* (user-facing) dropped support for `typescript@<5.0.4`
* (user-facing) all packages published from this repository will from now on drop support for old versions of `typescript` in minor releases. We will only drop support for versions that are older than 2 years.
* feat(core)!: remove deprecated samplers [#5316](https://github.com/open-telemetry/opentelemetry-js/pull/5316) @pichlermarc
* (user-facing): deprecated `AlwaysOnSampler` has moved to `@opentelemetry/sdk-trace-base`
* (user-facing): deprecated `AlwaysOffSampler` has moved to `@opentelemetry/sdk-trace-base`
* (user-facing): deprecated `TraceIdRatioSampler` has moved to `@opentelemetry/sdk-trace-base`
* (user-facing): deprecated `TraceIdRatioSampler` has moved to `@opentelemetry/sdk-trace-base`

### :rocket: (Enhancement)

### :bug: (Bug Fix)

* fix(sdk-metrics): do not export from `PeriodicExportingMetricReader` when there are no metrics to export. [#5288](https://github.com/open-telemetry/opentelemetry-js/pull/5288) @jacksonweber

### :books: (Refine Doc)

### :house: (Internal)
Expand Down
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"mocha": "10.8.2",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4",
"unionfs": "4.5.4",
"webpack": "5.96.1"
Expand Down
2 changes: 2 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ All notable changes to experimental packages in this project will be documented

### :bug: (Bug Fix)

* fix(exporter-metrics-otlp-http): browser OTLPMetricExporter was not passing config to OTLPMetricExporterBase super class [#5331](https://github.com/open-telemetry/opentelemetry-js/pull/5331) @trentm

### :books: (Refine Doc)

### :house: (Internal)
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/api-events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"lerna": "6.6.2",
"mocha": "10.8.2",
"nyc": "17.1.0",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4",
"webpack": "5.96.1"
},
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/api-logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"lerna": "6.6.2",
"mocha": "10.8.2",
"nyc": "17.1.0",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4",
"webpack": "5.96.1"
},
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/exporter-logs-otlp-grpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"mocha": "10.8.2",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/exporter-logs-otlp-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"mocha": "10.8.2",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4",
"webpack": "5.96.1",
"webpack-cli": "6.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"mocha": "10.8.2",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4",
"webpack": "5.96.1",
"webpack-cli": "6.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"mocha": "10.8.2",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"mocha": "10.8.2",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4",
"webpack": "5.96.1",
"webpack-cli": "6.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"mocha": "10.8.2",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4",
"webpack": "5.96.1",
"webpack-cli": "6.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"mocha": "10.8.2",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4",
"webpack": "5.96.1",
"webpack-cli": "6.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"mocha": "10.8.2",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"mocha": "10.8.2",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4",
"webpack": "5.96.1",
"webpack-cli": "6.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export class OTLPMetricExporter extends OTLPMetricExporterBase {
JsonMetricsSerializer,
'v1/metrics',
{ 'Content-Type': 'application/json' }
)
),
config
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* limitations under the License.
*/

import { AggregationTemporalityPreference } from '../../src';
import {
AggregationOption,
AggregationTemporality,
AggregationType,
InstrumentType,
MeterProvider,
PeriodicExportingMetricReader,
} from '@opentelemetry/sdk-metrics';
Expand Down Expand Up @@ -105,4 +110,146 @@ describe('OTLPMetricExporter', function () {
});
});
});

describe('temporality', () => {
it('should use the right temporality when Cumulative preference is selected', () => {
const exporter = new OTLPMetricExporter({
temporalityPreference: AggregationTemporalityPreference.CUMULATIVE,
});

assert.equal(
exporter.selectAggregationTemporality(InstrumentType.COUNTER),
AggregationTemporality.CUMULATIVE,
'Counter'
);
assert.equal(
exporter.selectAggregationTemporality(InstrumentType.HISTOGRAM),
AggregationTemporality.CUMULATIVE,
'Histogram'
);
assert.equal(
exporter.selectAggregationTemporality(InstrumentType.UP_DOWN_COUNTER),
AggregationTemporality.CUMULATIVE,
'UpDownCounter'
);
assert.equal(
exporter.selectAggregationTemporality(
InstrumentType.OBSERVABLE_COUNTER
),
AggregationTemporality.CUMULATIVE,
'Asynchronous Counter'
);
assert.equal(
exporter.selectAggregationTemporality(
InstrumentType.OBSERVABLE_UP_DOWN_COUNTER
),
AggregationTemporality.CUMULATIVE,
'Asynchronous UpDownCounter'
);
});

it('should use the right temporality when Delta preference is selected', () => {
const exporter = new OTLPMetricExporter({
temporalityPreference: AggregationTemporalityPreference.DELTA,
});

assert.equal(
exporter.selectAggregationTemporality(InstrumentType.COUNTER),
AggregationTemporality.DELTA,
'Counter'
);
assert.equal(
exporter.selectAggregationTemporality(InstrumentType.HISTOGRAM),
AggregationTemporality.DELTA,
'Histogram'
);
assert.equal(
exporter.selectAggregationTemporality(InstrumentType.UP_DOWN_COUNTER),
AggregationTemporality.CUMULATIVE,
'UpDownCounter'
);
assert.equal(
exporter.selectAggregationTemporality(
InstrumentType.OBSERVABLE_COUNTER
),
AggregationTemporality.DELTA,
'Asynchronous Counter'
);
assert.equal(
exporter.selectAggregationTemporality(
InstrumentType.OBSERVABLE_UP_DOWN_COUNTER
),
AggregationTemporality.CUMULATIVE,
'Asynchronous UpDownCounter'
);
});

it('should use the right temporality when LowMemory preference is selected', () => {
const exporter = new OTLPMetricExporter({
temporalityPreference: AggregationTemporalityPreference.LOWMEMORY,
});

assert.equal(
exporter.selectAggregationTemporality(InstrumentType.COUNTER),
AggregationTemporality.DELTA,
'Counter'
);
assert.equal(
exporter.selectAggregationTemporality(InstrumentType.HISTOGRAM),
AggregationTemporality.DELTA,
'Histogram'
);
assert.equal(
exporter.selectAggregationTemporality(InstrumentType.UP_DOWN_COUNTER),
AggregationTemporality.CUMULATIVE,
'UpDownCounter'
);
assert.equal(
exporter.selectAggregationTemporality(
InstrumentType.OBSERVABLE_COUNTER
),
AggregationTemporality.CUMULATIVE,
'Asynchronous Counter'
);
assert.equal(
exporter.selectAggregationTemporality(
InstrumentType.OBSERVABLE_UP_DOWN_COUNTER
),
AggregationTemporality.CUMULATIVE,
'Asynchronous UpDownCounter'
);
});
});

describe('aggregation', () => {
it('aggregationSelector calls the selector supplied to the constructor', () => {
const aggregation: AggregationOption = {
type: AggregationType.EXPLICIT_BUCKET_HISTOGRAM,
options: {
boundaries: [0, 100, 100000],
},
};
const exporter = new OTLPMetricExporter({
aggregationPreference: _instrumentType => aggregation,
});
assert.equal(
exporter.selectAggregation(InstrumentType.COUNTER),
aggregation
);
});

it('aggregationSelector returns the default aggregation preference when nothing is supplied', () => {
const exporter = new OTLPMetricExporter({
aggregationPreference: _instrumentType => ({
type: AggregationType.DEFAULT,
}),
});
assert.deepStrictEqual(
exporter.selectAggregation(InstrumentType.COUNTER),
{
type: AggregationType.DEFAULT,
}
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"mocha": "10.8.2",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"mocha": "10.8.2",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"typescript": "5.0.4",
"webpack": "5.96.1",
"webpack-cli": "6.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@
"mocha": "10.8.2",
"nock": "13.5.6",
"nyc": "17.1.0",
"request": "2.88.2",
"request-promise-native": "1.0.9",
"sinon": "15.1.2",
"superagent": "10.1.1",
"typescript": "5.0.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ instrumentation.enable();
instrumentation.disable();

import * as http from 'http';
import * as request from 'request-promise-native';
import * as superagent from 'superagent';
// Temporarily removed. See https://github.com/open-telemetry/opentelemetry-js/issues/3344
// import * as got from 'got';
import * as nock from 'nock';
import * as axios from 'axios';

Expand Down Expand Up @@ -82,11 +79,6 @@ describe('Packages', () => {
[
{ name: 'axios', httpPackage: axios }, //keep first
{ name: 'superagent', httpPackage: superagent },
// { name: 'got', httpPackage: { get: (url: string) => got(url) } },
{
name: 'request',
httpPackage: { get: (url: string) => request(url) },
},
].forEach(({ name, httpPackage }) => {
it(`should create a span for GET requests and add propagation headers by using ${name} package`, async () => {
nock.load(path.join(__dirname, '../', '/fixtures/google-http.json'));
Expand Down Expand Up @@ -123,7 +115,6 @@ describe('Packages', () => {
result.request._headers[DummyPropagation.SPAN_CONTEXT_KEY]
);
break;
case 'got':
case 'superagent':
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ instrumentation.enable();
instrumentation.disable();

import * as http from 'http';
import * as request from 'request-promise-native';
import * as superagent from 'superagent';
// Temporarily removed. See https://github.com/open-telemetry/opentelemetry-js/issues/3344
// import * as got from 'got';
import * as nock from 'nock';
import * as axios from 'axios';

Expand Down Expand Up @@ -82,11 +79,6 @@ describe('Packages', () => {
[
{ name: 'axios', httpPackage: axios }, //keep first
{ name: 'superagent', httpPackage: superagent },
// { name: 'got', httpPackage: { get: (url: string) => got(url) } },
{
name: 'request',
httpPackage: { get: (url: string) => request(url) },
},
].forEach(({ name, httpPackage }) => {
it(`should create a span for GET requests and add propagation headers by using ${name} package`, async () => {
nock.load(path.join(__dirname, '../', '/fixtures/google-https.json'));
Expand Down Expand Up @@ -123,7 +115,6 @@ describe('Packages', () => {
result.request._headers[DummyPropagation.SPAN_CONTEXT_KEY]
);
break;
case 'got':
case 'superagent':
break;
default:
Expand Down
Loading

0 comments on commit d42664a

Please sign in to comment.