Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions tests/parametric/test_library_tracestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,23 @@ def test_measured_spans_TS004(self, test_agent: TestAgentAPI, test_library: APML
assert op2_stats["Hits"] == 1
assert op2_stats["TopLevelHits"] == 0

@enable_tracestats()
@parametrize(
"library_env",
[
{
"DD_TRACE_STATS_COMPUTATION_ENABLED": "1",
"DD_TRACE_TRACER_METRICS_ENABLED": "true",
"DD_VERSION": "1.2.3",
"DD_ENV": "some-env",
"DD_SERVICE": "some-service",
}
],
)
@enable_agent_version()
def test_top_level_TS005(self, test_agent: TestAgentAPI, test_library: APMLibrary):
"""When top level (service entry) spans are created
Each top level span has trace stats computed for it.
Asserts that version and env are set correctly in the stats request.
"""
with (
test_library,
Expand All @@ -251,8 +263,9 @@ def test_top_level_TS005(self, test_agent: TestAgentAPI, test_library: APMLibrar
requests = test_agent.get_v06_stats_requests()
assert len(requests) == 1, "Only one stats request is expected"
request = requests[0]["body"]
for key in ("Hostname", "Env", "Version", "Stats"):
assert key in request, f"{key} should be in stats request"
assert request["Env"] == "some-env"
assert request["Version"] == "1.2.3"
assert request["Stats"] is not None

buckets = request["Stats"]
assert len(buckets) == 1, "There should be one bucket containing the stats"
Expand Down
Loading