Skip to content

Commit

Permalink
refactor: rename HttpText to TextMap propagator (open-telemetry#1458)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Dyla <[email protected]>
Co-authored-by: Valentin Marchaud <[email protected]>
  • Loading branch information
3 people committed Feb 18, 2021
1 parent ae1bdd1 commit 2b6c32d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions api/src/api/global-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { ContextManager } from '@opentelemetry/context-base';
import { HttpTextPropagator } from '../context/propagation/HttpTextPropagator';
import { TextMapPropagator } from '../context/propagation/TextMapPropagator';
import { MeterProvider } from '../metrics/MeterProvider';
import { TracerProvider } from '../trace/tracer_provider';
import { _globalThis } from '../platform';
Expand All @@ -35,7 +35,7 @@ type Get<T> = (version: number) => T;
type OtelGlobal = Partial<{
[GLOBAL_CONTEXT_MANAGER_API_KEY]: Get<ContextManager>;
[GLOBAL_METRICS_API_KEY]: Get<MeterProvider>;
[GLOBAL_PROPAGATION_API_KEY]: Get<HttpTextPropagator>;
[GLOBAL_PROPAGATION_API_KEY]: Get<TextMapPropagator>;
[GLOBAL_TRACE_API_KEY]: Get<TracerProvider>;
}>;

Expand Down
14 changes: 6 additions & 8 deletions api/src/api/propagation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import { Context } from '@opentelemetry/context-base';
import { defaultGetter, GetterFunction } from '../context/propagation/getter';
import { HttpTextPropagator } from '../context/propagation/HttpTextPropagator';
import { NOOP_HTTP_TEXT_PROPAGATOR } from '../context/propagation/NoopHttpTextPropagator';
import { TextMapPropagator } from '../context/propagation/TextMapPropagator';
import { NOOP_TEXT_MAP_PROPAGATOR } from '../context/propagation/NoopTextMapPropagator';
import { defaultSetter, SetterFunction } from '../context/propagation/setter';
import { ContextAPI } from './context';
import {
Expand Down Expand Up @@ -50,9 +50,7 @@ export class PropagationAPI {
/**
* Set the current propagator. Returns the initialized propagator
*/
public setGlobalPropagator(
propagator: HttpTextPropagator
): HttpTextPropagator {
public setGlobalPropagator(propagator: TextMapPropagator): TextMapPropagator {
if (_global[GLOBAL_PROPAGATION_API_KEY]) {
// global propagator has already been set
return this._getGlobalPropagator();
Expand All @@ -61,7 +59,7 @@ export class PropagationAPI {
_global[GLOBAL_PROPAGATION_API_KEY] = makeGetter(
API_BACKWARDS_COMPATIBILITY_VERSION,
propagator,
NOOP_HTTP_TEXT_PROPAGATOR
NOOP_TEXT_MAP_PROPAGATOR
);

return propagator;
Expand Down Expand Up @@ -102,11 +100,11 @@ export class PropagationAPI {
delete _global[GLOBAL_PROPAGATION_API_KEY];
}

private _getGlobalPropagator(): HttpTextPropagator {
private _getGlobalPropagator(): TextMapPropagator {
return (
_global[GLOBAL_PROPAGATION_API_KEY]?.(
API_BACKWARDS_COMPATIBILITY_VERSION
) ?? NOOP_HTTP_TEXT_PROPAGATOR
) ?? NOOP_TEXT_MAP_PROPAGATOR
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/

import { Context } from '@opentelemetry/context-base';
import { HttpTextPropagator } from './HttpTextPropagator';
import { TextMapPropagator } from './TextMapPropagator';

/**
* No-op implementations of {@link HttpTextPropagator}.
* No-op implementations of {@link TextMapPropagator}.
*/
export class NoopHttpTextPropagator implements HttpTextPropagator {
export class NoopTextMapPropagator implements TextMapPropagator {
/** Noop inject function does nothing */
inject(context: Context, carrier: unknown, setter: Function): void {}
/** Noop extract function does nothing and returns the input context */
Expand All @@ -29,4 +29,4 @@ export class NoopHttpTextPropagator implements HttpTextPropagator {
}
}

export const NOOP_HTTP_TEXT_PROPAGATOR = new NoopHttpTextPropagator();
export const NOOP_TEXT_MAP_PROPAGATOR = new NoopTextMapPropagator();
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import { GetterFunction } from './getter';
* usually implemented via library-specific request interceptors, where the
* client-side injects values and the server-side extracts them.
*/
export interface HttpTextPropagator {
export interface TextMapPropagator {
/**
* Injects values from a given `Context` into a carrier.
*
* OpenTelemetry defines a common set of format values (HttpTextPropagator),
* OpenTelemetry defines a common set of format values (TextMapPropagator),
* and each has an expected `carrier` type.
*
* @param context the Context from which to extract values to transmit over
Expand Down
4 changes: 2 additions & 2 deletions api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export * from './common/Exception';
export * from './common/Logger';
export * from './common/Time';
export * from './context/propagation/getter';
export * from './context/propagation/HttpTextPropagator';
export * from './context/propagation/NoopHttpTextPropagator';
export * from './context/propagation/TextMapPropagator';
export * from './context/propagation/NoopTextMapPropagator';
export * from './context/propagation/setter';
export * from './correlation_context/CorrelationContext';
export * from './correlation_context/EntryValue';
Expand Down

0 comments on commit 2b6c32d

Please sign in to comment.