Skip to content

Commit

Permalink
Merge branch 'main' into brettlangdon/remove.py.skips
Browse files Browse the repository at this point in the history
  • Loading branch information
brettlangdon authored Nov 22, 2024
2 parents 6e01a66 + 33a2345 commit 0ae0057
Show file tree
Hide file tree
Showing 35 changed files with 438 additions and 399 deletions.
6 changes: 3 additions & 3 deletions docs/scenarios/parametric.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ from utils.parametric.spec.trace import find_span, find_trace, find_span_in_trac
@pytest.mark.parametrize("library_env", [{"DD_ENV": "prod"}])
def test_datadog_spans(library_env, test_library, test_agent):
with test_library:
with test_library.start_span("operation") as s1:
with test_library.start_span("operation1", service="hello", parent_id=s1.span_id) as s2:
with test_library.dd_start_span("operation") as s1:
with test_library.dd_start_span("operation1", service="hello", parent_id=s1.span_id) as s2:
pass

with test_library.start_span("otel_rocks") as os1:
with test_library.dd_start_span("otel_rocks") as os1:
pass

# Waits for 2 traces to be captured and avoids sorting the received spans by start time
Expand Down
2 changes: 1 addition & 1 deletion manifests/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ tests/:
test_asm_standalone.py:
Test_AppSecStandalone_UpstreamPropagation:
'*': v2.12.3
uwsgi-poc: flaky (APPSEC-55222)
uwsgi-poc: v2.17.1
Test_IastStandalone_UpstreamPropagation: missing_feature
Test_SCAStandalone_Telemetry: missing_feature
test_automated_login_events.py:
Expand Down
15 changes: 11 additions & 4 deletions tests/docker_ssi/test_docker_ssi.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,25 @@ def test_telemetry(self):
@features.ssi_guardrails
@irrelevant(context.library == "java" and context.installed_language_runtime >= "1.8.0_0")
@irrelevant(context.library == "php" and context.installed_language_runtime >= "7.0")
@bug(condition=context.library == "python" and context.installed_language_runtime < "3.7.0", reason="INPLAT-181")
@irrelevant(context.library == "python" and context.installed_language_runtime >= "3.7.0")
def test_telemetry_abort(self):
# There is telemetry data about the auto instrumentation injector. We only validate there is data
telemetry_autoinject_data = interfaces.test_agent.get_telemetry_for_autoinject()
assert len(telemetry_autoinject_data) >= 1
inject_success = False
inject_result = None
for data in telemetry_autoinject_data:
if data["metric"] == "inject.success":
inject_success = True
inject_result = True
break
assert inject_success, "No telemetry data found for inject.success"
if data["metric"] == "inject.skip" or data["metric"] == "inject.error":
inject_result = False
break

assert inject_result != None, "No telemetry data found for inject.success, inject.skip or inject.error"

# The injector detected by itself that the version is not supported
if inject_result == False:
return

