File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 3232from opentelemetry .semconv ._incubating .attributes import (
3333 server_attributes as ServerAttributes ,
3434)
35+ from opentelemetry .semconv ._incubating .metrics import gen_ai_metrics
3536
3637
3738@pytest .mark .vcr ()
@@ -927,7 +928,7 @@ async def test_async_chat_completion_metrics(
927928 (
928929 m
929930 for m in metric_data
930- if m .name == "gen_ai.client.operation.duration"
931+ if m .name == gen_ai_metrics . GEN_AI_CLIENT_OPERATION_DURATION
931932 ),
932933 None ,
933934 )
@@ -936,7 +937,12 @@ async def test_async_chat_completion_metrics(
936937 assert_all_metric_attributes (duration_metric .data .data_points [0 ])
937938
938939 token_usage_metric = next (
939- (m for m in metric_data if m .name == "gen_ai.client.token.usage" ), None
940+ (
941+ m
942+ for m in metric_data
943+ if m .name == gen_ai_metrics .GEN_AI_CLIENT_TOKEN_USAGE
944+ ),
945+ None ,
940946 )
941947 assert token_usage_metric is not None
942948
Original file line number Diff line number Diff line change 3232from opentelemetry .semconv ._incubating .attributes import (
3333 server_attributes as ServerAttributes ,
3434)
35+ from opentelemetry .semconv ._incubating .metrics import gen_ai_metrics
3536
3637
3738@pytest .mark .vcr ()
@@ -903,7 +904,7 @@ def test_chat_completion_metrics(
903904 (
904905 m
905906 for m in metric_data
906- if m .name == "gen_ai.client.operation.duration"
907+ if m .name == gen_ai_metrics . GEN_AI_CLIENT_OPERATION_DURATION
907908 ),
908909 None ,
909910 )
@@ -912,7 +913,12 @@ def test_chat_completion_metrics(
912913 assert_all_metric_attributes (duration_metric .data .data_points [0 ])
913914
914915 token_usage_metric = next (
915- (m for m in metric_data if m .name == "gen_ai.client.token.usage" ), None
916+ (
917+ m
918+ for m in metric_data
919+ if m .name == gen_ai_metrics .GEN_AI_CLIENT_TOKEN_USAGE
920+ ),
921+ None ,
916922 )
917923 assert token_usage_metric is not None
918924
You can’t perform that action at this time.
0 commit comments