Skip to content

Commit

Permalink
chore: add typing to propagator carrier (open-telemetry#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored Feb 7, 2020
1 parent 0fc3ba3 commit 7c48b8e
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/JaegerHttpTraceFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* limitations under the License.
*/

import { SpanContext, HttpTextFormat, TraceFlags } from '@opentelemetry/api';
import {
SpanContext,
HttpTextFormat,
TraceFlags,
Carrier,
} from '@opentelemetry/api';

export const UBER_TRACE_ID_HEADER = 'uber-trace-id';

Expand Down Expand Up @@ -46,13 +51,9 @@ export class JaegerHttpTraceFormat implements HttpTextFormat {
/**
* @param {SpanContext} spanContext - context from which we take information to inject in carrier.
* @param {string} format - unused.
* @param { [key: string]: unknown } carrier - a carrier to which span information will be injected.
* @param {Carrier} carrier - a carrier to which span information will be injected.
**/
inject(
spanContext: SpanContext,
format: string,
carrier: { [key: string]: unknown }
) {
inject(spanContext: SpanContext, format: string, carrier: Carrier) {
const traceFlags = `0${(
spanContext.traceFlags || TraceFlags.UNSAMPLED
).toString(16)}`;
Expand All @@ -64,13 +65,10 @@ export class JaegerHttpTraceFormat implements HttpTextFormat {

/**
* @param {string} format - unused.
* @param { [key: string]: unknown } carrier - a carrier from which span context will be constructed.
* @param {Carrier} carrier - a carrier from which span context will be constructed.
* @return {SpanContext} - returns a span context extracted from carrier.
**/
extract(
format: string,
carrier: { [key: string]: unknown }
): SpanContext | null {
extract(format: string, carrier: Carrier): SpanContext | null {
const uberTraceIdHeader = carrier[this._jaegerTraceHeader];
if (!uberTraceIdHeader) return null;
const uberTraceId = Array.isArray(uberTraceIdHeader)
Expand Down

0 comments on commit 7c48b8e

Please sign in to comment.