Skip to content

Commit 6afec51

Browse files
committed
fix userprocessor overwriting
1 parent 146a13c commit 6afec51

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

ddtrace/_trace/processor/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ def __init__(
271271
partial_flush_enabled: bool,
272272
partial_flush_min_spans: int,
273273
trace_processors: List[TraceProcessor],
274+
user_processors: Optional[List[TraceProcessor]] = None,
274275
):
275276
# Set partial flushing
276277
self.partial_flush_enabled = partial_flush_enabled
@@ -280,7 +281,8 @@ def __init__(
280281
config._trace_compute_stats, get_span_sampling_rules(), asm_config._apm_opt_out
281282
)
282283
self.tags_processor = TraceTagsProcessor()
283-
self.trace_processors = trace_processors
284+
self.trace_processors = trace_processors or []
285+
self.user_processors = user_processors or []
284286
if SpanAggregator._use_log_writer():
285287
self.writer: TraceWriter = LogWriter()
286288
else:
@@ -314,6 +316,8 @@ def __repr__(self) -> str:
314316
f"{self.sampling_processor},"
315317
f"{self.tags_processor},"
316318
f"{self.trace_processors}, "
319+
f"{self.user_processors}, "
320+
f"{self._span_metrics}, "
317321
f"{self.writer})"
318322
)
319323

@@ -375,7 +379,9 @@ def on_span_finish(self, span: Span) -> None:
375379
finished[0].set_metric("_dd.py.partial_flush", num_finished)
376380

377381
spans: Optional[List[Span]] = finished
378-
for tp in chain(self.trace_processors, [self.sampling_processor, self.tags_processor]):
382+
for tp in chain(
383+
self.trace_processors, self.user_processors, [self.sampling_processor, self.tags_processor]
384+
):
379385
try:
380386
if spans is None:
381387
return

ddtrace/_trace/tracer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def configure(
373373
self._span_aggregator.writer._api_version = "v0.4"
374374

375375
if trace_processors:
376-
self._span_aggregator.trace_processors = trace_processors
376+
self._span_aggregator.user_processors = trace_processors
377377

378378
if any(
379379
x is not None

ddtrace/internal/ci_visibility/recorder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ def disable(cls) -> None:
631631
log.debug("%s disabled", cls.__name__)
632632

633633
def _start_service(self) -> None:
634-
tracer_filters = self.tracer._span_aggregator.trace_processors
634+
tracer_filters = self.tracer._span_aggregator.user_processors
635635
if not any(isinstance(tracer_filter, TraceCiVisibilityFilter) for tracer_filter in tracer_filters):
636636
tracer_filters += [TraceCiVisibilityFilter(self._tags, self._service)] # type: ignore[arg-type]
637637
self.tracer.configure(trace_processors=tracer_filters)

ddtrace/opentracer/tracer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __init__(
104104
trace_processors = None
105105
if isinstance(self._config.get(keys.SETTINGS), dict) and self._config[keys.SETTINGS].get("FILTERS"): # type: ignore[union-attr]
106106
trace_processors = self._config[keys.SETTINGS]["FILTERS"] # type: ignore[index]
107-
self._dd_tracer._span_aggregator.trace_processors = trace_processors
107+
self._dd_tracer._span_aggregator.user_processors = trace_processors
108108

109109
if self._config[keys.ENABLED]:
110110
self._dd_tracer.enabled = self._config[keys.ENABLED]

0 commit comments

Comments
 (0)