Skip to content

Commit c94f40e

Browse files
committed
agent name works
1 parent 9e03c88 commit c94f40e

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/chat_wrappers.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,6 @@ async def _handle_request(span, kwargs, instance):
268268
_set_request_attributes(span, kwargs, instance)
269269
_set_client_attributes(span, instance)
270270

271-
# Set agent name attribute if available in context
272-
agent_name = get_value("agent_name")
273-
if agent_name is not None:
274-
_set_span_attribute(span, GEN_AI_AGENT_NAME, str(agent_name))
275-
276271
if should_emit_events():
277272
for message in kwargs.get("messages", []):
278273
emit_event(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
from traceloop.sdk.tracing.context_manager import get_tracer
2-
from traceloop.sdk.tracing.tracing import set_workflow_name
2+
from traceloop.sdk.tracing.tracing import set_workflow_name, set_agent_name

packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from traceloop.sdk.utils import is_notebook
3636
from traceloop.sdk.utils.package_check import is_package_installed
3737
from typing import Callable, Dict, List, Optional, Set, Union
38+
from opentelemetry.semconv._incubating.attributes.gen_ai_attributes import GEN_AI_AGENT_NAME
3839

3940

4041
TRACER_NAME = "traceloop.tracer"
@@ -322,7 +323,7 @@ def default_span_processor_on_start(span: Span, parent_context: Context | None =
322323

323324
agent_name = get_value("agent_name")
324325
if agent_name is not None:
325-
span.set_attribute(SpanAttributes.TRACELOOP_ENTITY_NAME, str(agent_name))
326+
span.set_attribute(GEN_AI_AGENT_NAME, str(agent_name))
326327

327328
entity_path = get_value("entity_path")
328329
if entity_path is not None:
@@ -1177,10 +1178,6 @@ def metrics_common_attributes():
11771178
if workflow_name is not None:
11781179
common_attributes[SpanAttributes.TRACELOOP_WORKFLOW_NAME] = workflow_name
11791180

1180-
agent_name = get_value("agent_name")
1181-
if agent_name is not None:
1182-
common_attributes[SpanAttributes.TRACELOOP_ENTITY_NAME] = agent_name
1183-
11841181
entity_name = get_value("entity_name")
11851182
if entity_name is not None:
11861183
common_attributes[SpanAttributes.TRACELOOP_ENTITY_NAME] = entity_name

0 commit comments

Comments
 (0)