Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: renaming jaeger http trace propagator to jaeger propagator #2148

Merged
merged 8 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions packages/opentelemetry-propagator-jaeger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ 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()
// Use Jaeger Propagator
obecny marked this conversation as resolved.
Show resolved Hide resolved
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