@opentelemetry/propagator-jaeger
Advanced tools
Comparing version 1.0.1 to 1.1.0
import { Context, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api'; | ||
import { JaegerPropagatorConfig } from './types'; | ||
export declare const UBER_TRACE_ID_HEADER = "uber-trace-id"; | ||
@@ -21,6 +22,5 @@ export declare const UBER_BAGGAGE_HEADER_PREFIX = "uberctx"; | ||
private readonly _jaegerTraceHeader; | ||
/** | ||
* @param {string} [customTraceHeader="uber-trace-id"] - HTTP header to inject\extract trace from. | ||
**/ | ||
private readonly _jaegerBaggageHeaderPrefix; | ||
constructor(customTraceHeader?: string); | ||
constructor(config?: JaegerPropagatorConfig); | ||
inject(context: Context, carrier: unknown, setter: TextMapSetter): void; | ||
@@ -27,0 +27,0 @@ extract(context: Context, carrier: unknown, getter: TextMapGetter): Context; |
@@ -23,3 +23,2 @@ "use strict"; | ||
exports.UBER_BAGGAGE_HEADER_PREFIX = 'uberctx'; | ||
const UBER_BAGGAGE_HEADER_REGEX = /^uberctx-(.+)/i; | ||
/** | ||
@@ -41,7 +40,11 @@ * Propagates {@link SpanContext} through Trace Context format propagation. | ||
class JaegerPropagator { | ||
/** | ||
* @param {string} [customTraceHeader="uber-trace-id"] - HTTP header to inject\extract trace from. | ||
**/ | ||
constructor(customTraceHeader) { | ||
this._jaegerTraceHeader = customTraceHeader || exports.UBER_TRACE_ID_HEADER; | ||
constructor(config) { | ||
if (typeof config === 'string') { | ||
this._jaegerTraceHeader = config; | ||
this._jaegerBaggageHeaderPrefix = exports.UBER_BAGGAGE_HEADER_PREFIX; | ||
} | ||
else { | ||
this._jaegerTraceHeader = (config === null || config === void 0 ? void 0 : config.customTraceHeader) || exports.UBER_TRACE_ID_HEADER; | ||
this._jaegerBaggageHeaderPrefix = (config === null || config === void 0 ? void 0 : config.customBaggageHeaderPrefix) || exports.UBER_BAGGAGE_HEADER_PREFIX; | ||
} | ||
} | ||
@@ -51,3 +54,3 @@ inject(context, carrier, setter) { | ||
const baggage = api_1.propagation.getBaggage(context); | ||
if (spanContext && core_1.isTracingSuppressed(context) === false) { | ||
if (spanContext && (0, core_1.isTracingSuppressed)(context) === false) { | ||
const traceFlags = `0${(spanContext.traceFlags || api_1.TraceFlags.NONE).toString(16)}`; | ||
@@ -58,3 +61,3 @@ setter.set(carrier, this._jaegerTraceHeader, `${spanContext.traceId}:${spanContext.spanId}:0:${traceFlags}`); | ||
for (const [key, entry] of baggage.getAllEntries()) { | ||
setter.set(carrier, `${exports.UBER_BAGGAGE_HEADER_PREFIX}-${key}`, encodeURIComponent(entry.value)); | ||
setter.set(carrier, `${this._jaegerBaggageHeaderPrefix}-${key}`, encodeURIComponent(entry.value)); | ||
} | ||
@@ -71,7 +74,7 @@ } | ||
.keys(carrier) | ||
.filter(key => UBER_BAGGAGE_HEADER_REGEX.test(key)) | ||
.filter(key => key.startsWith(`${this._jaegerBaggageHeaderPrefix}-`)) | ||
.map(key => { | ||
const value = getter.get(carrier, key); | ||
return { | ||
key: key.substring(exports.UBER_BAGGAGE_HEADER_PREFIX.length + 1), | ||
key: key.substring(this._jaegerBaggageHeaderPrefix.length + 1), | ||
value: Array.isArray(value) ? value[0] : value, | ||
@@ -116,4 +119,5 @@ }; | ||
} | ||
const [_traceId, spanId, , flags] = headers; | ||
const [_traceId, _spanId, , flags] = headers; | ||
const traceId = _traceId.padStart(32, '0'); | ||
const spanId = _spanId.padStart(16, '0'); | ||
const traceFlags = flags.match(/^[0-9a-f]{2}$/i) ? parseInt(flags) & 1 : 1; | ||
@@ -120,0 +124,0 @@ return { traceId, spanId, isRemote: true, traceFlags }; |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "1.0.1"; | ||
export declare const VERSION = "1.1.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '1.0.1'; | ||
exports.VERSION = '1.1.0'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/propagator-jaeger", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "OpenTelemetry Jaeger propagator provides HTTP header propagation for systems that are using Jaeger HTTP header format.", | ||
@@ -22,3 +22,3 @@ "main": "build/src/index.js", | ||
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json", | ||
"precompile": "lerna run version --scope $(npm pkg get name) --include-filtered-dependencies", | ||
"precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies", | ||
"prewatch": "npm run precompile" | ||
@@ -53,10 +53,10 @@ }, | ||
"devDependencies": { | ||
"@opentelemetry/api": "~1.0.3", | ||
"@opentelemetry/api": "~1.1.0", | ||
"@types/mocha": "8.2.3", | ||
"@types/node": "14.17.11", | ||
"@types/sinon": "10.0.2", | ||
"@types/webpack-env": "1.16.2", | ||
"@types/node": "14.17.33", | ||
"@types/sinon": "10.0.6", | ||
"@types/webpack-env": "1.16.3", | ||
"codecov": "3.8.3", | ||
"istanbul-instrumenter-loader": "3.0.1", | ||
"karma": "6.3.7", | ||
"karma": "6.3.16", | ||
"karma-chrome-launcher": "3.1.0", | ||
@@ -73,12 +73,12 @@ "karma-coverage-istanbul-reporter": "3.0.3", | ||
"ts-mocha": "8.0.0", | ||
"typescript": "4.3.5", | ||
"typescript": "4.4.4", | ||
"webpack": "4.46.0" | ||
}, | ||
"peerDependencies": { | ||
"@opentelemetry/api": ">=1.0.0 <1.1.0" | ||
"@opentelemetry/api": ">=1.0.0 <1.2.0" | ||
}, | ||
"dependencies": { | ||
"@opentelemetry/core": "1.0.1" | ||
"@opentelemetry/core": "1.1.0" | ||
}, | ||
"gitHead": "9cf402ee4231ee1446884b5f59958ceafc1b5188" | ||
"gitHead": "f384303ac469914d0dbafde0758ccdae473f336e" | ||
} |
# OpenTelemetry Propagator Jaeger | ||
[![NPM Published Version][npm-img]][npm-url] | ||
[![dependencies][dependencies-image]][dependencies-url] | ||
[![devDependencies][devDependencies-image]][devDependencies-url] | ||
[![Apache License][license-image]][license-image] | ||
@@ -59,8 +57,4 @@ | ||
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat | ||
[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/status.svg?path=packages/opentelemetry-propagator-jaeger | ||
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-propagator-jaeger | ||
[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/dev-status.svg?path=packages/opentelemetry-propagator-jaeger | ||
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-propagator-jaeger&type=dev | ||
[npm-url]: https://www.npmjs.com/package/@opentelemetry/propagator-jaeger | ||
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fpropagator-jaeger.svg | ||
[fields-spec-url]: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/context/api-propagators.md#fields |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37116
15
218
60
+ Added@opentelemetry/api@1.1.0(transitive)
+ Added@opentelemetry/core@1.1.0(transitive)
+ Added@opentelemetry/semantic-conventions@1.1.0(transitive)
- Removed@opentelemetry/api@1.0.4(transitive)
- Removed@opentelemetry/core@1.0.1(transitive)
- Removed@opentelemetry/semantic-conventions@1.0.1(transitive)
Updated@opentelemetry/core@1.1.0