Skip to content

Commit 04d948a

Browse files
committed
refactor: don't reinvent span attribute assignment
1 parent be8620b commit 04d948a

File tree

1 file changed

+2
-10
lines changed
  • util/opentelemetry-util-genai/src/opentelemetry/util/genai

1 file changed

+2
-10
lines changed

util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
from dataclasses import asdict
16-
from typing import Any, Dict, List
16+
from typing import List
1717

1818
from opentelemetry.semconv._incubating.attributes import (
1919
gen_ai_attributes as GenAI,
@@ -106,21 +106,13 @@ def _maybe_set_span_messages(
106106
)
107107

108108

109-
def _set_span_extra_attributes(
110-
span: Span,
111-
attributes: Dict[str, Any],
112-
) -> None:
113-
for key, value in attributes.items():
114-
span.set_attribute(key, value)
115-
116-
117109
def _apply_finish_attributes(span: Span, invocation: LLMInvocation) -> None:
118110
"""Apply attributes/messages common to finish() paths."""
119111
_apply_common_span_attributes(span, invocation)
120112
_maybe_set_span_messages(
121113
span, invocation.input_messages, invocation.output_messages
122114
)
123-
_set_span_extra_attributes(span, invocation.attributes)
115+
span.set_attributes(invocation.attributes)
124116

125117

126118
def _apply_error_attributes(span: Span, error: Error) -> None:

0 commit comments

Comments
 (0)