You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Filters attributes for partial trace span events based on a given mode.
151
+
* Drops span or filters attributes based on partial trace rules for a given mode.
160
152
* The rules are as such:
161
-
* - If not a partial trace, return all attributes.
162
-
* - If an entry point span, return all attributes.
163
-
* - If an LLM span, return all attributes.
164
-
* - If not an exit span, return no attributes.
165
-
* - If mode is 'reduced' and there are entity relationship attributes, return all attributes.
166
-
* - Otherwise, return no attributes.
153
+
* - If not a partial trace, return span untouched
154
+
* - If an entry point span, return span untouched
155
+
* - If an LLM span, return span untouched
156
+
* - If not an exit span, return null(aka drop span)
157
+
* - If mode is 'reduced' and there are entity relationship attributes, return span untouched
158
+
* - If mode is 'essential' and there are entity relationship attributes or error attributes, return span with only those attributes, drop custom attributes
159
+
* - Otherwise return null(aka drop span)
167
160
*
168
161
* @param {object} params to function
169
-
* @param {TraceSegment} params.segment segment to filter attributes from
170
-
* @param {SpanContext} params.spanContext span context to filter attributes from
162
+
* @param {SpanEvent} params.span span to apply rules to
171
163
* @param {boolean} params.entryPoint whether the span is an entry point
logger.trace('Span %s is either not a partial trace: %s, an entry point: %s, or an LLM span: %s, keeping span unchanged.',span.intrinsics.name,isPartialTrace,entryPoint,isLlmSpan)
173
+
returnspan
181
174
}
182
175
183
-
if(!SpanEvent.isExitSpan(segment)){
184
-
return{dropSpan: true}
176
+
if(!SpanEvent.isExitSpan(span)){
177
+
logger.trace('Span %s is not an exit span and trace is partial granularity mode: %s.',span.intrinsics.name,partialGranularityMode)
logger.trace('Span %s does not contain any entity relationship attributes %j and trace is partial granularity mode: %s, dropping span.',span.intrinsics.name,span.attributes,partialGranularityMode)
187
+
returnnull
192
188
}
189
+
logger.trace('Span %s contains entity relationship attributes and trace is partial granularity mode: %s, keeping span unchanged.',span.intrinsics.name,partialGranularityMode)
logger.trace('Span %s does not contain any entity relationship attributes %j and trace is partial granularity mode: %s, dropping span.',span.intrinsics.name,span.attributes,partialGranularityMode)
200
+
returnnull
203
201
}
202
+
203
+
span.attributes=attributesToKeep
204
+
span.customAttributes=Object.create(null)
205
+
logger.trace('Span %s contains entity relationship attributes and trace is partial granularity mode: %s, only keeping entity relationship attributes and removing custom attributes.',span.intrinsics.name,partialGranularityMode)
0 commit comments