Skip to content

Commit

Permalink
Merge branch 'main' into chore/cleanup-otlp-grpc-exporter-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored Nov 25, 2024
2 parents 6d81353 + 3a20ed6 commit 28eae97
Show file tree
Hide file tree
Showing 61 changed files with 1,619 additions and 517 deletions.
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"access": "public"
},
"devDependencies": {
"@types/mocha": "10.0.9",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/sinon": "17.0.3",
"@types/webpack": "5.28.5",
Expand Down
2 changes: 1 addition & 1 deletion examples/esm-http-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
"@opentelemetry/resources": "1.28.0",
"@opentelemetry/sdk-trace-base": "1.28.0",
"@opentelemetry/sdk-trace-node": "1.28.0",
"@opentelemetry/semantic-conventions": "1.27.0"
"@opentelemetry/semantic-conventions": "1.28.0"
}
}
2 changes: 1 addition & 1 deletion examples/http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@opentelemetry/resources": "1.28.0",
"@opentelemetry/sdk-trace-base": "1.28.0",
"@opentelemetry/sdk-trace-node": "1.28.0",
"@opentelemetry/semantic-conventions": "1.27.0"
"@opentelemetry/semantic-conventions": "1.28.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/http",
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/https/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@opentelemetry/resources": "1.28.0",
"@opentelemetry/sdk-trace-base": "1.28.0",
"@opentelemetry/sdk-trace-node": "1.28.0",
"@opentelemetry/semantic-conventions": "1.27.0"
"@opentelemetry/semantic-conventions": "1.28.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/https",
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/opentelemetry-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@opentelemetry/sdk-metrics": "1.28.0",
"@opentelemetry/sdk-trace-base": "1.28.0",
"@opentelemetry/sdk-trace-web": "1.28.0",
"@opentelemetry/semantic-conventions": "1.27.0"
"@opentelemetry/semantic-conventions": "1.28.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/tracer-web"
}
2 changes: 1 addition & 1 deletion examples/otlp-exporter-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@opentelemetry/resources": "1.28.0",
"@opentelemetry/sdk-metrics": "1.28.0",
"@opentelemetry/sdk-trace-base": "1.28.0",
"@opentelemetry/semantic-conventions": "1.27.0"
"@opentelemetry/semantic-conventions": "1.28.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/otlp-exporter-node"
}
6 changes: 4 additions & 2 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ All notable changes to experimental packages in this project will be documented
* This type is scheduled for removal in a future version of this package, please treat all exporters as `SpanExporter`, `PushMetricExporter` or `LogRecordExporter`, based on their respective type.
* feat(otlp-grpc-exporter-base)!: collapse base classes into one [#5031](https://github.com/open-telemetry/opentelemetry-js/pull/5031) @pichlermarc
* `OTLPGRPCExporterNodeBase` has been removed in favor of a platform-agnostic implementation (`OTLPExporterBase` from `@opentelemetry/otlp-exporter-base`)
* feat(otlp-exporter-base): internally accept a http header provider function only [#5179](https://github.com/open-telemetry/opentelemetry-js/pull/5179) @pichlermarc
* feat(otlp-transformer)!: accept `ResourceMetrics` in serializers instead of `ResourceMetrics[]`
* (user-facing): `ProtobufMetricsSerializer` now only accepts `ResourceMetrics` instead of `ResourceMetrics[]` to align with `PushMetricExporter` requirements
* (user-facing): `JsonMetricsSerializer` now only accepts `ResourceMetrics` instead of `ResourceMetrics[]` to align with `PushMetricExporter` requirements


### :rocket: (Enhancement)

* feat(otlp-exporter-base): internally accept a http header provider function only [#5179](https://github.com/open-telemetry/opentelemetry-js/pull/5179) @pichlermarc
* refactor(otlp-exporter-base): don't create blob before sending xhr [#5193](https://github.com/open-telemetry/opentelemetry-js/pull/5193) @pichlermarc
* improves compatibility with some unsupported runtimes

### :bug: (Bug Fix)

### :books: (Refine Doc)
Expand Down
2 changes: 1 addition & 1 deletion experimental/examples/opencensus-shim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@opentelemetry/resources": "1.28.0",
"@opentelemetry/sdk-metrics": "1.28.0",
"@opentelemetry/sdk-trace-node": "1.28.0",
"@opentelemetry/semantic-conventions": "1.27.0",
"@opentelemetry/semantic-conventions": "1.28.0",
"@opentelemetry/shim-opencensus": "0.55.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/examples/opencensus-shim"
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 @@ -64,7 +64,7 @@
"@opentelemetry/api-logs": "0.55.0"
},
"devDependencies": {
"@types/mocha": "10.0.9",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/webpack-env": "1.16.3",
"babel-plugin-istanbul": "7.0.0",
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 @@ -63,7 +63,7 @@
"@opentelemetry/api": "^1.3.0"
},
"devDependencies": {
"@types/mocha": "10.0.9",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/webpack-env": "1.16.3",
"babel-plugin-istanbul": "7.0.0",
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 @@ -53,7 +53,7 @@
"@opentelemetry/api-logs": "0.55.0",
"@opentelemetry/otlp-exporter-base": "0.55.0",
"@opentelemetry/resources": "1.28.0",
"@types/mocha": "10.0.9",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/sinon": "17.0.3",
"cross-var": "1.1.0",
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 @@ -74,7 +74,7 @@
"@babel/preset-env": "7.26.0",
"@opentelemetry/api": "1.9.0",
"@opentelemetry/resources": "1.28.0",
"@types/mocha": "10.0.9",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/sinon": "17.0.3",
"@types/webpack-env": "1.16.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@babel/core": "7.26.0",
"@babel/preset-env": "7.26.0",
"@opentelemetry/api": "1.9.0",
"@types/mocha": "10.0.9",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/sinon": "17.0.3",
"babel-plugin-istanbul": "7.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@grpc/proto-loader": "^0.7.10",
"@opentelemetry/api": "1.9.0",
"@opentelemetry/otlp-exporter-base": "0.55.0",
"@types/mocha": "10.0.9",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/sinon": "17.0.3",
"cross-var": "1.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@babel/core": "7.26.0",
"@babel/preset-env": "7.26.0",
"@opentelemetry/api": "1.9.0",
"@types/mocha": "10.0.9",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/sinon": "17.0.3",
"@types/webpack-env": "1.16.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,9 @@ describe('OTLPTraceExporter - web', () => {
assert.strictEqual(request.method, 'POST');
assert.strictEqual(request.url, 'http://foo.bar.com');

const body = request.requestBody as Blob;
const decoder = new TextDecoder();
const body = request.requestBody as Uint8Array;
const json = JSON.parse(
decoder.decode(await body.arrayBuffer())
new TextDecoder().decode(body)
) as IExportTraceServiceRequest;
const span1 = json.resourceSpans?.[0].scopeSpans?.[0].spans?.[0];

Expand Down Expand Up @@ -340,14 +339,18 @@ describe('OTLPTraceExporter - web', () => {
collectorTraceExporter.export(spans, () => {});

queueMicrotask(() => {
const [{ requestHeaders }] = server.requests;

ensureHeadersContain(requestHeaders, customHeaders);
assert.strictEqual(stubBeacon.callCount, 0);
assert.strictEqual(stubOpen.callCount, 0);
try {
const [{ requestHeaders: requestHeaders }] = server.requests;

clock.restore();
done();
ensureHeadersContain(requestHeaders, customHeaders);
assert.strictEqual(stubBeacon.callCount, 0);
assert.strictEqual(stubOpen.callCount, 0);
done();
} catch (e) {
done(e);
} finally {
clock.restore();
}
});
});
it('should log the timeout request error message', done => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@babel/core": "7.26.0",
"@babel/preset-env": "7.26.0",
"@opentelemetry/api": "1.9.0",
"@types/mocha": "10.0.9",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/sinon": "17.0.3",
"babel-plugin-istanbul": "7.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@babel/core": "7.26.0",
"@babel/preset-env": "7.26.0",
"@opentelemetry/api": "1.9.0",
"@types/mocha": "10.0.9",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/sinon": "17.0.3",
"babel-plugin-istanbul": "7.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@grpc/proto-loader": "^0.7.10",
"@opentelemetry/api": "1.9.0",
"@types/mocha": "10.0.9",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/sinon": "17.0.3",
"cross-var": "1.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@babel/core": "7.26.0",
"@babel/preset-env": "7.26.0",
"@opentelemetry/api": "1.9.0",
"@types/mocha": "10.0.9",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/sinon": "17.0.3",
"@types/webpack-env": "1.16.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,77 +240,84 @@ describe('OTLPMetricExporter - web', () => {
collectorExporter.export(metrics, () => {});

queueMicrotask(async () => {
const request = server.requests[0];
assert.strictEqual(request.method, 'POST');
assert.strictEqual(request.url, 'http://foo.bar.com');

const body = request.requestBody;
const decoder = new TextDecoder();
const json = JSON.parse(
decoder.decode(await body.arrayBuffer())
) as IExportMetricsServiceRequest;
// The order of the metrics is not guaranteed.
const counterIndex = metrics.scopeMetrics[0].metrics.findIndex(
it => it.descriptor.name === 'int-counter'
);
const observableIndex = metrics.scopeMetrics[0].metrics.findIndex(
it => it.descriptor.name === 'double-observable-gauge2'
);
const histogramIndex = metrics.scopeMetrics[0].metrics.findIndex(
it => it.descriptor.name === 'int-histogram'
);

const metric1 =
json.resourceMetrics[0].scopeMetrics[0].metrics[counterIndex];
const metric2 =
json.resourceMetrics[0].scopeMetrics[0].metrics[observableIndex];
const metric3 =
json.resourceMetrics[0].scopeMetrics[0].metrics[histogramIndex];
try {
const request = server.requests[0];
assert.strictEqual(request.method, 'POST');
assert.strictEqual(request.url, 'http://foo.bar.com');

const body = request.requestBody;
const json = JSON.parse(
new TextDecoder().decode(body)
) as IExportMetricsServiceRequest;
// The order of the metrics is not guaranteed.
const counterIndex = metrics.scopeMetrics[0].metrics.findIndex(
it => it.descriptor.name === 'int-counter'
);
const observableIndex = metrics.scopeMetrics[0].metrics.findIndex(
it => it.descriptor.name === 'double-observable-gauge2'
);
const histogramIndex = metrics.scopeMetrics[0].metrics.findIndex(
it => it.descriptor.name === 'int-histogram'
);

assert.ok(typeof metric1 !== 'undefined', "metric doesn't exist");
ensureCounterIsCorrect(
metric1,
metrics.scopeMetrics[0].metrics[counterIndex].dataPoints[0].endTime,
metrics.scopeMetrics[0].metrics[counterIndex].dataPoints[0]
.startTime
);
const metric1 =
json.resourceMetrics[0].scopeMetrics[0].metrics[counterIndex];
const metric2 =
json.resourceMetrics[0].scopeMetrics[0].metrics[observableIndex];
const metric3 =
json.resourceMetrics[0].scopeMetrics[0].metrics[histogramIndex];

assert.ok(typeof metric1 !== 'undefined', "metric doesn't exist");
ensureCounterIsCorrect(
metric1,
metrics.scopeMetrics[0].metrics[counterIndex].dataPoints[0]
.endTime,
metrics.scopeMetrics[0].metrics[counterIndex].dataPoints[0]
.startTime
);

assert.ok(
typeof metric2 !== 'undefined',
"second metric doesn't exist"
);
ensureObservableGaugeIsCorrect(
metric2,
metrics.scopeMetrics[0].metrics[observableIndex].dataPoints[0]
.endTime,
metrics.scopeMetrics[0].metrics[observableIndex].dataPoints[0]
.startTime,
6,
'double-observable-gauge2'
);
assert.ok(
typeof metric2 !== 'undefined',
"second metric doesn't exist"
);
ensureObservableGaugeIsCorrect(
metric2,
metrics.scopeMetrics[0].metrics[observableIndex].dataPoints[0]
.endTime,
metrics.scopeMetrics[0].metrics[observableIndex].dataPoints[0]
.startTime,
6,
'double-observable-gauge2'
);

assert.ok(
typeof metric3 !== 'undefined',
"third metric doesn't exist"
);
ensureHistogramIsCorrect(
metric3,
metrics.scopeMetrics[0].metrics[histogramIndex].dataPoints[0]
.endTime,
metrics.scopeMetrics[0].metrics[histogramIndex].dataPoints[0]
.startTime,
[0, 100],
[0, 2, 0]
);
assert.ok(
typeof metric3 !== 'undefined',
"third metric doesn't exist"
);
ensureHistogramIsCorrect(
metric3,
metrics.scopeMetrics[0].metrics[histogramIndex].dataPoints[0]
.endTime,
metrics.scopeMetrics[0].metrics[histogramIndex].dataPoints[0]
.startTime,
[0, 100],
[0, 2, 0]
);

const resource = json.resourceMetrics[0].resource;
assert.ok(typeof resource !== 'undefined', "resource doesn't exist");
ensureWebResourceIsCorrect(resource);
const resource = json.resourceMetrics[0].resource;
assert.ok(
typeof resource !== 'undefined',
"resource doesn't exist"
);
ensureWebResourceIsCorrect(resource);

assert.strictEqual(stubBeacon.callCount, 0);
ensureExportMetricsServiceRequestIsSet(json);
assert.strictEqual(stubBeacon.callCount, 0);
ensureExportMetricsServiceRequestIsSet(json);

done();
done();
} catch (e) {
done(e);
}
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"devDependencies": {
"@opentelemetry/api": "1.9.0",
"@types/mocha": "10.0.9",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/sinon": "17.0.3",
"cross-var": "1.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
},
"devDependencies": {
"@opentelemetry/api": "1.9.0",
"@opentelemetry/semantic-conventions": "1.27.0",
"@types/mocha": "10.0.9",
"@opentelemetry/semantic-conventions": "1.28.0",
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/sinon": "17.0.3",
"cross-var": "1.1.0",
Expand Down
Loading

0 comments on commit 28eae97

Please sign in to comment.