Skip to content

Commit cbed775

Browse files
committed
added to all
1 parent 49e5bb8 commit cbed775

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/traceloop-sdk/src/lib/tracing/association.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,16 @@ export function withAssociationProperties<
1414
return fn.apply(thisArg, args);
1515
}
1616

17+
// Get existing associations from context and merge with new properties
18+
const existingAssociations = context
19+
.active()
20+
.getValue(ASSOCATION_PROPERTIES_KEY) as Record<string, string> | undefined;
21+
const mergedAssociations = existingAssociations
22+
? { ...existingAssociations, ...properties }
23+
: properties;
24+
1725
const newContext = context
1826
.active()
19-
.setValue(ASSOCATION_PROPERTIES_KEY, properties);
27+
.setValue(ASSOCATION_PROPERTIES_KEY, mergedAssociations);
2028
return context.with(newContext, fn, thisArg, ...args);
2129
}

packages/traceloop-sdk/src/lib/tracing/associations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export class Associations {
7777
}
7878
}
7979

80-
// Also set directly on the current span
81-
const span = trace.getSpan(otelContext.active());
80+
// Also set directly on the current span (use newContext after enterWith)
81+
const span = trace.getSpan(newContext);
8282
if (span && span.isRecording()) {
8383
for (const [prop, value] of associations) {
8484
span.setAttribute(prop, value);

0 commit comments

Comments
 (0)