Skip to content

Commit ed424fd

Browse files
Merge branch 'main' into google_genai_test_improvements
2 parents 7b5605b + ad2fe81 commit ed424fd

File tree

21 files changed

+465
-196
lines changed

21 files changed

+465
-196
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
- `opentelemetry-instrumentation-openai-v2` Update doc for OpenAI Instrumentation to support OpenAI Compatible Platforms
1717
([#3279](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3279))
18-
- `opentelemetry-instrumentation-system-metrics` Add `process` metrics and deprecated `process.runtime` prefixed ones
18+
- `opentelemetry-instrumentation-system-metrics` Add `process` metrics and deprecated `process.runtime` prefixed ones
1919
([#3250](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3250))
2020
- `opentelemetry-instrumentation-botocore` Add support for GenAI user events and lazy initialize tracer
2121
([#3258](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3258))
@@ -41,6 +41,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4141
([#3247](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3247))
4242
- `opentelemetry-instrumentation-asyncpg` Fix fallback for empty queries.
4343
([#3253](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3253))
44+
- `opentelemetry-instrumentation-threading` Fix broken context typehints
45+
([#3322](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3322))
46+
- `opentelemetry-instrumentation-requests` always record span status code in duration metric
47+
([#3323](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3323))
4448

4549
## Version 1.30.0/0.51b0 (2025-02-03)
4650

@@ -100,7 +104,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
100104

101105
### Breaking changes
102106

103-
- `opentelemetry-exporter-prometheus-remote-write` updated protobuf required version from 4.21 to 5.26 and regenerated protobufs
107+
- `opentelemetry-exporter-prometheus-remote-write` updated protobuf required version from 4.21 to 5.26 and regenerated protobufs
104108
([#3219](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3219))
105109
- `opentelemetry-instrumentation-sqlalchemy` including sqlcomment in `db.statement` span attribute value is now opt-in
106110
([#3112](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3112))

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ To release a package as `1.0` stable, the package:
101101

102102
## Semantic Convention status of instrumentations
103103

104-
In our efforts to maintain optimal user experience and prevent breaking changes for transitioning into stable semantic conventions, OpenTelemetry Python is adopting the semantic convention migration plan for several instrumentations. Currently this plan is only being adopted for [HTTP-related instrumentations](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/non-normative/http-migration.md), but will eventually cover all types. Please refer to the `semconv status` column of the [instrumentation README](instrumentation/README.md) of the current status of instrumentations' semantic conventions. The possible values are `experimental`, `stable` and `migration` referring to [status](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.31.0/specification/document-status.md#lifecycle-status) of that particular semantic convention. `Migration` refers to an instrumentation that currently supports the migration plan.
104+
In our efforts to maintain optimal user experience and prevent breaking changes for transitioning into stable semantic conventions, OpenTelemetry Python is adopting the semantic convention migration plan for several instrumentations. Currently this plan is only being adopted for [HTTP-related instrumentations](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/non-normative/http-migration.md), but will eventually cover all types. Please refer to the `semconv status` column of the [instrumentation README](instrumentation/README.md) of the current status of instrumentations' semantic conventions. The possible values are `development`, `stable` and `migration` referring to [status](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.31.0/specification/document-status.md#lifecycle-status) of that particular semantic convention. `Migration` refers to an instrumentation that currently supports the migration plan.
105105

106106
## Contributing
107107

@@ -113,7 +113,7 @@ Meeting notes are available as a public [Google doc](https://docs.google.com/doc
113113

114114
Approvers ([@open-telemetry/python-approvers](https://github.com/orgs/open-telemetry/teams/python-approvers)):
115115

116-
- [Emídio Neto](https://github.com/emdneto), Zenvia
116+
- [Emídio Neto](https://github.com/emdneto), PicPay
117117
- [Jeremy Voss](https://github.com/jeremydvoss), Microsoft
118118
- [Owais Lone](https://github.com/owais), Splunk
119119
- [Pablo Collins](https://github.com/pmcollins), Splunk

gen-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-c dev-requirements.txt
22
astor==0.8.1
3-
jinja2==3.1.4
3+
jinja2==3.1.6
44
markupsafe==2.0.1
55
ruff==0.6.9
66
requests

instrumentation-genai/opentelemetry-instrumentation-google-genai/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## Version 0.1b0 (2025-03-05)
11+
1012
- Add support for async and streaming.
1113
([#3298](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3298))
1214

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
# This version should stay below "1.0" until the fundamentals
1818
# in "TODOS.md" have been addressed. Please revisit the TODOs
1919
# listed there before bumping to a stable version.
20-
__version__ = "0.1b0.dev"
20+
__version__ = "0.2b0.dev"

instrumentation-genai/opentelemetry-instrumentation-vertexai/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
- Implement uninstrument for `opentelemetry-instrumentation-vertexai`
11+
([#3328](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3328))
12+
1013
## Version 2.0b0 (2025-02-24)
1114

1215
- Added Vertex AI spans for request parameters

instrumentation-genai/opentelemetry-instrumentation-vertexai/src/opentelemetry/instrumentation/vertexai/__init__.py

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
from opentelemetry._events import get_event_logger
4949
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
50+
from opentelemetry.instrumentation.utils import unwrap
5051
from opentelemetry.instrumentation.vertexai.package import _instruments
5152
from opentelemetry.instrumentation.vertexai.patch import (
5253
generate_content_create,
@@ -56,6 +57,23 @@
5657
from opentelemetry.trace import get_tracer
5758

5859

60+
def _client_classes():
61+
# This import is very slow, do it lazily in case instrument() is not called
62+
63+
# pylint: disable=import-outside-toplevel
64+
from google.cloud.aiplatform_v1.services.prediction_service import (
65+
client,
66+
)
67+
from google.cloud.aiplatform_v1beta1.services.prediction_service import (
68+
client as client_v1beta1,
69+
)
70+
71+
return (
72+
client.PredictionServiceClient,
73+
client_v1beta1.PredictionServiceClient,
74+
)
75+
76+
5977
class VertexAIInstrumentor(BaseInstrumentor):
6078
def instrumentation_dependencies(self) -> Collection[str]:
6179
return _instruments
@@ -77,20 +95,15 @@ def _instrument(self, **kwargs: Any):
7795
event_logger_provider=event_logger_provider,
7896
)
7997

80-
wrap_function_wrapper(
81-
module="google.cloud.aiplatform_v1beta1.services.prediction_service.client",
82-
name="PredictionServiceClient.generate_content",
83-
wrapper=generate_content_create(
84-
tracer, event_logger, is_content_enabled()
85-
),
86-
)
87-
wrap_function_wrapper(
88-
module="google.cloud.aiplatform_v1.services.prediction_service.client",
89-
name="PredictionServiceClient.generate_content",
90-
wrapper=generate_content_create(
91-
tracer, event_logger, is_content_enabled()
92-
),
93-
)
98+
for client_class in _client_classes():
99+
wrap_function_wrapper(
100+
client_class,
101+
name="generate_content",
102+
wrapper=generate_content_create(
103+
tracer, event_logger, is_content_enabled()
104+
),
105+
)
94106

95107
def _uninstrument(self, **kwargs: Any) -> None:
96-
"""TODO: implemented in later PR"""
108+
for client_class in _client_classes():
109+
unwrap(client_class, "generate_content")

instrumentation-genai/opentelemetry-instrumentation-vertexai/tests/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ def instrument_no_content(
111111

112112
yield instrumentor
113113
os.environ.pop(OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT, None)
114-
instrumentor.uninstrument()
114+
if instrumentor.is_instrumented_by_opentelemetry:
115+
instrumentor.uninstrument()
115116

116117

117118
@pytest.fixture
@@ -130,7 +131,8 @@ def instrument_with_content(
130131

131132
yield instrumentor
132133
os.environ.pop(OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT, None)
133-
instrumentor.uninstrument()
134+
if instrumentor.is_instrumented_by_opentelemetry:
135+
instrumentor.uninstrument()
134136

135137

136138
@pytest.fixture(scope="module")
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from __future__ import annotations
16+
17+
import pytest
18+
from google.cloud.aiplatform_v1.services.prediction_service import client
19+
from google.cloud.aiplatform_v1beta1.services.prediction_service import (
20+
client as client_v1beta1,
21+
)
22+
23+
from opentelemetry.instrumentation.vertexai import VertexAIInstrumentor
24+
25+
26+
@pytest.fixture(
27+
name="client_class",
28+
params=[
29+
pytest.param(client.PredictionServiceClient, id="v1"),
30+
pytest.param(client_v1beta1.PredictionServiceClient, id="v1beta1"),
31+
],
32+
)
33+
def fixture_client_class(request: pytest.FixtureRequest):
34+
return request.param
35+
36+
37+
def test_instruments(
38+
instrument_with_content: VertexAIInstrumentor, client_class
39+
):
40+
assert hasattr(client_class.generate_content, "__wrapped__")
41+
42+
43+
def test_uninstruments(
44+
instrument_with_content: VertexAIInstrumentor, client_class
45+
):
46+
instrument_with_content.uninstrument()
47+
assert not hasattr(client_class.generate_content, "__wrapped__")

0 commit comments

Comments
 (0)