Skip to content

Commit f7e1a7b

Browse files
Merge remote-tracking branch 'origin/main' into fix/grpc-bidi-stream-1180
2 parents 5d31795 + 3fcabc3 commit f7e1a7b

22 files changed

Lines changed: 190 additions & 48 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5959
([#4139](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4139))
6060

6161
### Fixed
62+
63+
- `opentelemetry-instrumentation-asyncio`: Fix environment variables not appearing in Read the Docs documentation
64+
([#4256](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/4256))
6265
- `opentelemetry-instrumentation-grpc`: Fix bidirectional streaming RPCs raising `AttributeError: 'generator' object has no attribute 'add_done_callback'` by routing bidi streams through `_intercept` instead of the generator-based `_intercept_server_stream`
6366
([#1180](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1180))
6467
- `opentelemetry-instrumentation-mysql`: Refactor MySQL integration test mocks to use concrete DBAPI connection attributes, reducing noisy attribute type warnings.
@@ -117,6 +120,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
117120
([#4175](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4175))
118121
- `opentelemetry-docker-tests` Fix docker-tests assumption by Postgres-Sqlalchemy case about scope of metrics
119122
([#4258](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4258))
123+
- `opentelemetry-instrumentation-threading`: fix AttributeError when Thread is run without starting
124+
([#4246](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4246))
120125

121126
### Breaking changes
122127

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ For more information about the maintainer role, see the [community repository](h
125125
- [Emídio Neto](https://github.com/emdneto), Independent
126126
- [Héctor Hernández](https://github.com/hectorhdzg), Microsoft
127127
- [Jeremy Voss](https://github.com/jeremydvoss), Microsoft
128+
- [Keith Decker](https://github.com/keith-decker), Cisco/Splunk
128129
- [Liudmila Molkova](https://github.com/lmolkova), Grafana Labs
129130
- [Lukas Hering](https://github.com/herin049), Capital One
130131
- [Owais Lone](https://github.com/owais), Splunk

docs/instrumentation/asyncio/asyncio.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ OpenTelemetry asyncio Instrumentation
55
:members:
66
:undoc-members:
77
:show-inheritance:
8+
9+
.. automodule:: opentelemetry.instrumentation.asyncio.environment_variables
10+
:members:
11+
:undoc-members:
12+
:show-inheritance:

gen-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ requests
77
tomli
88
tomli_w
99
hatch
10+
# TODO: stick with virtualenv < 21 until a new hatch release
11+
virtualenv<21

instrumentation-genai/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
| --------------- | ------------------ | --------------- | -------------- |
44
| [opentelemetry-instrumentation-anthropic](./opentelemetry-instrumentation-anthropic) | anthropic >= 0.16.0 | No | development
55
| [opentelemetry-instrumentation-claude-agent-sdk](./opentelemetry-instrumentation-claude-agent-sdk) | claude-agent-sdk >= 0.1.14 | No | development
6-
| [opentelemetry-instrumentation-google-genai](./opentelemetry-instrumentation-google-genai) | google-genai >= 1.0.0 | No | development
6+
| [opentelemetry-instrumentation-google-genai](./opentelemetry-instrumentation-google-genai) | google-genai >= 1.32.0 | No | development
77
| [opentelemetry-instrumentation-langchain](./opentelemetry-instrumentation-langchain) | langchain >= 0.3.21 | No | development
88
| [opentelemetry-instrumentation-openai-agents-v2](./opentelemetry-instrumentation-openai-agents-v2) | openai-agents >= 0.3.3 | No | development
99
| [opentelemetry-instrumentation-openai-v2](./opentelemetry-instrumentation-openai-v2) | openai >= 1.26.0 | Yes | development

instrumentation-genai/opentelemetry-instrumentation-claude-agent-sdk/examples/zero-code/.env

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ ANTHROPIC_API_KEY=sk-ant-YOUR_API_KEY
77

88
OTEL_SERVICE_NAME=opentelemetry-python-claude-agent-sdk
99

10-
# Change to 'false' to disable collection of python logging logs
11-
OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
12-
1310
# Uncomment if your OTLP endpoint doesn't support logs
1411
# OTEL_LOGS_EXPORTER=console
1512

instrumentation-genai/opentelemetry-instrumentation-claude-agent-sdk/examples/zero-code/README.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ interaction.
1515

1616
Note: `.env <.env>`_ file configures additional environment variables:
1717

18-
- ``OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true`` configures
19-
OpenTelemetry SDK to export logs and events.
2018
- ``OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true`` configures
2119
Claude Agent SDK instrumentation to capture prompt and completion contents
2220
on events.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
_instruments = ("google-genai >= 1.0.0",)
15+
_instruments = ("google-genai >= 1.32.0",)

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/generate_content/test_e2e.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040
from google.genai import types
4141
from vcr.record_mode import RecordMode
4242

43+
try:
44+
# These modules are only supported in python >= 3.10
45+
from aiohttp.client_exceptions import ClientConnectionError
46+
from vcr.stubs import aiohttp_stubs
47+
except ImportError:
48+
ClientConnectionError = None
49+
aiohttp_stubs = None
50+
4351
from opentelemetry.instrumentation._semconv import (
4452
OTEL_SEMCONV_STABILITY_OPT_IN,
4553
_OpenTelemetrySemanticConventionStability,
@@ -135,6 +143,9 @@ def _redact_headers(headers):
135143

136144

137145
def _before_record_request(request):
146+
# aiohttp reports the request method in lower case while it is recorded in the cassette in upper case.
147+
if request.method:
148+
request.method = request.method.upper()
138149
if request.headers:
139150
_redact_headers(request.headers)
140151
uri = request.uri
@@ -316,6 +327,48 @@ def setup_vcr(vcr):
316327
return vcr
317328

318329

330+
@pytest.fixture(name="patch_vcr_aiohttp_stream", scope="module", autouse=True)
331+
def fixture_patch_vcr_aiohttp_stream():
332+
# Allows the async tests to not be stuck in infinite loop when streaming
333+
# a VCR cassette with aiohttp stubs.
334+
# https://github.com/kevin1024/vcrpy/issues/927
335+
if ClientConnectionError is None or aiohttp_stubs is None:
336+
return
337+
338+
class _ReplayMockStream(aiohttp_stubs.MockStream):
339+
# Keep vcrpy's stream behavior, but ignore aiohttp's
340+
# close-time ClientConnectionError("Connection closed") during
341+
# cassette replay, where the full response is already buffered
342+
# and this condition should be treated as normal EOF.
343+
def set_exception(self, exc):
344+
if isinstance(exc, ClientConnectionError) and exc.args == (
345+
"Connection closed",
346+
):
347+
return
348+
super().set_exception(exc)
349+
350+
class _ReplayMockClientResponse(aiohttp_stubs.MockClientResponse):
351+
def __init__(self, *args, **kwargs):
352+
super().__init__(*args, **kwargs)
353+
self._mock_content_stream = None
354+
355+
@property
356+
def content(self):
357+
# vcrpy's aiohttp MockClientResponse.content creates a fresh stream object
358+
# on every property access. google-genai async streaming repeatedly reads
359+
# response.content.readline() and expects the same stream instance until EOF is
360+
# reached.
361+
if self._mock_content_stream is None:
362+
body = self._body or b""
363+
stream = _ReplayMockStream()
364+
stream.feed_data(body)
365+
stream.feed_eof()
366+
self._mock_content_stream = stream
367+
return self._mock_content_stream
368+
369+
aiohttp_stubs.MockClientResponse = _ReplayMockClientResponse
370+
371+
319372
@pytest.fixture(name="instrumentor")
320373
def fixture_instrumentor():
321374
return GoogleGenAiSdkInstrumentor()

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ pytest==7.4.4
4040
pytest-asyncio==0.21.0
4141
pytest-vcr==1.0.2
4242

43-
google-auth==2.38.0
44-
google-genai==1.32.0
43+
google-auth==2.47.0
44+
45+
google-genai==1.47.0; python_version < "3.10"
46+
google-genai==1.64.0; python_version >= "3.10"
4547

4648
# Install locally from the folder. This path is relative to the
4749
# root directory, given invocation from "tox" at root level.

0 commit comments

Comments
 (0)