Skip to content

Commit c4f4bbb

Browse files
committed
Reverting unnecessary changes and dealing with comments
1 parent ac37dad commit c4f4bbb

6 files changed

Lines changed: 11 additions & 58 deletions

File tree

util/opentelemetry-util-genai/CHANGELOG.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
([https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3891](#3891))
2323
- Add parent class genAI invocation
2424
([https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3889](#3889))
25-
- Add `EmbeddingInvocation` span lifecycle support (`start_embedding`,
26-
`stop_embedding`, `fail_embedding`), embedding span tests, and defer
27-
embedding metrics emission (current no-op) to a follow-up PR.
28-
([#<PR_NUMBER>](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/<PR_NUMBER>))
25+
- Add EmbeddingInvocation span lifecycle support
26+
([https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4219](#4219))
2927

3028
## Version 0.2b0 (2025-10-14)
3129

@@ -38,8 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3836
- Make inputs / outputs / system instructions optional params to `on_completion`,
3937
([https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3802](#3802)).
4038
- Use a SHA256 hash of the system instructions as it's upload filename, and check
41-
if the file exists before re-uploading it, ([https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3814](#3814)).
42-
39+
if the file exists before re-uploading it, ([https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3814](#3814)).
4340

4441
## Version 0.1b0 (2025-09-25)
4542

@@ -53,6 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5350
([#3752](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3752))
5451
([#3759](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3759))
5552
([#3763](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3763))
53+
5654
- Add a utility to parse the `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT` environment variable.
5755
Add `gen_ai_latest_experimental` as a new value to the Sem Conv stability flag ([#3716](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3716)).
5856

util/opentelemetry-util-genai/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ For embedding invocations, common attributes include:
4343
- `gen_ai.provider.name`: Str(openai)
4444
- `gen_ai.operation.name`: Str(embeddings)
4545
- `gen_ai.request.model`: Str(text-embedding-3-small)
46-
- `gen_ai.embedding.dimension_count`: Int(1536)
46+
- `gen_ai.embeddings.dimension.count`: Int(1536)
4747
- `gen_ai.request.encoding_formats`: Slice(["float"])
4848
- `gen_ai.usage.input_tokens`: Int(24)
4949
- `server.address`: Str(api.openai.com)

util/opentelemetry-util-genai/pyproject.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ classifiers = [
2525
"Programming Language :: Python :: 3.13",
2626
]
2727
dependencies = [
28-
"opentelemetry-instrumentation ~= 0.58b0",
29-
"opentelemetry-semantic-conventions ~= 0.58b0",
28+
"opentelemetry-instrumentation ~= 0.60b1",
29+
"opentelemetry-semantic-conventions ~= 0.60b1",
3030
"opentelemetry-api>=1.31.0",
3131
]
3232

@@ -45,10 +45,7 @@ Repository = "https://github.com/open-telemetry/opentelemetry-python-contrib"
4545
path = "src/opentelemetry/util/genai/version.py"
4646

4747
[tool.hatch.build.targets.sdist]
48-
include = [
49-
"/src",
50-
"/tests",
51-
]
48+
include = ["/src", "/tests"]
5249

5350
[tool.hatch.build.targets.wheel]
5451
packages = ["src/opentelemetry"]

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,6 @@ def start_embedding(
234234
name=f"{invocation.operation_name} {invocation.request_model}",
235235
kind=SpanKind.CLIENT,
236236
)
237-
# Record a monotonic start timestamp (seconds) for duration
238-
# calculation using timeit.default_timer.
239-
invocation.monotonic_start_s = timeit.default_timer()
240237
invocation.span = span
241238
invocation.context_token = otel_context.attach(
242239
set_span_in_context(span)

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

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
from opentelemetry.trace.propagation import set_span_in_context
3333
from opentelemetry.trace.status import Status, StatusCode
3434
from opentelemetry.util.genai.types import (
35+
EmbeddingInvocation,
3536
Error,
3637
InputMessage,
3738
LLMInvocation,
38-
EmbeddingInvocation,
3939
MessagePart,
4040
OutputMessage,
4141
)
@@ -217,44 +217,6 @@ def _maybe_emit_llm_event(
217217
logger.emit(event)
218218

219219

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-
258220
def _apply_llm_finish_attributes(
259221
span: Span, invocation: LLMInvocation
260222
) -> None:
@@ -333,7 +295,7 @@ def _get_embedding_request_attributes(
333295
"""Get GenAI request semantic convention attributes."""
334296
optional_attrs = (
335297
(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),
337299
(GenAI.GEN_AI_REQUEST_ENCODING_FORMATS, invocation.encoding_formats),
338300
)
339301

@@ -399,5 +361,4 @@ def _get_embedding_response_attributes(
399361
"_get_embedding_request_attributes",
400362
"_get_embedding_response_attributes",
401363
"_get_embedding_span_name",
402-
"_maybe_emit_embedding_event",
403364
]

util/opentelemetry-util-genai/tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ def test_embedding_manual_start_and_stop_creates_span(self):
973973
GenAI.GEN_AI_OPERATION_NAME: "embeddings",
974974
GenAI.GEN_AI_REQUEST_MODEL: "embed-model",
975975
GenAI.GEN_AI_PROVIDER_NAME: "test-provider",
976-
GenAI.GEN_AI_EMBEDDING_DIMENSION_COUNT: 1536,
976+
GenAI.GEN_AI_EMBEDDINGS_DIMENSION_COUNT: 1536,
977977
GenAI.GEN_AI_REQUEST_ENCODING_FORMATS: ("float",),
978978
GenAI.GEN_AI_USAGE_INPUT_TOKENS: 123,
979979
server_attributes.SERVER_ADDRESS: "custom.server.com",

0 commit comments

Comments
 (0)