Skip to content

Commit

Permalink
Use metric name constant
Browse files Browse the repository at this point in the history
  • Loading branch information
drewby committed Jan 10, 2025
1 parent 1e0d6b7 commit bf16dfe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from opentelemetry.semconv._incubating.attributes import (
server_attributes as ServerAttributes,
)
from opentelemetry.semconv._incubating.metrics import gen_ai_metrics


@pytest.mark.vcr()
Expand Down Expand Up @@ -927,7 +928,7 @@ async def test_async_chat_completion_metrics(
(
m
for m in metric_data
if m.name == "gen_ai.client.operation.duration"
if m.name == gen_ai_metrics.GEN_AI_CLIENT_OPERATION_DURATION
),
None,
)
Expand All @@ -936,7 +937,12 @@ async def test_async_chat_completion_metrics(
assert_all_metric_attributes(duration_metric.data.data_points[0])

token_usage_metric = next(
(m for m in metric_data if m.name == "gen_ai.client.token.usage"), None
(
m
for m in metric_data
if m.name == gen_ai_metrics.GEN_AI_CLIENT_TOKEN_USAGE
),
None,
)
assert token_usage_metric is not None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from opentelemetry.semconv._incubating.attributes import (
server_attributes as ServerAttributes,
)
from opentelemetry.semconv._incubating.metrics import gen_ai_metrics


@pytest.mark.vcr()
Expand Down Expand Up @@ -903,7 +904,7 @@ def test_chat_completion_metrics(
(
m
for m in metric_data
if m.name == "gen_ai.client.operation.duration"
if m.name == gen_ai_metrics.GEN_AI_CLIENT_OPERATION_DURATION
),
None,
)
Expand All @@ -912,7 +913,12 @@ def test_chat_completion_metrics(
assert_all_metric_attributes(duration_metric.data.data_points[0])

token_usage_metric = next(
(m for m in metric_data if m.name == "gen_ai.client.token.usage"), None
(
m
for m in metric_data
if m.name == gen_ai_metrics.GEN_AI_CLIENT_TOKEN_USAGE
),
None,
)
assert token_usage_metric is not None

Expand Down

0 comments on commit bf16dfe

Please sign in to comment.