diff --git a/ddtrace/_trace/processor/__init__.py b/ddtrace/_trace/processor/__init__.py index 21d728d2f52..8957f4417d1 100644 --- a/ddtrace/_trace/processor/__init__.py +++ b/ddtrace/_trace/processor/__init__.py @@ -302,7 +302,6 @@ def __init__( partial_flush_enabled: bool, partial_flush_min_spans: int, dd_processors: Optional[List[TraceProcessor]] = None, - user_processors: Optional[List[TraceProcessor]] = None, ): # Set partial flushing self.partial_flush_enabled = partial_flush_enabled @@ -313,7 +312,7 @@ def __init__( ) self.tags_processor = TraceTagsProcessor() self.dd_processors = dd_processors or [] - self.user_processors = user_processors or [] + self.user_processors: List[TraceProcessor] = [] self.service_name_processor = ServiceNameProcessor() self.writer = create_trace_writer(response_callback=self._agent_response_callback) # Initialize the trace buffer and lock diff --git a/ddtrace/_trace/tracer.py b/ddtrace/_trace/tracer.py index d2d6201636e..1b9b552f870 100644 --- a/ddtrace/_trace/tracer.py +++ b/ddtrace/_trace/tracer.py @@ -60,6 +60,7 @@ from ddtrace.settings._config import config from ddtrace.settings.asm import config as asm_config from ddtrace.settings.peer_service import _ps_config +from ddtrace.vendor.debtcollector import deprecate from ddtrace.vendor.debtcollector.removals import remove from ddtrace.version import get_version @@ -230,6 +231,14 @@ def deregister_on_start_span(self, func: Callable[[Span], None]) -> Callable[[Sp core.reset_listeners("trace.span_start", callback=func) return func + @property + def processors(self) -> List[TraceProcessor]: + return self._span_aggregator.user_processors + + @processors.setter + def processors(self, value: List[TraceProcessor]): + self._span_aggregator.user_processors = value + def sample(self, span): self._sampler.sample(span) @@ -306,6 +315,7 @@ def configure( iast_enabled: Optional[bool] = None, apm_tracing_disabled: Optional[bool] = None, trace_processors: Optional[List[TraceProcessor]] = None, + apm_tracing_enabled: Optional[bool] = None, ) -> None: """Configure a Tracer. @@ -314,9 +324,9 @@ def configure( doesn't need to be changed from the default value. :param bool appsec_enabled: Enables Application Security Monitoring (ASM) for the tracer. :param bool iast_enabled: Enables IAST support for the tracer - :param bool apm_tracing_disabled: When APM tracing is disabled ensures ASM support is still enabled. - :param List[TraceProcessor] trace_processors: This parameter sets TraceProcessor (ex: TraceFilters). - Trace processors are used to modify and filter traces based on certain criteria. + :param bool apm_tracing_disabled: Deprecated. Use `apm_tracing_enabled` instead. + :param bool apm_tracing_enabled: Enables/Disables the submission of traces to the Datadog Agent. + :param List[TraceProcessor] trace_processors: Deprecated. Use `tracer.processors` property instead. """ if appsec_enabled is not None: @@ -328,7 +338,15 @@ def configure( asm_config._iast_enabled = iast_enabled if apm_tracing_disabled is not None: + deprecate( + prefix="tracer.configure(apm_tracing_disabled=...) is deprecated", + message="Use tracer.configure(apm_tracing_enabled=...) instead.", + category=DDTraceDeprecationWarning, + removal_version="4.0.0", + ) asm_config._apm_tracing_enabled = not apm_tracing_disabled + if apm_tracing_enabled is not None: + asm_config._apm_tracing_enabled = apm_tracing_enabled if asm_config._apm_opt_out: config._tracing_enabled = self.enabled = False @@ -341,21 +359,33 @@ def configure( if compute_stats_enabled is not None: config._trace_compute_stats = compute_stats_enabled + if trace_processors is not None: + deprecate( + prefix="tracer.configure(trace_processors=...) is deprecated", + message="Use tracer.processors property instead.", + category=DDTraceDeprecationWarning, + removal_version="4.0.0", + ) + self.processors = trace_processors + + if context_provider is not None: + deprecate( + prefix="tracer.configure(context_provider=...) is deprecated", + message="Use tracer.context_provider property instead.", + category=DDTraceDeprecationWarning, + removal_version="4.0.0", + ) + self.context_provider = context_provider + if any( x is not None for x in [ - trace_processors, compute_stats_enabled, appsec_enabled, iast_enabled, ] ): - self._recreate( - trace_processors, compute_stats_enabled, asm_config._apm_opt_out, appsec_enabled, reset_buffer=False - ) - - if context_provider is not None: - self.context_provider = context_provider + self._recreate(compute_stats_enabled, asm_config._apm_opt_out, appsec_enabled, reset_buffer=False) def _generate_diagnostic_logs(self): if config._debug_mode or config._startup_logs_enabled: @@ -383,7 +413,6 @@ def _child_after_fork(self): def _recreate( self, - trace_processors: Optional[List[TraceProcessor]] = None, compute_stats_enabled: Optional[bool] = None, apm_opt_out: Optional[bool] = None, appsec_enabled: Optional[bool] = None, @@ -393,7 +422,6 @@ def _recreate( # Stop the writer. # This will stop the periodic thread in HTTPWriters, preventing memory leaks and unnecessary I/O. self._span_aggregator.reset( - user_processors=trace_processors, compute_stats=compute_stats_enabled, apm_opt_out=apm_opt_out, appsec_enabled=appsec_enabled, diff --git a/ddtrace/contrib/internal/tornado/application.py b/ddtrace/contrib/internal/tornado/application.py index fed41c0d3d9..88e9d4c1e10 100644 --- a/ddtrace/contrib/internal/tornado/application.py +++ b/ddtrace/contrib/internal/tornado/application.py @@ -39,10 +39,8 @@ def tracer_config(__init__, app, args, kwargs): # TODO: Remove `FILTERS` from supported settings trace_processors = settings.get("settings", {}).get("FILTERS") - tracer.configure( - context_provider=context_provider, - trace_processors=trace_processors, - ) + tracer.processors = trace_processors + tracer.context_provider = context_provider tracer._wrap_executor = decorators.wrap_executor # TODO: Remove `enabled`, `hostname` and `port` settings in v4.0 # Tracer should be configured via environment variables diff --git a/ddtrace/internal/ci_visibility/recorder.py b/ddtrace/internal/ci_visibility/recorder.py index a68740fe69a..dad8571a4ec 100644 --- a/ddtrace/internal/ci_visibility/recorder.py +++ b/ddtrace/internal/ci_visibility/recorder.py @@ -656,7 +656,7 @@ def _start_service(self) -> None: tracer_filters = self.tracer._span_aggregator.user_processors if not any(isinstance(tracer_filter, TraceCiVisibilityFilter) for tracer_filter in tracer_filters): tracer_filters += [TraceCiVisibilityFilter(self._tags, self._service)] # type: ignore[arg-type] - self.tracer.configure(trace_processors=tracer_filters) + self.tracer.processors = tracer_filters if asbool(os.getenv("DD_CIVISIBILITY_USE_BETA_WRITER")): self._set_global_span_forwarder(CIVisibilitySpanForwarder(self.tracer)) @@ -734,7 +734,7 @@ def _set_global_span_forwarder(self, span_forwarder: Optional[TraceFilter]) -> N tracer_filters = [tf for tf in tracer_filters if not isinstance(tf, CIVisibilitySpanForwarder)] if span_forwarder: tracer_filters.append(span_forwarder) - ddtrace.tracer.configure(trace_processors=tracer_filters) + ddtrace.tracer.processors = tracer_filters @classmethod def set_codeowners_of(cls, location, span=None): diff --git a/releasenotes/notes/update-tracer-configure-190952ff70420bda.yaml b/releasenotes/notes/update-tracer-configure-190952ff70420bda.yaml new file mode 100644 index 00000000000..4dcbd52478e --- /dev/null +++ b/releasenotes/notes/update-tracer-configure-190952ff70420bda.yaml @@ -0,0 +1,9 @@ +--- +deprecations: + - | + tracing: The following tracer.configure() parameters have been deprecated: + - `trace_processors` - use `tracer.processors` property instead + - `apm_tracing_disabled` - use `tracer.configure(apm_tracing_enabled=...)` instead + - `context_provider` - use `tracer.context_provider` property instead + + These will be removed in ddtrace 4.0.0. Other configure() parameters remain supported. \ No newline at end of file diff --git a/tests/appsec/appsec/test_asm_standalone.py b/tests/appsec/appsec/test_asm_standalone.py index c7cb625388a..89260a385cc 100644 --- a/tests/appsec/appsec/test_asm_standalone.py +++ b/tests/appsec/appsec/test_asm_standalone.py @@ -11,7 +11,7 @@ @pytest.fixture( params=[ - {"DD_APPSEC_SCA_ENABLED": sca, "iast_enabled": iast, "appsec_enabled": appsec, "apm_tracing_disabled": apm} + {"DD_APPSEC_SCA_ENABLED": sca, "iast_enabled": iast, "appsec_enabled": appsec, "apm_tracing_enabled": apm} for sca in ["1", "0"] for iast in [True, False] for appsec in [True, False] @@ -37,7 +37,7 @@ def tracer_appsec_standalone(request, tracer): # Reset tracer configuration ddtrace.config._reset() - tracer.configure(appsec_enabled=False, apm_tracing_disabled=False, iast_enabled=False) + tracer.configure(appsec_enabled=False, apm_tracing_enabled=True, iast_enabled=False) def test_appsec_standalone_apm_enabled_metric(tracer_appsec_standalone): @@ -46,7 +46,7 @@ def test_appsec_standalone_apm_enabled_metric(tracer_appsec_standalone): with tracer.trace("test", span_type=SpanTypes.WEB) as span: set_http_meta(span, {}, raw_uri="http://example.com/.git", status_code="404") - if args.get("apm_tracing_disabled", None) and ( + if args.get("apm_tracing_enabled", None) and ( args.get("appsec_enabled", None) or args.get("iast_enabled", None) or args.get("DD_APPSEC_SCA_ENABLED", "0") == "1" diff --git a/tests/appsec/contrib_appsec/django_app/settings.py b/tests/appsec/contrib_appsec/django_app/settings.py index c28e5ff126d..576814dfe24 100644 --- a/tests/appsec/contrib_appsec/django_app/settings.py +++ b/tests/appsec/contrib_appsec/django_app/settings.py @@ -6,7 +6,7 @@ from tests.webclient import PingFilter -tracer.configure(trace_processors=[PingFilter()]) +tracer.processors = [PingFilter()] ALLOWED_HOSTS = [ diff --git a/tests/appsec/contrib_appsec/flask_app/app.py b/tests/appsec/contrib_appsec/flask_app/app.py index 9ac1f333039..604562f1054 100644 --- a/tests/appsec/contrib_appsec/flask_app/app.py +++ b/tests/appsec/contrib_appsec/flask_app/app.py @@ -15,7 +15,7 @@ from tests.webclient import PingFilter -tracer.configure(trace_processors=[PingFilter()]) +tracer.processors = [PingFilter()] cur_dir = os.path.dirname(os.path.realpath(__file__)) tmpl_path = os.path.join(cur_dir, "test_templates") app = Flask(__name__, template_folder=tmpl_path) diff --git a/tests/appsec/integrations/django_tests/django_app/settings.py b/tests/appsec/integrations/django_tests/django_app/settings.py index 4f874351fad..814b24c5006 100644 --- a/tests/appsec/integrations/django_tests/django_app/settings.py +++ b/tests/appsec/integrations/django_tests/django_app/settings.py @@ -6,7 +6,7 @@ from tests.webclient import PingFilter -tracer.configure(trace_processors=[PingFilter()]) +tracer.processors = [PingFilter()] ALLOWED_HOSTS = [ "testserver", diff --git a/tests/contrib/django/django_app/settings.py b/tests/contrib/django/django_app/settings.py index b2d98ad6b6b..4de0c2508ef 100644 --- a/tests/contrib/django/django_app/settings.py +++ b/tests/contrib/django/django_app/settings.py @@ -6,7 +6,7 @@ from tests.webclient import PingFilter -tracer.configure(trace_processors=[PingFilter()]) +tracer.processors = [PingFilter()] ALLOWED_HOSTS = [ diff --git a/tests/contrib/flask/app.py b/tests/contrib/flask/app.py index 22048c2cc92..7b8b9864022 100644 --- a/tests/contrib/flask/app.py +++ b/tests/contrib/flask/app.py @@ -12,7 +12,7 @@ from tests.webclient import PingFilter -tracer.configure(trace_processors=[PingFilter()]) +tracer.processors = [PingFilter()] cur_dir = os.path.dirname(os.path.realpath(__file__)) tmpl_path = os.path.join(cur_dir, "test_templates") app = Flask(__name__, template_folder=tmpl_path) diff --git a/tests/contrib/gunicorn/wsgi_mw_app.py b/tests/contrib/gunicorn/wsgi_mw_app.py index f9d85166337..db02871e7c0 100644 --- a/tests/contrib/gunicorn/wsgi_mw_app.py +++ b/tests/contrib/gunicorn/wsgi_mw_app.py @@ -18,7 +18,7 @@ from tests.webclient import PingFilter -tracer.configure(trace_processors=[PingFilter()]) +tracer.processors = [PingFilter()] def aggressive_shutdown(): diff --git a/tests/contrib/kafka/test_kafka.py b/tests/contrib/kafka/test_kafka.py index 2abbff439fe..c1ef4f1df38 100644 --- a/tests/contrib/kafka/test_kafka.py +++ b/tests/contrib/kafka/test_kafka.py @@ -110,7 +110,7 @@ def should_filter_empty_polls(): def tracer(should_filter_empty_polls): patch() if should_filter_empty_polls: - ddtracer.configure(trace_processors=[KafkaConsumerPollFilter()]) + ddtracer.processors = [KafkaConsumerPollFilter()] # disable backoff because it makes these tests less reliable if not config._trace_writer_native: previous_backoff = ddtracer._span_aggregator.writer._send_payload_with_backoff @@ -554,7 +554,7 @@ def _generate_in_subprocess(random_topic): PAYLOAD = bytes("hueh hueh hueh", encoding="utf-8") - ddtrace.tracer.configure(trace_processors=[KafkaConsumerPollFilter()]) + ddtrace.tracer.processors = [KafkaConsumerPollFilter()] # disable backoff because it makes these tests less reliable if not config._trace_writer_native: ddtrace.tracer._span_aggregator.writer._send_payload_with_backoff = ( diff --git a/tests/contrib/openai/conftest.py b/tests/contrib/openai/conftest.py index 728e7653a14..c0e9d221e83 100644 --- a/tests/contrib/openai/conftest.py +++ b/tests/contrib/openai/conftest.py @@ -137,7 +137,7 @@ def patch_openai(ddtrace_global_config, ddtrace_config_openai, openai_api_key, o @pytest.fixture def snapshot_tracer(openai, patch_openai): pin = Pin.get_from(openai) - pin.tracer.configure(trace_processors=[FilterOrg()]) + pin.tracer.processors = [FilterOrg()] yield pin.tracer @@ -147,7 +147,7 @@ def mock_tracer(ddtrace_global_config, openai, patch_openai): pin = Pin.get_from(openai) mock_tracer = DummyTracer(writer=DummyWriter(trace_flush_enabled=False)) pin._override(openai, tracer=mock_tracer) - pin.tracer.configure(trace_processors=[FilterOrg()]) + pin.tracer.processors = [FilterOrg()] if ddtrace_global_config.get("_llmobs_enabled", False): # Have to disable and re-enable LLMObs to use to mock tracer. diff --git a/tests/contrib/openai/test_openai_v1.py b/tests/contrib/openai/test_openai_v1.py index 3d9f7a0b9c7..ddaf3e62bfe 100644 --- a/tests/contrib/openai/test_openai_v1.py +++ b/tests/contrib/openai/test_openai_v1.py @@ -855,7 +855,7 @@ def test_integration_sync(openai_api_key, ddtrace_run_python_code_in_subprocess) from tests.contrib.openai.conftest import FilterOrg from tests.contrib.openai.test_openai_v1 import get_openai_vcr pin = ddtrace.trace.Pin.get_from(openai) -pin.tracer.configure(trace_processors=[FilterOrg()]) +pin.tracer.processors = [FilterOrg()] with get_openai_vcr(subdirectory_name="v1").use_cassette("completion.yaml"): client = openai.OpenAI() resp = client.completions.create( @@ -896,7 +896,7 @@ def test_integration_async(openai_api_key, ddtrace_run_python_code_in_subprocess from tests.contrib.openai.conftest import FilterOrg from tests.contrib.openai.test_openai_v1 import get_openai_vcr pin = ddtrace.trace.Pin.get_from(openai) -pin.tracer.configure(trace_processors=[FilterOrg()]) +pin.tracer.processors = [FilterOrg()] async def task(): with get_openai_vcr(subdirectory_name="v1").use_cassette("completion.yaml"): client = openai.AsyncOpenAI() @@ -1099,7 +1099,7 @@ def test_integration_service_name(openai_api_key, ddtrace_run_python_code_in_sub from tests.contrib.openai.conftest import FilterOrg from tests.contrib.openai.test_openai_v1 import get_openai_vcr pin = ddtrace.trace.Pin.get_from(openai) -pin.tracer.configure(trace_processors=[FilterOrg()]) +pin.tracer.processors = [FilterOrg()] with get_openai_vcr(subdirectory_name="v1").use_cassette("completion.yaml"): client = openai.OpenAI() resp = client.completions.create(model="ada", prompt="hello world") diff --git a/tests/contrib/pyramid/app/app.py b/tests/contrib/pyramid/app/app.py index 5566ca47add..847699480f6 100644 --- a/tests/contrib/pyramid/app/app.py +++ b/tests/contrib/pyramid/app/app.py @@ -7,7 +7,7 @@ from tests.webclient import PingFilter -tracer.configure(trace_processors=[PingFilter()]) +tracer.processors = [PingFilter()] def hello_world(request): diff --git a/tests/contrib/pyramid/pserve_app/app/__init__.py b/tests/contrib/pyramid/pserve_app/app/__init__.py index 7f87d563c7a..16992d8d597 100644 --- a/tests/contrib/pyramid/pserve_app/app/__init__.py +++ b/tests/contrib/pyramid/pserve_app/app/__init__.py @@ -13,7 +13,7 @@ def process_trace(self, trace): return None if trace and trace[0].trace_id == 1 else trace -tracer.configure(trace_processors=[PingFilter()]) +tracer.processors = [PingFilter()] def tracer_shutdown(request): diff --git a/tests/contrib/sanic/run_server.py b/tests/contrib/sanic/run_server.py index 88b957486d8..296195e5a29 100644 --- a/tests/contrib/sanic/run_server.py +++ b/tests/contrib/sanic/run_server.py @@ -9,7 +9,7 @@ from tests.webclient import PingFilter -tracer.configure(trace_processors=[PingFilter()]) +tracer.processors = [PingFilter()] app = Sanic("test_sanic_server") diff --git a/tests/contrib/urllib3/test_urllib3.py b/tests/contrib/urllib3/test_urllib3.py index 01d3b87893c..3c001227a42 100644 --- a/tests/contrib/urllib3/test_urllib3.py +++ b/tests/contrib/urllib3/test_urllib3.py @@ -536,7 +536,7 @@ def test_distributed_tracing_apm_opt_out_true(self): config.urllib3["distributed_tracing"] = True self.tracer.enabled = False # Ensure the ASM SpanProcessor is set - self.tracer.configure(apm_tracing_disabled=True, appsec_enabled=True) + self.tracer.configure(apm_tracing_enabled=False, appsec_enabled=True) assert asm_config._apm_opt_out with mock.patch( "urllib3.connectionpool.HTTPConnectionPool._make_request", side_effect=ValueError @@ -585,7 +585,7 @@ def test_distributed_tracing_apm_opt_out_false(self): """Test with distributed tracing disabled does not propagate the headers""" config.urllib3["distributed_tracing"] = True # Ensure the ASM SpanProcessor is set. - self.tracer.configure(apm_tracing_disabled=False, appsec_enabled=True) + self.tracer.configure(apm_tracing_enabled=True, appsec_enabled=True) self.tracer.enabled = False assert not asm_config._apm_opt_out with mock.patch( diff --git a/tests/integration/test_integration_snapshots.py b/tests/integration/test_integration_snapshots.py index 8bb70cf70a6..dc5c44be897 100644 --- a/tests/integration/test_integration_snapshots.py +++ b/tests/integration/test_integration_snapshots.py @@ -91,7 +91,7 @@ def process_trace(self, trace): s.set_tag(self.key, self.value) return trace - tracer.configure(trace_processors=[FilterMutate("boop", "beep")]) + tracer.processors = [FilterMutate("boop", "beep")] with tracer.trace("root"): with tracer.trace("child"): diff --git a/tests/integration/test_priority_sampling.py b/tests/integration/test_priority_sampling.py index d80084b8d4b..cb97d81a049 100644 --- a/tests/integration/test_priority_sampling.py +++ b/tests/integration/test_priority_sampling.py @@ -173,7 +173,7 @@ def process_trace(self, trace): return None return trace - t.configure(trace_processors=[CustomFilter()]) # Triggers AgentWriter recreate + t.processors = [CustomFilter()] # Triggers AgentWriter recreate assert ( t._span_aggregator.sampling_processor.sampler._agent_based_samplers == agent_based_samplers ), f"Expected agent sampling rules to be set to {agent_based_samplers}, " diff --git a/tests/opentelemetry/flask_app.py b/tests/opentelemetry/flask_app.py index 07ee07fc5a0..073a3fdfca0 100644 --- a/tests/opentelemetry/flask_app.py +++ b/tests/opentelemetry/flask_app.py @@ -10,7 +10,7 @@ opentelemetry.trace.set_tracer_provider(TracerProvider()) -ddtrace.tracer.configure(trace_processors=[PingFilter()]) +ddtrace.tracer.processors = [PingFilter()] app = flask.Flask(__name__) diff --git a/tests/telemetry/test_telemetry.py b/tests/telemetry/test_telemetry.py index 9a439f5a6e3..f870ea201a7 100644 --- a/tests/telemetry/test_telemetry.py +++ b/tests/telemetry/test_telemetry.py @@ -153,7 +153,7 @@ class FailingFilture(TraceFilter): def process_trace(self, trace): raise Exception("Exception raised in trace filter") -tracer.configure(trace_processors=[FailingFilture()]) +tracer.processors = [FailingFilture()] # generate and encode span to trigger sampling failure tracer.trace("hello").finish() diff --git a/tests/tracer/runtime/test_tag_collectors.py b/tests/tracer/runtime/test_tag_collectors.py index b536d41e99f..f8c636ee638 100644 --- a/tests/tracer/runtime/test_tag_collectors.py +++ b/tests/tracer/runtime/test_tag_collectors.py @@ -85,7 +85,7 @@ def process_trace(self, _): return None # Drop all traces so we don't get an error trying to flush - ddtrace.tracer.configure(trace_processors=[DropFilter()]) + ddtrace.tracer.processors = [DropFilter()] ddtrace.config.service = "my-service" diff --git a/tests/tracer/test_processors.py b/tests/tracer/test_processors.py index a737da92a47..3b80c4bd617 100644 --- a/tests/tracer/test_processors.py +++ b/tests/tracer/test_processors.py @@ -94,8 +94,8 @@ def process_trace(self, trace): partial_flush_enabled=False, partial_flush_min_spans=0, dd_processors=[Proc()], - user_processors=[UserProc()], ) + aggr.user_processors = [UserProc()] with Span("span", on_finish=[aggr.on_span_finish]) as span: aggr.on_span_start(span) @@ -116,8 +116,8 @@ def test_aggregator_reset_default_args(): partial_flush_enabled=False, partial_flush_min_spans=1, dd_processors=[dd_proc], - user_processors=[user_proc], ) + aggr.user_processors = [user_proc] sampling_proc = aggr.sampling_processor dm_writer = DummyWriter() aggr.writer = dm_writer @@ -152,8 +152,8 @@ def test_aggregator_reset_apm_opt_out_preserves_sampling(): partial_flush_enabled=False, partial_flush_min_spans=1, dd_processors=[dd_proc], - user_processors=[user_proc], ) + aggr.user_processors = [user_proc] sampling_proc = aggr.sampling_processor original_apm_opt_out = sampling_proc.apm_opt_out @@ -187,8 +187,8 @@ def test_aggregator_reset_with_args(writer_class): partial_flush_enabled=False, partial_flush_min_spans=1, dd_processors=[dd_proc], - user_processors=[user_proc], ) + aggr.user_processors = [user_proc] aggr.writer = writer_class("http://localhost:8126", api_version="v0.5") span = Span("span", on_finish=[aggr.on_span_finish]) diff --git a/tests/tracer/test_propagation.py b/tests/tracer/test_propagation.py index 9232d4c2f20..aa3787a3379 100644 --- a/tests/tracer/test_propagation.py +++ b/tests/tracer/test_propagation.py @@ -332,7 +332,7 @@ def test_asm_standalone_minimum_trace_per_minute_has_no_downstream_propagation( with override_env({"DD_APPSEC_SCA_ENABLED": sca_enabled}): ddtrace.config._reset() - tracer.configure(appsec_enabled=appsec_enabled, apm_tracing_disabled=True, iast_enabled=iast_enabled) + tracer.configure(appsec_enabled=appsec_enabled, apm_tracing_enabled=False, iast_enabled=iast_enabled) try: headers = { "x-datadog-trace-id": "1234", @@ -375,7 +375,7 @@ def test_asm_standalone_minimum_trace_per_minute_has_no_downstream_propagation( finally: with override_env({"DD_APPSEC_SCA_ENABLED": "0"}): ddtrace.config._reset() - tracer.configure(appsec_enabled=False, apm_tracing_disabled=False, iast_enabled=False) + tracer.configure(appsec_enabled=False, apm_tracing_enabled=True, iast_enabled=False) @pytest.mark.parametrize("sca_enabled", ["true", "false"]) @@ -390,7 +390,7 @@ def test_asm_standalone_missing_propagation_tags_no_appsec_event_trace_dropped( with override_env({"DD_APPSEC_SCA_ENABLED": sca_enabled}): ddtrace.config._reset() - tracer.configure(appsec_enabled=appsec_enabled, apm_tracing_disabled=True, iast_enabled=iast_enabled) + tracer.configure(appsec_enabled=appsec_enabled, apm_tracing_enabled=False, iast_enabled=iast_enabled) try: with tracer.trace("local_root_span0"): # First span should be kept, as we keep 1 per min @@ -420,11 +420,11 @@ def test_asm_standalone_missing_propagation_tags_no_appsec_event_trace_dropped( finally: with override_env({"DD_APPSEC_SCA_ENABLED": "0"}): ddtrace.config._reset() - tracer.configure(appsec_enabled=False, apm_tracing_disabled=False, iast_enabled=False) + tracer.configure(appsec_enabled=False, apm_tracing_enabled=True, iast_enabled=False) def test_asm_standalone_missing_propagation_tags_appsec_event_present_trace_kept(tracer): # noqa: F811 - tracer.configure(appsec_enabled=True, apm_tracing_disabled=True) + tracer.configure(appsec_enabled=True, apm_tracing_enabled=False) try: with tracer.trace("local_root_span0"): # First span should be kept, as we keep 1 per min @@ -454,7 +454,7 @@ def test_asm_standalone_missing_propagation_tags_appsec_event_present_trace_kept # Ensure span is user keep assert span._metrics["_sampling_priority_v1"] == USER_KEEP finally: - tracer.configure(appsec_enabled=False, apm_tracing_disabled=False, iast_enabled=False) + tracer.configure(appsec_enabled=False, apm_tracing_enabled=True, iast_enabled=False) @pytest.mark.parametrize("sca_enabled", ["true", "false"]) @@ -468,7 +468,7 @@ def test_asm_standalone_missing_appsec_tag_no_appsec_event_propagation_resets( with override_env({"DD_APPSEC_SCA_ENABLED": sca_enabled}): ddtrace.config._reset() - tracer.configure(appsec_enabled=appsec_enabled, apm_tracing_disabled=True, iast_enabled=iast_enabled) + tracer.configure(appsec_enabled=appsec_enabled, apm_tracing_enabled=False, iast_enabled=iast_enabled) try: with tracer.trace("local_root_span0"): # First span should be kept, as we keep 1 per min @@ -513,13 +513,13 @@ def test_asm_standalone_missing_appsec_tag_no_appsec_event_propagation_resets( finally: with override_env({"DD_APPSEC_SCA_ENABLED": "false"}): ddtrace.config._reset() - tracer.configure(appsec_enabled=False, apm_tracing_disabled=False, iast_enabled=False) + tracer.configure(appsec_enabled=False, apm_tracing_enabled=True, iast_enabled=False) def test_asm_standalone_missing_appsec_tag_appsec_event_present_trace_kept( tracer, # noqa: F811 ): - tracer.configure(appsec_enabled=True, apm_tracing_disabled=True) + tracer.configure(appsec_enabled=True, apm_tracing_enabled=False) try: with tracer.trace("local_root_span0"): # First span should be kept, as we keep 1 per min @@ -561,7 +561,7 @@ def test_asm_standalone_missing_appsec_tag_appsec_event_present_trace_kept( assert span._metrics["_sampling_priority_v1"] == USER_KEEP finally: - tracer.configure(appsec_enabled=False, apm_tracing_disabled=False, iast_enabled=False) + tracer.configure(appsec_enabled=False, apm_tracing_enabled=True, iast_enabled=False) @pytest.mark.parametrize("upstream_priority", ["1", "2"]) @@ -576,7 +576,7 @@ def test_asm_standalone_present_appsec_tag_no_appsec_event_propagation_set_to_us with override_env({"DD_APPSEC_SCA_ENABLED": sca_enabled}): ddtrace.config._reset() - tracer.configure(appsec_enabled=appsec_enabled, apm_tracing_disabled=True, iast_enabled=iast_enabled) + tracer.configure(appsec_enabled=appsec_enabled, apm_tracing_enabled=False, iast_enabled=iast_enabled) try: with tracer.trace("local_root_span0"): # First span should be kept, as we keep 1 per min @@ -629,7 +629,7 @@ def test_asm_standalone_present_appsec_tag_no_appsec_event_propagation_set_to_us finally: with override_env({"DD_APPSEC_SCA_ENABLED": sca_enabled}): ddtrace.config._reset() - tracer.configure(appsec_enabled=False, apm_tracing_disabled=False, iast_enabled=False) + tracer.configure(appsec_enabled=False, apm_tracing_enabled=True, iast_enabled=False) @pytest.mark.parametrize("upstream_priority", ["1", "2"]) @@ -644,7 +644,7 @@ def test_asm_standalone_present_appsec_tag_appsec_event_present_propagation_forc with override_env({"DD_APPSEC_SCA_ENABLED": sca_enabled}): ddtrace.config._reset() - tracer.configure(appsec_enabled=appsec_enabled, apm_tracing_disabled=True, iast_enabled=iast_enabled) + tracer.configure(appsec_enabled=appsec_enabled, apm_tracing_enabled=False, iast_enabled=iast_enabled) try: with tracer.trace("local_root_span0"): # First span should be kept, as we keep 1 per min @@ -698,7 +698,7 @@ def test_asm_standalone_present_appsec_tag_appsec_event_present_propagation_forc finally: with override_env({"DD_APPSEC_SCA_ENABLED": sca_enabled}): ddtrace.config._reset() - tracer.configure(appsec_enabled=False, apm_tracing_disabled=False, iast_enabled=False) + tracer.configure(appsec_enabled=False, apm_tracing_enabled=True, iast_enabled=False) def test_extract_with_baggage_http_propagation(tracer): # noqa: F811 diff --git a/tests/tracer/test_tracer.py b/tests/tracer/test_tracer.py index bd5b7909f87..f0b79d1a993 100644 --- a/tests/tracer/test_tracer.py +++ b/tests/tracer/test_tracer.py @@ -1186,7 +1186,7 @@ class FilterAll(object): def process_trace(self, trace): return None - tracer.configure(trace_processors=[FilterAll()]) + tracer.processors = [FilterAll()] with tracer.trace("root"): with tracer.trace("child"): @@ -1205,7 +1205,7 @@ def process_trace(self, trace): s.set_tag(self.key, self.value) return trace - tracer.configure(trace_processors=[FilterMutate("boop", "beep")]) + tracer.processors = [FilterMutate("boop", "beep")] with tracer.trace("root"): with tracer.trace("child"): @@ -1218,7 +1218,7 @@ def process_trace(self, trace): assert s2.get_tag("boop") == "beep" # Test multiple filters - tracer.configure(trace_processors=[FilterMutate("boop", "beep"), FilterMutate("mats", "sundin")]) + tracer.processors = [FilterMutate("boop", "beep"), FilterMutate("mats", "sundin")] with tracer.trace("root"): with tracer.trace("child"): @@ -1234,7 +1234,7 @@ class FilterBroken(object): def process_trace(self, trace): _ = 1 / 0 - tracer.configure(trace_processors=[FilterBroken()]) + tracer.processors = [FilterBroken()] with tracer.trace("root"): with tracer.trace("child"): @@ -1243,7 +1243,7 @@ def process_trace(self, trace): spans = test_spans.pop() assert len(spans) == 2 - tracer.configure(trace_processors=[FilterMutate("boop", "beep"), FilterBroken()]) + tracer.processors = [FilterMutate("boop", "beep"), FilterBroken()] with tracer.trace("root"): with tracer.trace("child"): pass @@ -1854,7 +1854,7 @@ class DropAllFilter(TraceFilter): def process_trace(self, trace): return None - t.configure(trace_processors=[DropAllFilter()]) + t.processors = [DropAllFilter()] for _ in range(5): with t.trace("test") as span: @@ -1913,7 +1913,7 @@ def test_asm_standalone_configuration(sca_enabled, appsec_enabled, iast_enabled) with override_env({"DD_APPSEC_SCA_ENABLED": sca_enabled}): ddtrace.config._reset() tracer = DummyTracer() - tracer.configure(appsec_enabled=appsec_enabled, iast_enabled=iast_enabled, apm_tracing_disabled=True) + tracer.configure(appsec_enabled=appsec_enabled, iast_enabled=iast_enabled, apm_tracing_enabled=False) if sca_enabled == "true": assert bool(ddtrace.config._sca_enabled) is True assert tracer.enabled is False @@ -1927,7 +1927,7 @@ def test_asm_standalone_configuration(sca_enabled, appsec_enabled, iast_enabled) # reset tracer values with override_env({"DD_APPSEC_SCA_ENABLED": "false"}): ddtrace.config._reset() - tracer.configure(appsec_enabled=False, iast_enabled=False, apm_tracing_disabled=False) + tracer.configure(appsec_enabled=False, iast_enabled=False, apm_tracing_enabled=True) def test_gc_not_used_on_root_spans():