Skip to content

Commit

Permalink
chore: renaming jaeger http trace propagator to jaeger propagator (#2148
Browse files Browse the repository at this point in the history
)

* chore: renaming jaeger http trace propagator to jaeger propagator

* chore: missing renaming

* chore: updating readme

* chore: readme

* chore: fixes after merge
  • Loading branch information
obecny authored May 4, 2021
1 parent a9d300d commit dfb7737
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 61 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ To request automatic tracing support for a module not on this list, please [file

- `HttpTraceContext` renamed to `HttpTraceContextPropagator`

- `JaegerHttpTracePropagator` renamed to `JaegerPropagator`

### 0.18.x to 0.19.0

- API is now a peer dependency. This means that users will need to include `@opentelemetry/api` as a dependency of their project in order to use the SDK. NPM version 7+ (Node 15+) should do this automatically.
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-node/src/NodeTracerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from '@opentelemetry/tracing';
import * as semver from 'semver';
import { NodeTracerConfig } from './config';
import { JaegerHttpTracePropagator } from '@opentelemetry/propagator-jaeger';
import { JaegerPropagator } from '@opentelemetry/propagator-jaeger';

/**
* Register this TracerProvider for use with the OpenTelemetry API.
Expand All @@ -49,7 +49,7 @@ export class NodeTracerProvider extends BasicTracerProvider {
'b3multi',
() => new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }),
],
['jaeger', () => new JaegerHttpTracePropagator()],
['jaeger', () => new JaegerPropagator()],
]);

constructor(config: NodeTracerConfig = {}) {
Expand Down
5 changes: 2 additions & 3 deletions packages/opentelemetry-propagator-jaeger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ Example of usage:

```javascript
const { NodeTracerProvider } = require('@opentelemetry/node');
const { JaegerHttpTracePropagator } = require('@opentelemetry/propagator-jaeger');
const { JaegerPropagator } = require('@opentelemetry/propagator-jaeger');

const provider = new NodeTracerProvider();
provider.register({
// Use Jaeger propagator
propagator: new JaegerHttpTracePropagator()
propagator: new JaegerPropagator()
});
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const UBER_TRACE_ID_HEADER = 'uber-trace-id';
* One byte bitmap, as two hex digits.
* Inspired by jaeger-client-node project.
*/
export class JaegerHttpTracePropagator implements TextMapPropagator {
export class JaegerPropagator implements TextMapPropagator {
private readonly _jaegerTraceHeader: string;

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-propagator-jaeger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
* limitations under the License.
*/

export * from './JaegerHttpTracePropagator';
export * from './JaegerPropagator';
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ import {
} from '@opentelemetry/api';
import * as assert from 'assert';
import {
JaegerHttpTracePropagator,
JaegerPropagator,
UBER_TRACE_ID_HEADER,
} from '../src/JaegerHttpTracePropagator';
} from '../src/JaegerPropagator';

describe('JaegerHttpTracePropagator', () => {
const jaegerHttpTracePropagator = new JaegerHttpTracePropagator();
describe('JaegerPropagator', () => {
const jaegerPropagator = new JaegerPropagator();
const customHeader = 'new-header';
const customJaegerHttpTracePropagator = new JaegerHttpTracePropagator(
customHeader
);
const customJaegerPropagator = new JaegerPropagator(customHeader);
let carrier: { [key: string]: unknown };

beforeEach(() => {
Expand All @@ -51,7 +49,7 @@ describe('JaegerHttpTracePropagator', () => {
traceFlags: TraceFlags.SAMPLED,
};

jaegerHttpTracePropagator.inject(
jaegerPropagator.inject(
setSpanContext(ROOT_CONTEXT, spanContext),
carrier,
defaultTextMapSetter
Expand All @@ -69,7 +67,7 @@ describe('JaegerHttpTracePropagator', () => {
traceFlags: TraceFlags.SAMPLED,
};

customJaegerHttpTracePropagator.inject(
customJaegerPropagator.inject(
setSpanContext(ROOT_CONTEXT, spanContext),
carrier,
defaultTextMapSetter
Expand All @@ -87,7 +85,7 @@ describe('JaegerHttpTracePropagator', () => {
traceFlags: TraceFlags.SAMPLED,
};

jaegerHttpTracePropagator.inject(
jaegerPropagator.inject(
suppressInstrumentation(setSpanContext(ROOT_CONTEXT, spanContext)),
carrier,
defaultTextMapSetter
Expand All @@ -101,11 +99,7 @@ describe('JaegerHttpTracePropagator', () => {
carrier[UBER_TRACE_ID_HEADER] =
'd4cda95b652f4a1592b449d5929fda1b:6e0c63257de34c92:0:01';
const extractedSpanContext = getSpanContext(
jaegerHttpTracePropagator.extract(
ROOT_CONTEXT,
carrier,
defaultTextMapGetter
)
jaegerPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter)
);

assert.deepStrictEqual(extractedSpanContext, {
Expand All @@ -120,11 +114,7 @@ describe('JaegerHttpTracePropagator', () => {
carrier[UBER_TRACE_ID_HEADER] =
'9c41e35aeb6d1272:45fd2a9709dadcf1:a13699e3fb724f40:1';
const extractedSpanContext = getSpanContext(
jaegerHttpTracePropagator.extract(
ROOT_CONTEXT,
carrier,
defaultTextMapGetter
)
jaegerPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter)
);

assert.deepStrictEqual(extractedSpanContext, {
Expand All @@ -139,11 +129,7 @@ describe('JaegerHttpTracePropagator', () => {
carrier[UBER_TRACE_ID_HEADER] =
'ac1f3dc3c2c0b06e%3A5ac292c4a11a163e%3Ac086aaa825821068%3A1';
const extractedSpanContext = getSpanContext(
jaegerHttpTracePropagator.extract(
ROOT_CONTEXT,
carrier,
defaultTextMapGetter
)
jaegerPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter)
);

assert.deepStrictEqual(extractedSpanContext, {
Expand All @@ -158,7 +144,7 @@ describe('JaegerHttpTracePropagator', () => {
carrier[customHeader] =
'd4cda95b652f4a1592b449d5929fda1b:6e0c63257de34c92:0:01';
const extractedSpanContext = getSpanContext(
customJaegerHttpTracePropagator.extract(
customJaegerPropagator.extract(
ROOT_CONTEXT,
carrier,
defaultTextMapGetter
Expand All @@ -176,11 +162,7 @@ describe('JaegerHttpTracePropagator', () => {
it('returns undefined if UBER_TRACE_ID_HEADER header is missing', () => {
assert.deepStrictEqual(
getSpanContext(
jaegerHttpTracePropagator.extract(
ROOT_CONTEXT,
carrier,
defaultTextMapGetter
)
jaegerPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter)
),
undefined
);
Expand All @@ -190,11 +172,7 @@ describe('JaegerHttpTracePropagator', () => {
carrier[UBER_TRACE_ID_HEADER] = 'invalid!';
assert.deepStrictEqual(
getSpanContext(
jaegerHttpTracePropagator.extract(
ROOT_CONTEXT,
carrier,
defaultTextMapGetter
)
jaegerPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter)
),
undefined
);
Expand All @@ -203,29 +181,25 @@ describe('JaegerHttpTracePropagator', () => {

describe('.fields()', () => {
it('returns the default header if not customized', () => {
assert.deepStrictEqual(jaegerHttpTracePropagator.fields(), [
'uber-trace-id',
]);
assert.deepStrictEqual(jaegerPropagator.fields(), ['uber-trace-id']);
});
it('returns the customized header if customized', () => {
assert.deepStrictEqual(customJaegerHttpTracePropagator.fields(), [
customHeader,
]);
assert.deepStrictEqual(customJaegerPropagator.fields(), [customHeader]);
});
});

it('should fail gracefully on bad responses from getter', () => {
const ctx1 = jaegerHttpTracePropagator.extract(
const ctx1 = jaegerPropagator.extract(
ROOT_CONTEXT,
carrier,
makeGetter(1) // not a number
);
const ctx2 = jaegerHttpTracePropagator.extract(
const ctx2 = jaegerPropagator.extract(
ROOT_CONTEXT,
carrier,
makeGetter([]) // empty array
);
const ctx3 = jaegerHttpTracePropagator.extract(
const ctx3 = jaegerPropagator.extract(
ROOT_CONTEXT,
carrier,
makeGetter(undefined) // missing value
Expand Down
14 changes: 5 additions & 9 deletions packages/opentelemetry-shim-opentracing/test/Shim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
} from '@opentelemetry/api';
import { performance } from 'perf_hooks';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { JaegerHttpTracePropagator } from '@opentelemetry/propagator-jaeger';
import { JaegerPropagator } from '@opentelemetry/propagator-jaeger';

describe('OpenTracing Shim', () => {
const compositePropagator = new CompositePropagator({
Expand Down Expand Up @@ -129,13 +129,13 @@ describe('OpenTracing Shim', () => {
});

describe('propagation using configured propagators', () => {
const jaegerHttpTracePropagator = new JaegerHttpTracePropagator();
const jaegerPropagator = new JaegerPropagator();
const b3Propagator = new B3Propagator();
before(() => {
const provider = new BasicTracerProvider();
shimTracer = new TracerShim(provider.getTracer('default'), {
textMapPropagator: b3Propagator,
httpHeadersPropagator: jaegerHttpTracePropagator,
httpHeadersPropagator: jaegerPropagator,
});
opentracing.initGlobalTracer(shimTracer);
});
Expand All @@ -149,11 +149,7 @@ describe('OpenTracing Shim', () => {
const carrier: { [key: string]: unknown } = {};
shimTracer.inject(context, opentracing.FORMAT_HTTP_HEADERS, carrier);
const extractedContext = getSpanContext(
jaegerHttpTracePropagator.extract(
ROOT_CONTEXT,
carrier,
defaultTextMapGetter
)
jaegerPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter)
);
assert.ok(extractedContext !== null);
assert.strictEqual(extractedContext?.traceId, context.toTraceId());
Expand All @@ -162,7 +158,7 @@ describe('OpenTracing Shim', () => {

it('extracts HTTP carriers', () => {
const carrier: { [key: string]: unknown } = {};
jaegerHttpTracePropagator.inject(
jaegerPropagator.inject(
setSpanContext(
ROOT_CONTEXT,
(context as SpanContextShim).getSpanContext()
Expand Down

0 comments on commit dfb7737

Please sign in to comment.