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

Add missed contextKey option to initTracer #308

Merged
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 @@ -225,6 +225,7 @@ export default class Configuration {
}

return new Tracer(config.serviceName, reporter, sampler, {
contextKey: options.contextKey,
metrics: options.metrics,
logger: options.logger,
tags: options.tags,
Expand Down
1 change: 1 addition & 0 deletions src/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default class Tracer {
* @param {Object} [options.metrics] - instance of the Metrics class from ./metrics/metrics.js.
* @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
* BaggageRestrictionManager API from ./baggage.js.
*/
constructor(
Expand Down
2 changes: 2 additions & 0 deletions test/init_tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,13 @@ describe('initTracer', () => {
tags: {
x: 'y',
},
contextKey: 'custom-header',
}
);
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');
tracer.close(done);
});

Expand Down