Skip to content
Draft
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
28 changes: 27 additions & 1 deletion lib/tracing/cds.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,37 @@ module.exports = () => {
const { handle: _unboxed_handle } = unboxed
unboxed.handle = wrap(_unboxed_handle, {
wrapper: function handle(msg) {
if (msg.inbound) return _unboxed_handle.apply(this, arguments)
if (msg.inbound) {
// TODO: w3c trace context
return _unboxed_handle.apply(this, arguments)
}
const kind = service.kind !== 'local-messaging' ? SpanKind.PRODUCER : SpanKind.INTERNAL
return trace(msg, _unboxed_handle, this, arguments, { kind })
}
})

// // TODO: w3c trace context
// if (unboxed !== service) {
// const { handle: _outboxed_handle } = service
// service.handle = wrap(_outboxed_handle, {
// wrapper: function handle(msg) {
// if (!msg.inbound) {
// const spanContext = otel_trace.getActiveSpan().spanContext()
// // taken from W3CTraceContextPropagator
// const traceParent =
// VERSION +
// '-' +
// spanContext.traceId +
// '-' +
// spanContext.spanId +
// '-0' +
// Number(spanContext.traceFlags || TraceFlags.NONE).toString(16)
// msg.headers.traceparent = traceParent
// }
// return _outboxed_handle.apply(this, arguments)
// }
// })
// }
}
})

Expand Down