-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(core): Ensure trace context only includes relevant data #11713
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
Conversation
packages/core/src/utils/spanUtils.ts
Outdated
export function spanToTraceContext(span: Span, includeAllData = false): TraceContext { | ||
const { spanId: span_id, traceId: trace_id } = span.spanContext(); | ||
const { data, op, parent_span_id, status, origin } = spanToJSON(span); | ||
|
||
return dropUndefinedKeys({ | ||
data, | ||
op, | ||
parent_span_id, | ||
span_id, | ||
status, | ||
trace_id, | ||
origin, | ||
}); | ||
const reqFields = { parent_span_id, span_id, trace_id }; | ||
// These are only included if `includeAllData` is true | ||
const optFields = { data, op, status, origin }; | ||
|
||
return dropUndefinedKeys(includeAllData ? { ...reqFields, ...optFields } : reqFields); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be heavily in favor of creating a separate function instead of passing a flag.
ie
- spanToTransactionTraceContext
- spanToTraceContext
or similar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reason being "includeAllData" is super undescriptive. What is not all data? Why would I use that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good to me! will update this.
size-limit report 📦
|
Today, we have different behavior for the
trace
context in core/browser & node:In Node, we made the change so that
contexts.trace
only containsspan_id
,trace_id
andparent_span_id
for non-transaction events.In contrast, in core/browser we are always adding the full span trace context, if there is an active span (including e.g. data, status, etc.)
This PR aligns this to use the node behavior everywhere.
Transaction events are unchanged by this PR.