Skip to content

feat: propagate w3c in messaging #284

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

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
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