Skip to content

Commit

Permalink
chore: upgrade to OpenTelemetry 0.22, API 1.0.0 (#153)
Browse files Browse the repository at this point in the history
* chore: upgrade to OpenTelemetry 0.22, API 1.0.0

* chore: update CHANGELOG
  • Loading branch information
seemk authored Jul 1, 2021
1 parent 4bbe598 commit 6b340d9
Show file tree
Hide file tree
Showing 9 changed files with 481 additions and 455 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
([#121](https://github.com/signalfx/splunk-otel-js/pull/121))
- Rename `SPLUNK_CONTEXT_SERVER_TIMING_ENABLED`
([#149](https://github.com/signalfx/splunk-otel-js/pull/149))
- Upgrade to OpenTelemetry SDK 0.22.0, API 1.0.0.
([#153](https://github.com/signalfx/splunk-otel-js/pull/153))

## 0.8.0 (04-15-2021)

Expand Down
822 changes: 422 additions & 400 deletions package-lock.json

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
"access": "public"
},
"devDependencies": {
"@opentelemetry/instrumentation-http": "~0.19.0",
"@opentelemetry/instrumentation-bunyan": "~0.16.0",
"@opentelemetry/instrumentation-pino": "~0.16.0",
"@opentelemetry/instrumentation-winston": "~0.16.0",
"@opentelemetry/instrumentation-http": "^0.22.0",
"@opentelemetry/instrumentation-bunyan": "^0.22.0",
"@opentelemetry/instrumentation-pino": "^0.22.0",
"@opentelemetry/instrumentation-winston": "^0.22.0",
"@types/bunyan": "1.8.6",
"@types/mocha": "8.2.2",
"@types/node": "15.12.2",
Expand Down Expand Up @@ -78,43 +78,43 @@
"winston": "3.3.3"
},
"dependencies": {
"@opentelemetry/api": "~1.0.0-rc.3",
"@opentelemetry/context-async-hooks": "~0.19.0",
"@opentelemetry/core": "~0.19.0",
"@opentelemetry/exporter-jaeger": "~0.19.0",
"@opentelemetry/instrumentation": "~0.19.0",
"@opentelemetry/node": "~0.19.0",
"@opentelemetry/propagator-b3": "~0.19.0",
"@opentelemetry/resources": "~0.19.0",
"@opentelemetry/semantic-conventions": "~0.19.0",
"@opentelemetry/tracing": "~0.19.0",
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/context-async-hooks": "^0.22.0",
"@opentelemetry/core": "^0.22.0",
"@opentelemetry/exporter-jaeger": "^0.22.0",
"@opentelemetry/instrumentation": "^0.22.0",
"@opentelemetry/node": "^0.22.0",
"@opentelemetry/propagator-b3": "^0.22.0",
"@opentelemetry/resources": "^0.22.0",
"@opentelemetry/semantic-conventions": "^0.22.0",
"@opentelemetry/tracing": "^0.22.0",
"jaeger-client": "^3.15.0",
"semver": "^7.1.3"
},
"peerDependencies": {
"@opentelemetry/instrumentation-dns": "~0.16.0",
"@opentelemetry/instrumentation-express": "~0.16.0",
"@opentelemetry/instrumentation-graphql": "~0.16.0",
"@opentelemetry/instrumentation-grpc": "~0.19.0",
"@opentelemetry/instrumentation-hapi": "~0.16.0",
"@opentelemetry/instrumentation-http": "~0.19.0",
"@opentelemetry/instrumentation-ioredis": "~0.16.0",
"@opentelemetry/instrumentation-koa": "~0.16.0",
"@opentelemetry/instrumentation-mongodb": "~0.16.0",
"@opentelemetry/instrumentation-mysql": "~0.16.0",
"@opentelemetry/instrumentation-net": "~0.16.0",
"@opentelemetry/instrumentation-pg": "~0.16.0",
"@opentelemetry/instrumentation-redis": "~0.16.0",
"@opentelemetry/instrumentation-bunyan": "~0.16.0",
"@opentelemetry/instrumentation-pino": "~0.16.0",
"@opentelemetry/instrumentation-winston": "~0.16.0",
"opentelemetry-instrumentation-amqplib": "~0.4.2",
"opentelemetry-instrumentation-aws-sdk": "~0.4.3",
"opentelemetry-instrumentation-elasticsearch": "~0.4.2",
"opentelemetry-instrumentation-kafkajs": "~0.4.3",
"opentelemetry-instrumentation-mongoose": "~0.4.3",
"opentelemetry-instrumentation-sequelize": "~0.4.2",
"opentelemetry-instrumentation-typeorm": "~0.4.2"
"@opentelemetry/instrumentation-dns": "^0.22.0",
"@opentelemetry/instrumentation-express": "^0.22.0",
"@opentelemetry/instrumentation-graphql": "^0.22.0",
"@opentelemetry/instrumentation-grpc": "^0.22.0",
"@opentelemetry/instrumentation-hapi": "^0.22.0",
"@opentelemetry/instrumentation-http": "^0.22.0",
"@opentelemetry/instrumentation-ioredis": "^0.22.0",
"@opentelemetry/instrumentation-koa": "^0.22.0",
"@opentelemetry/instrumentation-mongodb": "^0.22.0",
"@opentelemetry/instrumentation-mysql": "^0.22.0",
"@opentelemetry/instrumentation-net": "^0.22.0",
"@opentelemetry/instrumentation-pg": "^0.22.0",
"@opentelemetry/instrumentation-redis": "^0.22.0",
"@opentelemetry/instrumentation-bunyan": "^0.22.0",
"@opentelemetry/instrumentation-pino": "^0.22.0",
"@opentelemetry/instrumentation-winston": "^0.22.0",
"opentelemetry-instrumentation-amqplib": "^0.22.0",
"opentelemetry-instrumentation-aws-sdk": "^0.22.0",
"opentelemetry-instrumentation-elasticsearch": "^0.22.0",
"opentelemetry-instrumentation-kafkajs": "^0.22.0",
"opentelemetry-instrumentation-mongoose": "^0.22.0",
"opentelemetry-instrumentation-sequelize": "^0.22.0",
"opentelemetry-instrumentation-typeorm": "^0.22.0"
},
"peerDependenciesMeta": {
"@opentelemetry/instrumentation-http": {
Expand Down
2 changes: 1 addition & 1 deletion src/instrumentations/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function configureHttpInstrumentation(
response
) => {
if (response instanceof ServerResponse) {
const spanContext = span.context();
const spanContext = span.spanContext();

if (isSpanContextValid(spanContext)) {
const { traceFlags, traceId, spanId } = spanContext;
Expand Down
7 changes: 5 additions & 2 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ import { NodeTracerConfig } from '@opentelemetry/node';
import { Resource } from '@opentelemetry/resources';
import { ResourceAttributes } from '@opentelemetry/semantic-conventions';
import { TextMapPropagator } from '@opentelemetry/api';
import { CompositePropagator, HttpTraceContext } from '@opentelemetry/core';
import {
CompositePropagator,
HttpTraceContextPropagator,
} from '@opentelemetry/core';

const defaultEndpoint = 'http://localhost:9080/v1/trace';
const defaultServiceName = 'unnamed-node-service';
Expand Down Expand Up @@ -158,7 +161,7 @@ export function defaultPropagatorFactory(options: Options): TextMapPropagator {
return new CompositePropagator({
propagators: [
new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }),
new HttpTraceContext(),
new HttpTraceContextPropagator(),
],
});
}
Expand Down
6 changes: 3 additions & 3 deletions test/loginjection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as assert from 'assert';
import { Writable } from 'stream';
import { context, trace, getSpan, setSpan } from '@opentelemetry/api';
import { context, trace } from '@opentelemetry/api';
import { startTracing } from '../src/tracing';
import type * as pino from 'pino';
import type * as bunyan from 'bunyan';
Expand All @@ -28,8 +28,8 @@ describe('log injection', () => {

function assertInjection(logger, done, extra) {
const span = trace.getTracer('test').startSpan('main');
context.with(setSpan(context.active(), span), () => {
const { traceId, spanId } = span.context();
context.with(trace.setSpan(context.active(), span), () => {
const { traceId, spanId } = span.spanContext();
logger.info('my-log-message');
assert.strictEqual(record['trace_id'], traceId);
assert.strictEqual(record['span_id'], spanId);
Expand Down
6 changes: 3 additions & 3 deletions test/propagation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('propagation', () => {

const tracer = otel.trace.getTracer('test-tracer');
const span = tracer.startSpan('main');
otel.context.with(otel.setSpan(otel.context.active(), span), () => {
otel.context.with(otel.trace.setSpan(otel.context.active(), span), () => {
const carrier = {};
otel.propagation.inject(
otel.context.active(),
Expand All @@ -42,8 +42,8 @@ describe('propagation', () => {
);
span.end();

const traceId = span.context().traceId;
const spanId = span.context().spanId;
const traceId = span.spanContext().traceId;
const spanId = span.spanContext().spanId;
assert.strictEqual(carrier['x-b3-traceid'], traceId);
assert.strictEqual(carrier['x-b3-spanid'], spanId);
assert.strictEqual(carrier['x-b3-sampled'], '1');
Expand Down
6 changes: 3 additions & 3 deletions test/servertiming.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as assert from 'assert';
import * as sinon from 'sinon';
import { context, getSpanContext } from '@opentelemetry/api';
import { context, trace } from '@opentelemetry/api';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
import { startTracing } from '../src/tracing';

Expand Down Expand Up @@ -46,7 +46,7 @@ describe('servertiming', () => {
let spanContext;
const http = require('http');
server = http.createServer((req, res) => {
spanContext = getSpanContext(context.active());
spanContext = trace.getSpanContext(context.active());
res.end('ok');
});
server.listen(PORT);
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('servertiming', () => {
const http = require('http');
let spanContext;
server = http.createServer((req, res) => {
spanContext = getSpanContext(context.active());
spanContext = trace.getSpanContext(context.active());
res.end('ok');
});
server.listen(PORT);
Expand Down
11 changes: 5 additions & 6 deletions test/tracing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,15 @@ describe('tracing', () => {
const exporter = processor['_exporter'];
assert(exporter instanceof JaegerExporter);

const sender = exporter['_sender'];
assert.deepEqual(sender['_url'], URL.parse(exportURL)); // eslint-disable-line node/no-deprecated-api
const config = exporter['_localConfig'];
assert.deepEqual(config['endpoint'], exportURL);

if (accessToken) {
assert.equal(sender['_username'], 'auth');
assert.equal(sender['_password'], accessToken);
assert.equal(config['username'], 'auth');
assert.equal(config['password'], accessToken);
}

const process = exporter['_process'];
assert.equal(process.serviceName, serviceName);
assert.equal(config['serviceName'], serviceName);

assert.equal(maxAttrLength, patchJaegerMock.getCall(0).args[0]);
}
Expand Down

0 comments on commit 6b340d9

Please sign in to comment.