Skip to content

Commit e317bd5

Browse files
Merge branch 'main' into structlog-handler
2 parents 18647ae + d22bf39 commit e317bd5

File tree

42 files changed

+2688
-564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2688
-564
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
([#4212](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4212))
2424
- `opentelemetry-instrumentation-botocore`: Add support for instrumenting `aiobotocore`
2525
([#4049](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4049))
26+
- `opentelemetry-instrumentation-sqlalchemy`: implement new semantic convention opt-in migration
27+
([#4110](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4110))
2628

2729
### Fixed
2830

@@ -34,6 +36,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3436
([#4305](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4305))
3537
- Don't import module in unwrap if not already imported
3638
([#4321](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4321))
39+
- `opentelemetry-instrumentation-logging`: Map Python `CRITICAL` log level to OTel `FATAL` severity text and `WARNING` to `WARN`
40+
([#4365](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4365))
3741
- `opentelemetry-instrumentation-logging`: Add recursion guard in LoggingHandler.emit to prevent deadlock
3842
([#4302](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4302))
3943
- `opentelemetry-instrumentation-grpc`: Fix bidirectional streaming RPCs raising `AttributeError: 'generator' object has no attribute 'add_done_callback'`

instrumentation-genai/opentelemetry-instrumentation-anthropic/pyproject.toml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@ classifiers = [
2626
"Programming Language :: Python :: 3.14",
2727
]
2828
dependencies = [
29-
"opentelemetry-api ~= 1.37",
30-
"opentelemetry-instrumentation ~= 0.58b0",
31-
"opentelemetry-semantic-conventions ~= 0.58b0",
29+
"opentelemetry-api ~= 1.39",
30+
"opentelemetry-instrumentation ~= 0.60b0",
31+
"opentelemetry-semantic-conventions ~= 0.60b0",
3232
"opentelemetry-util-genai >= 0.2b0, <0.4b0",
3333
]
3434

3535
[project.optional-dependencies]
36-
instruments = [
37-
"anthropic >= 0.51.0",
38-
]
36+
instruments = ["anthropic >= 0.51.0"]
3937

4038
[project.entry-points.opentelemetry_instrumentor]
4139
anthropic = "opentelemetry.instrumentation.anthropic:AnthropicInstrumentor"
@@ -48,15 +46,10 @@ Repository = "https://github.com/open-telemetry/opentelemetry-python-contrib"
4846
path = "src/opentelemetry/instrumentation/anthropic/version.py"
4947

5048
[tool.hatch.build.targets.sdist]
51-
include = [
52-
"/src",
53-
"/tests",
54-
"/examples",
55-
]
49+
include = ["/src", "/tests", "/examples"]
5650

5751
[tool.hatch.build.targets.wheel]
5852
packages = ["src/opentelemetry"]
5953

6054
[tool.pytest.ini_options]
6155
testpaths = ["tests"]
62-

instrumentation-genai/opentelemetry-instrumentation-anthropic/src/opentelemetry/instrumentation/anthropic/utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
MessagePart,
3939
Reasoning,
4040
Text,
41-
ToolCall,
41+
ToolCallRequest,
4242
ToolCallResponse,
4343
)
4444

@@ -114,7 +114,7 @@ def _convert_dict_block_to_part(
114114

115115
if block_type == "tool_use":
116116
inp = block.get("input")
117-
return ToolCall(
117+
return ToolCallRequest(
118118
arguments=inp if isinstance(inp, dict) else None,
119119
name=str(block.get("name", "")),
120120
id=str(block.get("id", "")),
@@ -144,7 +144,9 @@ def _convert_content_block_to_part(
144144
return Text(content=block.text)
145145

146146
if isinstance(block, (ToolUseBlock, ServerToolUseBlock)):
147-
return ToolCall(arguments=block.input, name=block.name, id=block.id)
147+
return ToolCallRequest(
148+
arguments=block.input, name=block.name, id=block.id
149+
)
148150

149151
if isinstance(block, (ThinkingBlock, RedactedThinkingBlock)):
150152
content = (
@@ -229,7 +231,7 @@ def stream_block_state_to_part(state: StreamBlockState) -> MessagePart | None:
229231
arguments = json.loads(state.input_json)
230232
except ValueError:
231233
arguments = state.input_json
232-
return ToolCall(
234+
return ToolCallRequest(
233235
arguments=arguments,
234236
name=state.tool_name,
235237
id=state.tool_id,

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/requirements.oldest.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pytest==7.4.4
2121
pytest-vcr==1.0.2
2222
pytest-asyncio==0.21.0
2323
wrapt==1.16.0
24-
opentelemetry-api==1.37 # when updating, also update in pyproject.toml
25-
opentelemetry-sdk==1.37 # when updating, also update in pyproject.toml
26-
opentelemetry-semantic-conventions==0.58b0 # when updating, also update in pyproject.toml
24+
opentelemetry-api==1.39 # when updating, also update in pyproject.toml
25+
opentelemetry-sdk==1.39 # when updating, also update in pyproject.toml
26+
opentelemetry-semantic-conventions==0.60b0 # when updating, also update in pyproject.toml
2727

2828
-e instrumentation-genai/opentelemetry-instrumentation-anthropic

instrumentation-genai/opentelemetry-instrumentation-claude-agent-sdk/pyproject.toml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@ classifiers = [
2424
"Programming Language :: Python :: 3.13",
2525
]
2626
dependencies = [
27-
"opentelemetry-api ~= 1.37",
28-
"opentelemetry-instrumentation ~= 0.58b0",
29-
"opentelemetry-semantic-conventions ~= 0.58b0",
27+
"opentelemetry-api ~= 1.39",
28+
"opentelemetry-instrumentation ~= 0.60b0",
29+
"opentelemetry-semantic-conventions ~= 0.60b0",
3030
"opentelemetry-util-genai >= 0.2b0, <0.4b0",
3131
]
3232

3333
[project.optional-dependencies]
34-
instruments = [
35-
"claude-agent-sdk >= 0.1.14",
36-
]
34+
instruments = ["claude-agent-sdk >= 0.1.14"]
3735

3836
[project.entry-points.opentelemetry_instrumentor]
3937
claude-agent-sdk = "opentelemetry.instrumentation.claude_agent_sdk:ClaudeAgentSDKInstrumentor"
@@ -46,11 +44,7 @@ Repository = "https://github.com/open-telemetry/opentelemetry-python-contrib"
4644
path = "src/opentelemetry/instrumentation/claude_agent_sdk/version.py"
4745

4846
[tool.hatch.build.targets.sdist]
49-
include = [
50-
"/src",
51-
"/tests",
52-
"/examples",
53-
]
47+
include = ["/src", "/tests", "/examples"]
5448

5549
[tool.hatch.build.targets.wheel]
5650
packages = ["src/opentelemetry"]

instrumentation-genai/opentelemetry-instrumentation-claude-agent-sdk/tests/requirements.oldest.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pytest==7.4.4
2121
pytest-vcr==1.0.2
2222
pytest-asyncio==0.21.0
2323
wrapt==1.16.0
24-
opentelemetry-api==1.37 # when updating, also update in pyproject.toml
25-
opentelemetry-sdk==1.37 # when updating, also update in pyproject.toml
26-
opentelemetry-semantic-conventions==0.58b0 # when updating, also update in pyproject.toml
24+
opentelemetry-api==1.39 # when updating, also update in pyproject.toml
25+
opentelemetry-sdk==1.39 # when updating, also update in pyproject.toml
26+
opentelemetry-semantic-conventions==0.60b0 # when updating, also update in pyproject.toml
2727

2828
-e instrumentation-genai/opentelemetry-instrumentation-claude-agent-sdk

instrumentation-genai/opentelemetry-instrumentation-google-genai/pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ classifiers = [
3939
"Programming Language :: Python :: 3.14",
4040
]
4141
dependencies = [
42-
"opentelemetry-api ~=1.37",
43-
"opentelemetry-instrumentation >=0.58b0, <2",
44-
"opentelemetry-semantic-conventions >=0.58b0, <2",
45-
"opentelemetry-util-genai >= 0.3b0, <0.4b0",
42+
"opentelemetry-api ~=1.39",
43+
"opentelemetry-instrumentation >=0.60b0, <2",
44+
"opentelemetry-semantic-conventions >=0.60b0, <2",
45+
"opentelemetry-util-genai >= 0.4b0.dev, <0.5b0",
4646
]
4747

4848
[project.optional-dependencies]

instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/message.py

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515
from __future__ import annotations
1616

1717
import logging
18-
from dataclasses import dataclass
1918
from enum import Enum
20-
from typing import Literal
2119

2220
from google.genai import types as genai_types
2321

2422
from opentelemetry.util.genai.types import (
23+
Blob,
2524
FinishReason,
2625
InputMessage,
2726
MessagePart,
2827
OutputMessage,
2928
Text,
30-
ToolCall,
29+
ToolCallRequest,
3130
ToolCallResponse,
31+
Uri,
3232
)
3333

3434

@@ -39,23 +39,6 @@ class Role(str, Enum):
3939
TOOL = "tool"
4040

4141

42-
@dataclass
43-
class BlobPart:
44-
data: bytes
45-
mime_type: str
46-
type: Literal["blob"] = "blob"
47-
48-
49-
@dataclass
50-
class FileDataPart:
51-
mime_type: str
52-
uri: str
53-
type: Literal["file_data"] = "file_data"
54-
55-
class Config:
56-
extra = "allow"
57-
58-
5942
_logger = logging.getLogger(__name__)
6043

6144

@@ -121,16 +104,26 @@ def tool_call_id(name: str | None) -> str:
121104
if (text := part.text) is not None:
122105
return Text(content=text)
123106

124-
if data := part.inline_data:
125-
return BlobPart(mime_type=data.mime_type or "", data=data.data or b"")
107+
if inline_data := part.inline_data:
108+
mime_type = inline_data.mime_type or ""
109+
modality = mime_type.split("/")[0] if mime_type else ""
110+
return Blob(
111+
mime_type=mime_type,
112+
modality=modality,
113+
content=inline_data.data or b"",
114+
)
126115

127-
if data := part.file_data:
128-
return FileDataPart(
129-
mime_type=data.mime_type or "", uri=data.file_uri or ""
116+
if file_data := part.file_data:
117+
mime_type = file_data.mime_type or ""
118+
modality = mime_type.split("/")[0] if mime_type else ""
119+
return Uri(
120+
mime_type=mime_type,
121+
modality=modality,
122+
uri=file_data.file_uri or "",
130123
)
131124

132125
if call := part.function_call:
133-
return ToolCall(
126+
return ToolCallRequest(
134127
id=call.id or tool_call_id(call.name),
135128
name=call.name or "",
136129
arguments=call.args,

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/requirements.oldest.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ pytest-vcr==1.0.2
2121

2222
google-auth==2.15.0
2323
google-genai==1.32.0
24-
opentelemetry-api==1.37.0
25-
opentelemetry-sdk==1.37.0
26-
opentelemetry-semantic-conventions==0.58b0
27-
opentelemetry-instrumentation==0.58b0
28-
opentelemetry-util-genai[upload]==0.3b0
24+
opentelemetry-api==1.39.0
25+
opentelemetry-sdk==1.39.0
26+
opentelemetry-semantic-conventions==0.60b0
27+
opentelemetry-instrumentation==0.60b0
28+
-e util/opentelemetry-util-genai[upload]
2929

3030
fsspec==2025.9.0
3131

instrumentation-genai/opentelemetry-instrumentation-langchain/src/opentelemetry/instrumentation/langchain/callback_handler.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from __future__ import annotations
1616

17-
from typing import Any, Optional
17+
from typing import Any, Optional, cast
1818
from uuid import UUID
1919

2020
from langchain_core.callbacks import BaseCallbackHandler
@@ -29,6 +29,7 @@
2929
Error,
3030
InputMessage,
3131
LLMInvocation,
32+
MessagePart,
3233
OutputMessage,
3334
Text,
3435
)
@@ -133,7 +134,11 @@ def on_chat_model_start(
133134
Text(content=text_value, type="text")
134135
)
135136

136-
input_messages.append(InputMessage(parts=parts, role=role))
137+
input_messages.append(
138+
InputMessage(
139+
parts=cast(list[MessagePart], parts), role=role
140+
)
141+
)
137142

138143
llm_invocation = LLMInvocation(
139144
request_model=request_model,
@@ -206,7 +211,7 @@ def on_llm_end(
206211
role = chat_generation.message.type
207212
output_message = OutputMessage(
208213
role=role,
209-
parts=parts,
214+
parts=cast(list[MessagePart], parts),
210215
finish_reason=finish_reason,
211216
)
212217
output_messages.append(output_message)

0 commit comments

Comments
 (0)