Skip to content

Commit

Permalink
add logging to text map propagator (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
rochdev authored Oct 10, 2018
1 parent 342be9e commit 2bcaf61
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
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

0 comments on commit 2bcaf61

Please sign in to comment.