Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logging to text map propagator #305

Merged
merged 1 commit into from
Oct 10, 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 LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require,int64-buffer,MIT,Copyright 2015-2016 Yusuke Kawasaki
require,koalas,MIT,Copyright 2013-2017 Brian Woodward
require,lodash.kebabcase,MIT,Copyright JS Foundation and other contributors
require,lodash.memoize,MIT,Copyright JS Foundation and other contributors
require,lodash.pick,MIT,Copyright JS Foundation and other contributors
require,lodash.uniq,MIT,Copyright JS Foundation and other contributors
require,methods,MIT,Copyright 2013-2014 TJ Holowaychuk 2013-2014 TJ Holowaychuk
require,msgpack-lite,MIT,Copyright 2015 Yusuke Kawasaki
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"koalas": "^1.0.2",
"lodash.kebabcase": "^4.1.1",
"lodash.memoize": "^4.1.2",
"lodash.pick": "^4.4.0",
"lodash.uniq": "^4.5.0",
"methods": "^1.1.2",
"msgpack-lite": "^0.1.26",
Expand Down
7 changes: 7 additions & 0 deletions src/opentracing/propagation/text_map.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
'use strict'

const pick = require('lodash.pick')
const Uint64BE = require('int64-buffer').Uint64BE
const DatadogSpanContext = require('../span_context')
const log = require('../../log')

const traceKey = 'x-datadog-trace-id'
const spanKey = 'x-datadog-parent-id'
const samplingKey = 'x-datadog-sampling-priority'
const baggagePrefix = 'ot-baggage-'
const baggageExpr = new RegExp(`^${baggagePrefix}(.+)$`)
const logKeys = [traceKey, spanKey, samplingKey]

class TextMapPropagator {
inject (spanContext, carrier) {
Expand All @@ -16,6 +19,8 @@ class TextMapPropagator {

this._injectSamplingPriority(spanContext, carrier)
this._injectBaggageItems(spanContext, carrier)

log.debug(() => `Inject into carrier: ${JSON.stringify(pick(carrier, logKeys))}.`)
}

extract (carrier) {
Expand All @@ -31,6 +36,8 @@ class TextMapPropagator {
this._extractBaggageItems(carrier, spanContext)
this._extractSamplingPriority(carrier, spanContext)

log.debug(() => `Extract from carrier: ${JSON.stringify(pick(carrier, logKeys))}.`)

return spanContext
}

Expand Down