Skip to content

Commit e9a76c4

Browse files
committed
remove LLMSpanAttributes validation layer
1 parent 48fb3fb commit e9a76c4

File tree

4 files changed

+8
-173
lines changed

4 files changed

+8
-173
lines changed

Diff for: instrumentation/opentelemetry-instrumentation-openai/pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ classifiers = [
2727
dependencies = [
2828
"opentelemetry-api ~= 1.12",
2929
"opentelemetry-instrumentation == 0.48b0.dev",
30-
"opentelemetry-semantic-conventions == 0.48b0.dev",
31-
"pydantic>=1.8"
30+
"opentelemetry-semantic-conventions == 0.48b0.dev"
3231

3332
]
3433

Diff for: instrumentation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
4949
from opentelemetry.instrumentation.openai.package import _instruments
50+
from opentelemetry.semconv.schemas import Schemas
5051
from opentelemetry.trace import get_tracer
5152

5253
from .patch import chat_completions_create
@@ -64,7 +65,7 @@ def _instrument(self, **kwargs):
6465
__name__,
6566
"",
6667
tracer_provider,
67-
schema_url="https://opentelemetry.io/schemas/1.27.0",
68+
schema_url=Schemas.V1_27_0,
6869
)
6970
wrap_function_wrapper(
7071
module="openai.resources.chat.completions",

Diff for: instrumentation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from opentelemetry.trace import Span, SpanKind, Tracer
2525
from opentelemetry.trace.status import Status, StatusCode
2626

27-
from .span_attributes import LLMSpanAttributes
2827
from .utils import (
2928
extract_content,
3029
extract_tools_prompt,
@@ -49,13 +48,10 @@ def traced_method(wrapped, instance, args, kwargs):
4948
llm_prompts.append(tools_prompt if tools_prompt else item)
5049

5150
span_attributes = {**get_llm_request_attributes(kwargs)}
52-
53-
attributes = LLMSpanAttributes(**span_attributes)
54-
55-
span_name = f"{attributes.gen_ai_operation_name} {attributes.gen_ai_request_model}"
51+
span_name = f"{span_attributes[GenAIAttributes.GEN_AI_OPERATION_NAME]} {span_attributes[GenAIAttributes.GEN_AI_REQUEST_MODEL]}"
5652

5753
span = tracer.start_span(name=span_name, kind=SpanKind.CLIENT)
58-
_set_input_attributes(span, attributes)
54+
_set_input_attributes(span, span_attributes)
5955
set_event_prompt(span, json.dumps(llm_prompts))
6056

6157
try:
@@ -84,8 +80,8 @@ def traced_method(wrapped, instance, args, kwargs):
8480

8581

8682
@silently_fail
87-
def _set_input_attributes(span, attributes: LLMSpanAttributes):
88-
for field, value in attributes.model_dump(by_alias=True).items():
83+
def _set_input_attributes(span, attributes):
84+
for field, value in attributes.items():
8985
set_span_attribute(span, field, value)
9086

9187

@@ -219,7 +215,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
219215
if exc_type is not None:
220216
self.span.set_status(Status(StatusCode.ERROR, str(exc_val)))
221217
self.span.set_attribute(
222-
ErrorAttributes.ERROR_TYPE, exc_type.__name__
218+
ErrorAttributes.ERROR_TYPE, exc_type.__qualname__
223219
)
224220
finally:
225221
self.cleanup()

Diff for: instrumentation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/span_attributes.py

-161
This file was deleted.

0 commit comments

Comments
 (0)