Skip to content

Commit 8ab1601

Browse files
committed
Rename formatter to propagator (open-telemetry#851)
* chore: rename formatter to propagator * chore: lint * chore: last few formatter renames * chore: remove test of removed function * chore: remove unused imports
1 parent b420216 commit 8ab1601

File tree

7 files changed

+16
-36
lines changed

7 files changed

+16
-36
lines changed

api/src/api/propagation.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import { Context } from '@opentelemetry/scope-base';
1818
import { defaultGetter, GetterFunction } from '../context/propagation/getter';
19-
import { HttpTextFormat } from '../context/propagation/HttpTextFormat';
20-
import { NOOP_HTTP_TEXT_FORMAT } from '../context/propagation/NoopHttpTextFormat';
19+
import { HttpTextPropagator } from '../context/propagation/HttpTextPropagator';
20+
import { NOOP_HTTP_TEXT_PROPAGATOR } from '../context/propagation/NoopHttpTextPropagator';
2121
import { defaultSetter, SetterFunction } from '../context/propagation/setter';
2222
import { ContextAPI } from './context';
2323

@@ -28,7 +28,7 @@ const contextApi = ContextAPI.getInstance();
2828
*/
2929
export class PropagationAPI {
3030
private static _instance?: PropagationAPI;
31-
private _propagator: HttpTextFormat = NOOP_HTTP_TEXT_FORMAT;
31+
private _propagator: HttpTextPropagator = NOOP_HTTP_TEXT_PROPAGATOR;
3232

3333
/** Empty private constructor prevents end users from constructing a new instance of the API */
3434
private constructor() {}
@@ -45,7 +45,9 @@ export class PropagationAPI {
4545
/**
4646
* Set the current propagator. Returns the initialized propagator
4747
*/
48-
public setGlobalPropagator(propagator: HttpTextFormat): HttpTextFormat {
48+
public setGlobalPropagator(
49+
propagator: HttpTextPropagator
50+
): HttpTextPropagator {
4951
this._propagator = propagator;
5052
return propagator;
5153
}

api/src/context/propagation/HttpTextFormat.ts renamed to api/src/context/propagation/HttpTextPropagator.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ import { GetterFunction } from './getter';
2727
* The carrier of propagated data on both the client (injector) and server
2828
* (extractor) side is usually an object such as http headers.
2929
*/
30-
export interface HttpTextFormat {
30+
export interface HttpTextPropagator {
3131
/**
3232
* Injects values from a given {@link Context} into a carrier.
3333
*
34-
* OpenTelemetry defines a common set of format values (HTTPTextFormat), and
34+
* OpenTelemetry defines a common set of format values (HttpTextPropagator), and
3535
* each has an expected `carrier` type.
3636
*
3737
* @param context the Context from which to extract values to transmit over

api/src/context/propagation/NoopHttpTextFormat.ts renamed to api/src/context/propagation/NoopHttpTextPropagator.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
*/
1616

1717
import { Context } from '@opentelemetry/scope-base';
18-
import { HttpTextFormat } from './HttpTextFormat';
18+
import { HttpTextPropagator } from './HttpTextPropagator';
1919

2020
/**
21-
* No-op implementations of {@link HttpTextFormat}.
21+
* No-op implementations of {@link HttpTextPropagator}.
2222
*/
23-
export class NoopHttpTextFormat implements HttpTextFormat {
23+
export class NoopHttpTextPropagator implements HttpTextPropagator {
2424
/** Noop inject function does nothing */
2525
inject(context: Context, carrier: unknown, setter: Function): void {}
2626
/** Noop extract function does nothing and returns the input context */
@@ -29,4 +29,4 @@ export class NoopHttpTextFormat implements HttpTextFormat {
2929
}
3030
}
3131

32-
export const NOOP_HTTP_TEXT_FORMAT = new NoopHttpTextFormat();
32+
export const NOOP_HTTP_TEXT_PROPAGATOR = new NoopHttpTextPropagator();

api/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
export * from './common/Logger';
1818
export * from './common/Time';
1919
export * from './context/propagation/getter';
20-
export * from './context/propagation/HttpTextFormat';
21-
export * from './context/propagation/NoopHttpTextFormat';
20+
export * from './context/propagation/HttpTextPropagator';
21+
export * from './context/propagation/NoopHttpTextPropagator';
2222
export * from './context/propagation/setter';
2323
export * from './correlation_context/CorrelationContext';
2424
export * from './correlation_context/EntryValue';

api/src/trace/NoopTracer.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { HttpTextFormat, Span, SpanOptions, Tracer } from '..';
18-
import { NOOP_HTTP_TEXT_FORMAT } from '../context/propagation/NoopHttpTextFormat';
17+
import { Span, SpanOptions, Tracer } from '..';
1918
import { NOOP_SPAN } from './NoopSpan';
2019

2120
/**
@@ -41,11 +40,6 @@ export class NoopTracer implements Tracer {
4140
bind<T>(target: T, span?: Span): T {
4241
return target;
4342
}
44-
45-
// By default does nothing
46-
getHttpTextFormat(): HttpTextFormat {
47-
return NOOP_HTTP_TEXT_FORMAT;
48-
}
4943
}
5044

5145
export const NOOP_TRACER = new NoopTracer();

api/test/api/api.test.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ import api, {
2525
} from '../../src';
2626

2727
describe('API', () => {
28-
const functions = [
29-
'getCurrentSpan',
30-
'startSpan',
31-
'withSpan',
32-
'getHttpTextFormat',
33-
];
28+
const functions = ['getCurrentSpan', 'startSpan', 'withSpan'];
3429

3530
it('should expose a tracer provider via getTracerProvider', () => {
3631
const tracer = api.trace.getTracerProvider();

api/test/noop-implementations/noop-tracer.test.ts

-11
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { Context } from '@opentelemetry/scope-base';
1817
import * as assert from 'assert';
1918
import { NoopTracer, NOOP_SPAN, SpanKind } from '../../src';
20-
import { defaultGetter } from '../../src/context/propagation/getter';
21-
import { defaultSetter } from '../../src/context/propagation/setter';
2219

2320
describe('NoopTracer', () => {
2421
it('should not crash', () => {
@@ -37,14 +34,6 @@ describe('NoopTracer', () => {
3734
);
3835

3936
assert.deepStrictEqual(tracer.getCurrentSpan(), NOOP_SPAN);
40-
const httpTextFormat = tracer.getHttpTextFormat();
41-
assert.ok(httpTextFormat);
42-
43-
httpTextFormat.inject(Context.ROOT_CONTEXT, {}, defaultSetter);
44-
assert.deepStrictEqual(
45-
httpTextFormat.extract(Context.ROOT_CONTEXT, {}, defaultGetter),
46-
Context.ROOT_CONTEXT
47-
);
4837
});
4938

5039
it('should not crash when .withSpan()', done => {

0 commit comments

Comments
 (0)