Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8190143

Browse files
authoredMar 10, 2025··
Merge branch 'main' into fix/sns-warnings
2 parents 582854f + d5dce5d commit 8190143

File tree

21 files changed

+474
-195
lines changed

21 files changed

+474
-195
lines changed
 

‎CHANGELOG.md

+6-2
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))
@@ -44,6 +44,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4444
([#3249](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3249))
4545
- `opentelemetry-instrumentation-asyncpg` Fix fallback for empty queries.
4646
([#3253](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3253))
47+
- `opentelemetry-instrumentation-threading` Fix broken context typehints
48+
([#3322](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3322))
49+
- `opentelemetry-instrumentation-requests` always record span status code in duration metric
50+
([#3323](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3323))
4751

4852
## Version 1.30.0/0.51b0 (2025-02-03)
4953

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

104108
### Breaking changes
105109

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

‎README.md

+2-2
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

+1-1
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-vertexai/CHANGELOG.md

+3
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

+28-15
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

+4-2
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")
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)
Please sign in to comment.