Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Allows to override codec's default baggage prefix. #310

Merged
merged 1 commit into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export default class Configuration {

return new Tracer(config.serviceName, reporter, sampler, {
contextKey: options.contextKey,
baggagePrefix: options.baggagePrefix,
metrics: options.metrics,
logger: options.logger,
tags: options.tags,
Expand Down
2 changes: 2 additions & 0 deletions src/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default class Tracer {
* @param {Object} [options.logger] - a logger matching NullLogger API from ./logger.js.
* @param {Object} [options.baggageRestrictionManager] - a baggageRestrictionManager matching
* @param {Object} [options.contextKey] - a name of the key to extract/inject context from headers
* @param {Object} [options.baggagePrefix] - a name of the context baggage key prefix
* BaggageRestrictionManager API from ./baggage.js.
*/
constructor(
Expand Down Expand Up @@ -84,6 +85,7 @@ export default class Tracer {

let codecOptions = {
contextKey: options.contextKey || null,
baggagePrefix: options.baggagePrefix || null,
urlEncoding: false,
metrics: this._metrics,
};
Expand Down
6 changes: 5 additions & 1 deletion test/init_tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,16 @@ describe('initTracer', () => {
x: 'y',
},
contextKey: 'custom-header',
baggagePrefix: 'prfx-',
}
);
assert.equal(tracer._logger, logger);
assert.equal(tracer._metrics._factory, metrics);
assert.equal(tracer._tags['x'], 'y');
assert.equal(tracer._injectors[opentracing.FORMAT_TEXT_MAP]._contextKey, 'custom-header');

const textMapInjector = tracer._injectors[opentracing.FORMAT_TEXT_MAP];
assert.equal(textMapInjector._contextKey, 'custom-header');
assert.equal(textMapInjector._baggagePrefix, 'prfx-');
tracer.close(done);
});

Expand Down