# There is telemetry data about the library entrypoint. We only validate there is data
telemetry_autoinject_data = interfaces.test_agent.get_telemetry_for_autoinject_library_entrypoint()
Expand Down
4 changes: 2 additions & 2 deletions tests/parametric/test_128_bit_traceids.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ def test_w3c_128_bit_propagation_tid_in_chunk_root(self, test_agent, test_librar
"""Ensure that only root span contains the tid.
"""
with test_library:
with test_library.start_span(name="parent", service="service", resource="resource") as parent:
with test_library.start_span(name="child", service="service", parent_id=parent.span_id) as child:
with test_library.dd_start_span(name="parent", service="service", resource="resource") as parent:
with test_library.dd_start_span(name="child", service="service", parent_id=parent.span_id) as child:
pass

traces = test_agent.wait_for_num_traces(1, clear=True, sort_by_start=False)
Expand Down
30 changes: 15 additions & 15 deletions tests/parametric/test_config_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Test_Config_TraceEnabled:
def test_tracing_enabled(self, library_env, test_agent, test_library):
assert library_env.get("DD_TRACE_ENABLED", "true") == "true"
with test_library:
with test_library.start_span("allowed"):
with test_library.dd_start_span("allowed"):
pass
assert test_agent.wait_for_num_traces(
num=1
Expand All @@ -38,7 +38,7 @@ def test_tracing_enabled(self, library_env, test_agent, test_library):
def test_tracing_disabled(self, library_env, test_agent, test_library):
assert library_env.get("DD_TRACE_ENABLED") == "false"
with test_library:
with test_library.start_span("allowed"):
with test_library.dd_start_span("allowed"):
pass
with pytest.raises(ValueError) as e:
test_agent.wait_for_num_traces(num=1)
Expand All @@ -54,7 +54,7 @@ class Test_Config_TraceLogDirectory:
)
def test_trace_log_directory_configured_with_existing_directory(self, library_env, test_agent, test_library):
with test_library:
with test_library.start_span("allowed"):
with test_library.dd_start_span("allowed"):
pass

success, message = test_library.container_exec_run("ls /parametric-tracer-logs")
Expand All @@ -74,7 +74,7 @@ class Test_Config_UnifiedServiceTagging:
@parametrize("library_env", [{}])
def test_default_config(self, library_env, test_agent, test_library):
with test_library:
with test_library.start_span(name="s1") as s1:
with test_library.dd_start_span(name="s1") as s1:
pass

traces = test_agent.wait_for_num_traces(1)
Expand All @@ -92,9 +92,9 @@ def test_default_config(self, library_env, test_agent, test_library):
@missing_feature(context.library < "ruby@2.7.1-dev")
def test_specific_version(self, library_env, test_agent, test_library):
with test_library:
with test_library.start_span(name="s1") as s1:
with test_library.dd_start_span(name="s1") as s1:
pass
with test_library.start_span(name="s2", service="no dd_service") as s2:
with test_library.dd_start_span(name="s2", service="no dd_service") as s2:
pass

traces = test_agent.wait_for_num_traces(2)
Expand All @@ -113,7 +113,7 @@ def test_specific_version(self, library_env, test_agent, test_library):
def test_specific_env(self, library_env, test_agent, test_library):
assert library_env.get("DD_ENV") == "dev"
with test_library:
with test_library.start_span(name="s1") as s1:
with test_library.dd_start_span(name="s1") as s1:
pass

traces = test_agent.wait_for_num_traces(1)
Expand Down Expand Up @@ -144,7 +144,7 @@ class Test_Config_TraceAgentURL:
)
def test_dd_trace_agent_unix_url_nonexistent(self, library_env, test_agent, test_library):
with test_library as t:
resp = t.get_tracer_config()
resp = t.config()

url = urlparse(resp["dd_trace_agent_url"])
assert "unix" in url.scheme
Expand All @@ -157,7 +157,7 @@ def test_dd_trace_agent_unix_url_nonexistent(self, library_env, test_agent, test
)
def test_dd_trace_agent_http_url_nonexistent(self, library_env, test_agent, test_library):
with test_library as t:
resp = t.get_tracer_config()
resp = t.config()

url = urlparse(resp["dd_trace_agent_url"])
assert url.scheme == "http"
Expand All @@ -175,7 +175,7 @@ class Test_Config_RateLimit:
@parametrize("library_env", [{"DD_TRACE_SAMPLE_RATE": "1"}])
def test_default_trace_rate_limit(self, library_env, test_agent, test_library):
with test_library as t:
resp = t.get_tracer_config()
resp = t.config()
assert resp["dd_trace_rate_limit"] == "100"

