|
32 | 32 | from opentelemetry.trace.propagation import set_span_in_context |
33 | 33 | from opentelemetry.trace.status import Status, StatusCode |
34 | 34 | from opentelemetry.util.genai.types import ( |
| 35 | + EmbeddingInvocation, |
35 | 36 | Error, |
36 | 37 | InputMessage, |
37 | 38 | LLMInvocation, |
38 | | - EmbeddingInvocation, |
39 | 39 | MessagePart, |
40 | 40 | OutputMessage, |
41 | 41 | ) |
@@ -217,44 +217,6 @@ def _maybe_emit_llm_event( |
217 | 217 | logger.emit(event) |
218 | 218 |
|
219 | 219 |
|
220 | | -def _maybe_emit_embedding_event( |
221 | | - logger: Logger | None, |
222 | | - span: Span, |
223 | | - invocation: EmbeddingInvocation, |
224 | | - error: Error | None = None, |
225 | | -) -> None: |
226 | | - """Emit a gen_ai.client.inference.operation.details event to the logger. |
227 | | -
|
228 | | - This function creates a LogRecord event following the semantic convention |
229 | | - for gen_ai.client.inference.operation.details as specified in the GenAI |
230 | | - event semantic conventions. |
231 | | -
|
232 | | - For more details, see the semantic convention documentation: |
233 | | - https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-events.md#event-eventgen_aiclientinferenceoperationdetails |
234 | | - """ |
235 | | - if not is_experimental_mode() or not should_emit_event() or logger is None: |
236 | | - return |
237 | | - |
238 | | - # Build event attributes by reusing the attribute getter functions |
239 | | - attributes: dict[str, Any] = {} |
240 | | - attributes.update(_get_embedding_common_attributes(invocation)) |
241 | | - attributes.update(_get_embedding_request_attributes(invocation)) |
242 | | - attributes.update(_get_embedding_response_attributes(invocation)) |
243 | | - |
244 | | - # Add error.type if operation ended in error |
245 | | - if error is not None: |
246 | | - attributes[error_attributes.ERROR_TYPE] = error.type.__qualname__ |
247 | | - |
248 | | - # Create and emit the event |
249 | | - context = set_span_in_context(span, get_current()) |
250 | | - event = LogRecord( |
251 | | - event_name="gen_ai.client.embedding.operation.details", |
252 | | - attributes=attributes, |
253 | | - context=context, |
254 | | - ) |
255 | | - logger.emit(event) |
256 | | - |
257 | | - |
258 | 220 | def _apply_llm_finish_attributes( |
259 | 221 | span: Span, invocation: LLMInvocation |
260 | 222 | ) -> None: |
@@ -333,7 +295,7 @@ def _get_embedding_request_attributes( |
333 | 295 | """Get GenAI request semantic convention attributes.""" |
334 | 296 | optional_attrs = ( |
335 | 297 | (GenAI.GEN_AI_REQUEST_MODEL, invocation.request_model), |
336 | | - (GenAI.GEN_AI_EMBEDDING_DIMENSION_COUNT, invocation.dimension_count), |
| 298 | + (GenAI.GEN_AI_EMBEDDINGS_DIMENSION_COUNT, invocation.dimension_count), |
337 | 299 | (GenAI.GEN_AI_REQUEST_ENCODING_FORMATS, invocation.encoding_formats), |
338 | 300 | ) |
339 | 301 |
|
@@ -399,5 +361,4 @@ def _get_embedding_response_attributes( |
399 | 361 | "_get_embedding_request_attributes", |
400 | 362 | "_get_embedding_response_attributes", |
401 | 363 | "_get_embedding_span_name", |
402 | | - "_maybe_emit_embedding_event", |
403 | 364 | ] |
0 commit comments