Skip to content

Commit

Permalink
chore: upgrade to otel 1.28.0 / 0.55.0
Browse files Browse the repository at this point in the history
  • Loading branch information
seemk committed Dec 4, 2024
1 parent c89f1a9 commit 70652e7
Show file tree
Hide file tree
Showing 8 changed files with 856 additions and 703 deletions.
1,375 changes: 742 additions & 633 deletions package-lock.json

Large diffs are not rendered by default.

108 changes: 54 additions & 54 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,60 +101,60 @@
"@grpc/grpc-js": "^1.11.1",
"@grpc/proto-loader": "^0.7.13",
"@opentelemetry/api": "^1.8.0",
"@opentelemetry/api-logs": "^0.53.0",
"@opentelemetry/context-async-hooks": "1.26.0",
"@opentelemetry/core": "1.26.0",
"@opentelemetry/resource-detector-container": "0.4.1",
"@opentelemetry/exporter-logs-otlp-http": "0.53.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "0.53.0",
"@opentelemetry/exporter-metrics-otlp-proto": "0.53.0",
"@opentelemetry/exporter-trace-otlp-grpc": "0.53.0",
"@opentelemetry/exporter-trace-otlp-proto": "0.53.0",
"@opentelemetry/instrumentation": "0.53.0",
"@opentelemetry/instrumentation-amqplib": "0.42.0",
"@opentelemetry/instrumentation-aws-sdk": "0.44.0",
"@opentelemetry/instrumentation-bunyan": "0.41.0",
"@opentelemetry/instrumentation-cassandra-driver": "0.41.0",
"@opentelemetry/instrumentation-connect": "0.39.0",
"@opentelemetry/instrumentation-dataloader": "0.12.0",
"@opentelemetry/instrumentation-dns": "0.39.0",
"@opentelemetry/instrumentation-express": "0.42.0",
"@opentelemetry/instrumentation-fastify": "0.39.0",
"@opentelemetry/instrumentation-generic-pool": "0.39.0",
"@opentelemetry/instrumentation-graphql": "0.43.0",
"@opentelemetry/instrumentation-grpc": "0.53.0",
"@opentelemetry/instrumentation-hapi": "0.41.0",
"@opentelemetry/instrumentation-http": "0.53.0",
"@opentelemetry/instrumentation-ioredis": "0.43.0",
"@opentelemetry/instrumentation-kafkajs": "0.3.0",
"@opentelemetry/instrumentation-knex": "0.40.0",
"@opentelemetry/instrumentation-koa": "0.43.0",
"@opentelemetry/instrumentation-lru-memoizer": "0.40.0",
"@opentelemetry/instrumentation-memcached": "0.39.0",
"@opentelemetry/instrumentation-mongodb": "0.47.0",
"@opentelemetry/instrumentation-mongoose": "0.42.0",
"@opentelemetry/instrumentation-mysql": "0.41.0",
"@opentelemetry/instrumentation-mysql2": "0.41.0",
"@opentelemetry/instrumentation-nestjs-core": "0.40.0",
"@opentelemetry/instrumentation-net": "0.39.0",
"@opentelemetry/instrumentation-pg": "0.44.0",
"@opentelemetry/instrumentation-pino": "0.42.0",
"@opentelemetry/instrumentation-redis": "0.42.0",
"@opentelemetry/instrumentation-redis-4": "0.42.0",
"@opentelemetry/instrumentation-restify": "0.41.0",
"@opentelemetry/instrumentation-router": "0.40.0",
"@opentelemetry/instrumentation-socket.io": "0.42.0",
"@opentelemetry/instrumentation-tedious": "0.14.0",
"@opentelemetry/instrumentation-undici": "0.6.0",
"@opentelemetry/instrumentation-winston": "0.40.0",
"@opentelemetry/propagator-b3": "1.26.0",
"@opentelemetry/resources": "1.26.0",
"@opentelemetry/sdk-logs": "^0.53.0",
"@opentelemetry/sdk-metrics": "1.26.0",
"@opentelemetry/sdk-trace-base": "1.26.0",
"@opentelemetry/sdk-trace-node": "1.26.0",
"@opentelemetry/semantic-conventions": "1.27.0",
"@opentelemetry/winston-transport": "0.6.0",
"@opentelemetry/api-logs": "^0.55.0",
"@opentelemetry/context-async-hooks": "1.28.0",
"@opentelemetry/core": "1.28.0",
"@opentelemetry/resource-detector-container": "0.5.1",
"@opentelemetry/exporter-logs-otlp-http": "0.55.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "0.55.0",
"@opentelemetry/exporter-metrics-otlp-proto": "0.55.0",
"@opentelemetry/exporter-trace-otlp-grpc": "0.55.0",
"@opentelemetry/exporter-trace-otlp-proto": "0.55.0",
"@opentelemetry/instrumentation": "0.55.0",
"@opentelemetry/instrumentation-amqplib": "0.44.0",
"@opentelemetry/instrumentation-aws-sdk": "0.47.0",
"@opentelemetry/instrumentation-bunyan": "0.43.0",
"@opentelemetry/instrumentation-cassandra-driver": "0.43.0",
"@opentelemetry/instrumentation-connect": "0.41.0",
"@opentelemetry/instrumentation-dataloader": "0.14.0",
"@opentelemetry/instrumentation-dns": "0.41.0",
"@opentelemetry/instrumentation-express": "0.45.0",
"@opentelemetry/instrumentation-fastify": "0.42.0",
"@opentelemetry/instrumentation-generic-pool": "0.41.0",
"@opentelemetry/instrumentation-graphql": "0.45.0",
"@opentelemetry/instrumentation-grpc": "0.55.0",
"@opentelemetry/instrumentation-hapi": "0.43.0",
"@opentelemetry/instrumentation-http": "0.55.0",
"@opentelemetry/instrumentation-ioredis": "0.45.0",
"@opentelemetry/instrumentation-kafkajs": "0.5.0",
"@opentelemetry/instrumentation-knex": "0.42.0",
"@opentelemetry/instrumentation-koa": "0.45.0",
"@opentelemetry/instrumentation-lru-memoizer": "0.42.0",
"@opentelemetry/instrumentation-memcached": "0.41.0",
"@opentelemetry/instrumentation-mongodb": "0.49.0",
"@opentelemetry/instrumentation-mongoose": "0.44.0",
"@opentelemetry/instrumentation-mysql": "0.43.0",
"@opentelemetry/instrumentation-mysql2": "0.43.0",
"@opentelemetry/instrumentation-nestjs-core": "0.42.0",
"@opentelemetry/instrumentation-net": "0.41.0",
"@opentelemetry/instrumentation-pg": "0.48.0",
"@opentelemetry/instrumentation-pino": "0.44.0",
"@opentelemetry/instrumentation-redis": "0.44.0",
"@opentelemetry/instrumentation-redis-4": "0.44.0",
"@opentelemetry/instrumentation-restify": "0.43.0",
"@opentelemetry/instrumentation-router": "0.42.0",
"@opentelemetry/instrumentation-socket.io": "0.44.0",
"@opentelemetry/instrumentation-tedious": "0.16.0",
"@opentelemetry/instrumentation-undici": "0.8.0",
"@opentelemetry/instrumentation-winston": "0.42.0",
"@opentelemetry/propagator-b3": "1.28.0",
"@opentelemetry/resources": "1.28.0",
"@opentelemetry/sdk-logs": "^0.55.0",
"@opentelemetry/sdk-metrics": "1.28.0",
"@opentelemetry/sdk-trace-base": "1.28.0",
"@opentelemetry/sdk-trace-node": "1.28.0",
"@opentelemetry/semantic-conventions": "1.28.0",
"@opentelemetry/winston-transport": "0.8.0",
"is-promise": "^4.0.0",
"nan": "^2.22.0",
"node-gyp-build": "^4.8.2",
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function createOtlpExporter(options: MetricsOptions) {
? {
'X-SF-TOKEN': options.accessToken,
}
: {};
: undefined;
return new OTLPHttpProtoMetricExporter({
url: endpoint,
headers,
Expand Down
2 changes: 1 addition & 1 deletion src/tracing/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export function otlpSpanExporterFactory(options: Options): SpanExporter {
? {
'X-SF-TOKEN': accessToken,
}
: {};
: undefined;
return new OTLPHttpTraceExporter({
url: endpoint,
headers,
Expand Down
8 changes: 4 additions & 4 deletions test/metrics.options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('metrics options', () => {
const [reader] = options.metricReaderFactory(options);
const exporter = reader['_exporter'];
assert(exporter instanceof OTLPMetricExporter);
assert.deepStrictEqual(exporter['_otlpExporter'].url, 'foobar:4200');
assert.deepStrictEqual(utils.exporterUrl(exporter), 'foobar:4200');
});
});

Expand All @@ -125,7 +125,7 @@ describe('metrics options', () => {

assert(exporter instanceof OTLPHttpProtoMetricExporter);
assert.deepStrictEqual(
exporter['_otlpExporter'].url,
utils.exporterUrl(exporter),
'https://ingest.us0.signalfx.com/v2/datapoint/otlp'
);
sinon.assert.calledWith(
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('metrics options', () => {
);

assert.deepStrictEqual(
exporter['_otlpExporter'].url,
utils.exporterUrl(exporter),
'https://ingest.eu0.signalfx.com/v2/datapoint/otlp'
);
});
Expand All @@ -177,7 +177,7 @@ describe('metrics options', () => {
'OTLP metric exporter factory: Realm value ignored (full endpoint URL has been specified).'
);
assert(exporter instanceof OTLPMetricExporter);
assert.deepStrictEqual(exporter['_otlpExporter'].url, 'localhost:4317');
assert.deepStrictEqual(utils.exporterUrl(exporter), 'localhost:4317');
});
});
});
10 changes: 5 additions & 5 deletions test/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ describe('options', () => {
const [exporter] = exporters;
assert(exporter instanceof OTLPHttpTraceExporter);
assert.deepStrictEqual(
exporter.url,
utils.exporterUrl(exporter),
`https://ingest.us0.signalfx.com/v2/trace/otlp`
);
});
Expand Down Expand Up @@ -415,7 +415,7 @@ describe('options', () => {
const [exporter] = exporters;
assert(exporter instanceof OTLPHttpTraceExporter);
assert.deepStrictEqual(
exporter.url,
utils.exporterUrl(exporter),
'https://ingest.us0.signalfx.com/v2/trace/otlp'
);
sinon.assert.calledWith(
Expand All @@ -441,7 +441,7 @@ describe('options', () => {
exporter instanceof OTLPTraceExporter,
'Expected exporter to be instance of OTLPTraceExporter'
);
assert.deepStrictEqual(exporter.url, 'localhost:4317');
assert.deepStrictEqual(utils.exporterUrl(exporter), 'localhost:4317');
});
});

Expand Down Expand Up @@ -482,7 +482,7 @@ describe('options', () => {
assert(Array.isArray(exporters));
const [exporter] = exporters;
assert(exporter instanceof OTLPTraceExporter);
assert.deepStrictEqual(exporter.url, 'foobar:4200');
assert.deepStrictEqual(utils.exporterUrl(exporter), 'foobar:4200');
});

it('prefers OTEL_EXPORTER_OTLP_TRACES_ENDPOINT over OTEL_EXPORTER_OTLP_ENDPOINT', () => {
Expand All @@ -493,7 +493,7 @@ describe('options', () => {
assert(Array.isArray(exporters));
const [exporter] = exporters;
assert(exporter instanceof OTLPTraceExporter);
assert.deepStrictEqual(exporter.url, 'barfoo:2400');
assert.deepStrictEqual(utils.exporterUrl(exporter), 'barfoo:2400');
});
});
});
Expand Down
7 changes: 2 additions & 5 deletions test/tracing/tracing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,11 @@ describe('tracing:otlp', () => {
const exporter = processor['_exporter'];
assert(exporter instanceof OTLPTraceExporter);

assert.deepEqual(exporter.url, exportURL);
assert.deepEqual(utils.exporterUrl(exporter), exportURL);

if (accessToken) {
// gRPC not yet supported in ingest
assert.equal(
exporter['_transport']['_parameters']['metadata']().get('x-sf-token'),
accessToken
);
assert.equal(utils.exporterHeaders(exporter)['x-sf-token'], accessToken);
}
}

Expand Down
47 changes: 47 additions & 0 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ import * as assert from 'assert';
import * as util from 'util';
import { Writable } from 'stream';
import { context, trace } from '@opentelemetry/api';
// eslint bugs and reports these as extraneous even though instanceof is used
// eslint-disable-next-line n/no-extraneous-import
import { OTLPExporterNodeBase } from '@opentelemetry/otlp-exporter-base';
import { OTLPTraceExporter as OTLPGrpcTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
import { OTLPTraceExporter as OTLPHttpTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
// eslint-disable-next-line n/no-extraneous-import
import { OTLPMetricExporterBase } from '@opentelemetry/exporter-metrics-otlp-http';

const isConfigVarEntry = (key) => {
const lowercased = key.toLowerCase();
Expand Down Expand Up @@ -106,3 +113,43 @@ export function assertInjection(
);
}
}

export function exporterUrl(exporter: any) {
if (exporter instanceof OTLPGrpcTraceExporter) {
const transport = exporter['_transport'];
return transport['_parameters'].address;
}

if (exporter instanceof OTLPHttpTraceExporter) {
return exporter['_transport']['_transport']['_parameters'].url;
}

if (exporter instanceof OTLPMetricExporterBase) {
const transport = exporter['_otlpExporter']['_transport'];
if (transport['_parameters']) {
return transport['_parameters'].address;
}

return transport['_transport']['_parameters'].url;
}

return undefined;
}

export function exporterHeaders(exporter: any) {
if (exporter instanceof OTLPHttpTraceExporter) {
return exporter['_transport']['_transport']['_parameters']['headers'];
}

if (exporter instanceof OTLPGrpcTraceExporter) {
return exporter['_transport']['_parameters'].metadata().toJSON();
}

if (exporter instanceof OTLPMetricExporterBase) {
return exporter['_otlpExporter']['_transport']['_transport']['_parameters'][
'headers'
];
}

return {};
}

0 comments on commit 70652e7

Please sign in to comment.