@irrelevant(
Expand All @@ -186,9 +186,9 @@ def test_default_trace_rate_limit(self, library_env, test_agent, test_library):
@flaky(library="java", reason="APMAPI-908")
def test_setting_trace_rate_limit_strict(self, library_env, test_agent, test_library):
with test_library:
with test_library.start_span(name="s1") as s1:
with test_library.dd_start_span(name="s1") as s1:
pass
with test_library.start_span(name="s2") as s2:
with test_library.dd_start_span(name="s2") as s2:
pass

traces = test_agent.wait_for_num_traces(2)
Expand All @@ -201,9 +201,9 @@ def test_setting_trace_rate_limit_strict(self, library_env, test_agent, test_lib
@parametrize("library_env", [{"DD_TRACE_RATE_LIMIT": "1"}])
def test_trace_rate_limit_without_trace_sample_rate(self, library_env, test_agent, test_library):
with test_library:
with test_library.start_span(name="s1") as s1:
with test_library.dd_start_span(name="s1") as s1:
pass
with test_library.start_span(name="s2") as s2:
with test_library.dd_start_span(name="s2") as s2:
pass

traces = test_agent.wait_for_num_traces(2)
Expand All @@ -222,7 +222,7 @@ def test_setting_trace_rate_limit(self, library_env, test_agent, test_library):
with test_library:
# Generate three traces to demonstrate rate limiting in PHP's backfill model
for i in range(3):
with test_library.start_span(name=f"s{i+1}") as span:
with test_library.dd_start_span(name=f"s{i+1}") as span:
pass

traces = test_agent.wait_for_num_traces(3)
Expand Down
24 changes: 12 additions & 12 deletions tests/parametric/test_dynamic_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@


def send_and_wait_trace(test_library, test_agent, **span_kwargs) -> List[Span]:
with test_library.start_span(**span_kwargs) as s1:
with test_library.dd_start_span(**span_kwargs) as s1:
pass
test_library.flush()
test_library.dd_flush()
traces = test_agent.wait_for_num_traces(num=1, clear=True, sort_by_start=False)
return find_trace(traces, s1.trace_id)

Expand Down Expand Up @@ -146,7 +146,7 @@ def test_tracing_client_tracing_enabled(self, library_env, test_agent, test_libr
trace_enabled_env = library_env.get("DD_TRACE_ENABLED", "true") == "true"
if trace_enabled_env:
with test_library:
with test_library.start_span("allowed"):
with test_library.dd_start_span("allowed"):
pass
test_agent.wait_for_num_traces(num=1, clear=True)
assert True, (
Expand All @@ -161,7 +161,7 @@ def test_tracing_client_tracing_enabled(self, library_env, test_agent, test_libr
test_agent.wait_for_telemetry_event("app-client-configuration-change", clear=True)
test_agent.wait_for_rc_apply_state("APM_TRACING", state=2, clear=True)
with test_library:
with test_library.start_span("disabled"):
with test_library.dd_start_span("disabled"):
pass
with pytest.raises(ValueError):
test_agent.wait_for_num_traces(num=1, clear=True)
Expand All @@ -182,7 +182,7 @@ def test_tracing_client_tracing_disable_one_way(self, library_env, test_agent, t

_set_rc(test_agent, _create_rc_config({}))
with test_library:
with test_library.start_span("test"):
with test_library.dd_start_span("test"):
pass

with pytest.raises(ValueError):
Expand Down Expand Up @@ -215,7 +215,7 @@ def test_telemetry_app_started(self, library_env, test_agent, test_library):
by the library.
"""
# Python doesn't start writing telemetry until the first trace.
with test_library.start_span("test"):
with test_library.dd_start_span("test"):
pass
events = test_agent.wait_for_telemetry_event("app-started")
assert len(events) > 0
Expand Down Expand Up @@ -442,26 +442,26 @@ def test_tracing_client_tracing_tags(self, library_env, test_agent, test_library

# Ensure tags are applied from the env
with test_library:
with test_library.start_span("test") as span:
with test_library.start_span("test2", parent_id=span.span_id):
with test_library.dd_start_span("test") as span:
with test_library.dd_start_span("test2", parent_id=span.span_id):
pass
traces = test_agent.wait_for_num_traces(num=1, clear=True, sort_by_start=False)
assert_trace_has_tags(traces[0], expected_local_tags)

# Ensure local tags are overridden and RC tags applied.
set_and_wait_rc(test_agent, config_overrides={"tracing_tags": ["rc_key1:val1", "rc_key2:val2"]})
with test_library:
with test_library.start_span("test") as span:
with test_library.start_span("test2", parent_id=span.span_id):
with test_library.dd_start_span("test") as span:
with test_library.dd_start_span("test2", parent_id=span.span_id):
pass
traces = test_agent.wait_for_num_traces(num=1, clear=True, sort_by_start=False)
assert_trace_has_tags(traces[0], {"rc_key1": "val1", "rc_key2": "val2"})

# Ensure previous tags are restored.
set_and_wait_rc(test_agent, config_overrides={})
with test_library:
with test_library.start_span("test") as span:
with test_library.start_span("test2", parent_id=span.span_id):
with test_library.dd_start_span("test") as span:
with test_library.dd_start_span("test2", parent_id=span.span_id):
pass
traces = test_agent.wait_for_num_traces(num=1, clear=True, sort_by_start=False)
assert_trace_has_tags(traces[0], expected_local_tags)
Expand Down
22 changes: 11 additions & 11 deletions tests/parametric/test_headers_baggage.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ def test_baggage_disable_settings_D003(self, test_agent, test_library):

def test_baggage_inject_header_D004(self, test_library):
"""testing baggage header injection, proper concatenation of key value pairs, and encoding"""
with test_library.start_span(name="test_baggage_set_D004") as span:
with test_library.dd_start_span(name="test_baggage_set_D004") as span:
span.set_baggage("foo", "bar")
span.set_baggage("baz", "qux")
span.set_baggage("userId", "Amélie")
span.set_baggage("serverNode", "DF 28")
span.set_baggage('",;\\()/:<=>?@[]{}', '",;\\')

headers = test_library.inject_headers(span.span_id)
headers = test_library.dd_inject_headers(span.span_id)

assert any("baggage" in header for header in headers)
baggage_list = next((header for header in headers if header[0] == "baggage"), [])
Expand Down Expand Up @@ -119,7 +119,7 @@ def test_baggage_extract_header_D005(self, test_library):
}

def test_baggage_set_D006(self, test_library):
with test_library.start_span(name="test_baggage_set_D006") as span:
with test_library.dd_start_span(name="test_baggage_set_D006") as span:
span.set_baggage("foo", "bar")
span.set_baggage("baz", "qux")
span.set_baggage("userId", "Amélie")
Expand All @@ -133,11 +133,11 @@ def test_baggage_set_D006(self, test_library):
@disable_baggage()
def test_baggage_set_disabled_D007(self, test_library):
"""Ensure that baggage headers are not injected when baggage is disabled."""
with test_library.start_span(name="test_baggage_set_disabled_D007") as span:
with test_library.dd_start_span(name="test_baggage_set_disabled_D007") as span:
span.set_baggage("foo", "bar")
span.set_baggage("baz", "qux")

headers = test_library.inject_headers(span.span_id)
headers = test_library.dd_inject_headers(span.span_id)
assert not any("baggage" in item for item in headers)

def test_baggage_get_D008(self, test_library):
Expand Down Expand Up @@ -165,7 +165,7 @@ def test_baggage_get_all_D009(self, test_library):

def test_baggage_remove_D010(self, test_library):
"""testing baggage API remove_baggage"""
with test_library.start_span(name="test_baggage_remove_D010") as span:
with test_library.dd_start_span(name="test_baggage_remove_D010") as span:
span.set_baggage("baz", "qux")
span.set_baggage("userId", "Amélie")
span.set_baggage("serverNode", "DF 28")
Expand All @@ -177,7 +177,7 @@ def test_baggage_remove_D010(self, test_library):

def test_baggage_remove_all_D011(self, test_library):
"""testing baggage API remove_all_baggage"""
with test_library.start_span(name="test_baggage_remove_all_D011") as span:
with test_library.dd_start_span(name="test_baggage_remove_all_D011") as span:
span.set_baggage("foo", "bar")
span.set_baggage("baz", "qux")
span.remove_all_baggage()
Expand Down Expand Up @@ -216,11 +216,11 @@ def test_baggage_malformed_headers_D015(self, test_library):
def test_baggageheader_maxitems_inject_D016(self, test_library):
"""Ensure that baggage headers are not injected when the number of baggage items exceeds the maximum number of items."""
max_items = 64
with test_library.start_span(name="test_baggageheader_maxitems_inject_D016") as span:
with test_library.dd_start_span(name="test_baggageheader_maxitems_inject_D016") as span:
for i in range(max_items + 2):
span.set_baggage(f"key{i}", f"value{i}")

headers = test_library.inject_headers(span.span_id)
headers = test_library.dd_inject_headers(span.span_id)
for header in headers:
if "baggage" in header:
baggage_header = header
Expand All @@ -230,7 +230,7 @@ def test_baggageheader_maxitems_inject_D016(self, test_library):
def test_baggageheader_maxbytes_inject_D017(self, test_library):
"""Ensure that baggage headers are not injected when the total byte size of the baggage exceeds the maximum size."""
max_bytes = 8192
with test_library.start_span(name="test_baggageheader_maxbytes_inject_D017",) as span:
with test_library.dd_start_span(name="test_baggageheader_maxbytes_inject_D017",) as span:
baggage_items = {
"key1": "a" * ((max_bytes // 3)),
"key2": "b" * ((max_bytes // 3)),
Expand All @@ -240,7 +240,7 @@ def test_baggageheader_maxbytes_inject_D017(self, test_library):
for key, value in baggage_items.items():
span.set_baggage(key, value)

headers = test_library.inject_headers(span.span_id)
headers = test_library.dd_inject_headers(span.span_id)
for header in headers:
if "baggage" in header:
baggage_header = header
Expand Down
4 changes: 2 additions & 2 deletions tests/parametric/test_headers_tracecontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,8 @@ def test_tracestate_w3c_p_inject(self, test_agent, test_library):
Ensure the last parent id is propagated according to the W3C spec
"""
with test_library:
with test_library.start_span(name="new_span") as span:
headers = test_library.inject_headers(span.span_id)
with test_library.dd_start_span(name="new_span") as span:
headers = test_library.dd_inject_headers(span.span_id)

tracestate_headers = list(filter(lambda h: h[0].lower() == "tracestate", headers))
assert len(tracestate_headers) == 1
Expand Down
Loading

0 comments on commit 0ae0057

Please sign in to comment.