Skip to content

Commit

Permalink
chore: [SVLS-5973] fewer count buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
apiarian-datadog committed Nov 14, 2024
1 parent 9eedfd9 commit c467f9d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
12 changes: 11 additions & 1 deletion ddtrace/_trace/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@ def record_span_pointer_calculation(context: str, span_pointer_count: int) -> No


def _span_pointer_count_to_tag(span_pointer_count: int) -> str:
if span_pointer_count <= 20:
if span_pointer_count < 0:
# this shouldn't be possible, but let's make sure
return "negative"

elif span_pointer_count <= 5:
return str(span_pointer_count)

elif span_pointer_count <= 10:
return "6-10"

elif span_pointer_count <= 20:
return "11-20"

elif span_pointer_count <= 50:
return "21-50"

Expand Down
15 changes: 13 additions & 2 deletions tests/tracer/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@


def test_span_pointer_count_to_tag_returns_strings() -> None:
for count in range(0, 500):
unique_tags = set()

for count in range(-10, 500):
tag = _span_pointer_count_to_tag(count)

assert isinstance(tag, str)
assert tag != ""

unique_tags.add(tag)

reasonable_cadinality_limit = 15
assert len(unique_tags) <= reasonable_cadinality_limit


class SpanPointerTagCase(NamedTuple):
count: int
Expand All @@ -21,6 +28,10 @@ class SpanPointerTagCase(NamedTuple):
@pytest.mark.parametrize(
"test_case",
[
SpanPointerTagCase(
count=-1,
expected="negative",
),
SpanPointerTagCase(
count=0,
expected="0",
Expand All @@ -35,7 +46,7 @@ class SpanPointerTagCase(NamedTuple):
),
SpanPointerTagCase(
count=15,
expected="15",
expected="11-20",
),
SpanPointerTagCase(
count=25,
Expand Down

0 comments on commit c467f9d

Please sign in to comment.