Skip to content

Commit fc186af

Browse files
authored
Merge branch 'main' into main
2 parents 388eccb + e2ba6d4 commit fc186af

File tree

65 files changed

+4707
-1726
lines changed

Some content is hidden

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

65 files changed

+4707
-1726
lines changed

CHANGELOG.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Fixed
1515

16+
- `opentelemetry-instrumentation-system-metrics`: fix loading on Google Cloud Run
17+
([#3533](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3533))
18+
- `opentelemetry-instrumentation-fastapi`: fix wrapping of middlewares
19+
([#3012](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3012))
20+
- `opentelemetry-instrumentation-starlette` Remove max version constraint on starlette
21+
([#3456](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3456))
22+
- `opentelemetry-instrumentation-urllib3`: proper bucket boundaries in stable semconv http duration metrics
23+
([#3518](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3518))
24+
- `opentelemetry-instrumentation-urllib`: proper bucket boundaries in stable semconv http duration metrics
25+
([#3519](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3519))
26+
- `opentelemetry-instrumentation-falcon`: proper bucket boundaries in stable semconv http duration
27+
([#3525](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3525))
28+
- `opentelemetry-instrumentation-wsgi`: add explicit http duration buckets for stable semconv
29+
([#3527](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3527))
30+
- `opentelemetry-instrumentation-asgi`: add explicit http duration buckets for stable semconv
31+
([#3526](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3526))
32+
- `opentelemetry-instrumentation-flask`: proper bucket boundaries in stable semconv http duration
33+
([#3523](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3523))
34+
- `opentelemetry-instrumentation-django`: proper bucket boundaries in stable semconv http duration
35+
([#3524](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3524))
36+
- `opentelemetry-instrumentation-grpc`: support non-list interceptors
37+
([#3520](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3520))
38+
- `opentelemetry-instrumentation-botocore` Ensure spans end on early stream closure for Bedrock Streaming APIs
39+
([#3481](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3481))
1640
- `opentelemetry-instrumentation-sqlalchemy` Respect suppress_instrumentation functionality
1741
([#3477](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3477))
1842

43+
### Breaking changes
44+
45+
- `opentelemetry-instrumentation-botocore` Use `cloud.region` instead of `aws.region` span attribute as per semantic conventions.
46+
([#3474](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3474))
47+
- `opentelemetry-instrumentation-fastapi`: Drop support for FastAPI versions earlier than `0.92`
48+
([#3012](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3012))
1949

2050
## Version 1.33.0/0.54b0 (2025-05-09)
2151

@@ -44,7 +74,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4474
- `opentelemetry-instrumentation-botocore` Capture server attributes for botocore API calls
4575
([#3448](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3448))
4676

47-
4877
## Version 1.32.0/0.53b0 (2025-04-10)
4978

5079
### Added

RELEASING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
(otherwise the workflow will pick up the version from `main` and just remove the `.dev` suffix).
1010
* Review the two pull requests that it creates.
1111
(one is targeted to the release branch and one is targeted to `main`).
12-
* The builds will fail for both the `main` and release pr because of validation rules. Follow the [release workflow](https://github.com/open-telemetry/opentelemetry-python/blob/main/RELEASING.md) for the core repo up until this same point. Change the SHAs of each PR to point at each other to get the `main` and release builds to pass.
12+
* The builds will fail for the release PR because of validation rules. Follow the [release workflow](https://github.com/open-telemetry/opentelemetry-python/blob/main/RELEASING.md) for the core repo up until this same point.
13+
* Close and reopen the PR so that the workflow will take into account the label automation we have in place
1314
* Merge the release PR.
1415
* Merge the PR to main (this can be done separately from [making the release](#making-the-release))
1516

@@ -40,13 +41,16 @@ The workflow will create two pull requests, one against the `main` and one again
4041
* Press the "Run workflow" button, then select the release branch from the dropdown list,
4142
e.g. `release/v1.9.x`, then enter the pull request number that you want to backport,
4243
then click the "Run workflow" button below that.
44+
* Add the label `backport` to the generated pull request.
45+
* In case label automation doesn't work, just close and reopen the PR so that the workflow will take into account the label automation we have in place.
4346
* Review and merge the backport pull request that it generates.
4447
* Merge a pull request to the release branch updating the `CHANGELOG.md`.
4548
* The heading for the unreleased entries should be `## Unreleased`.
4649
* Run the [Prepare patch release workflow](https://github.com/open-telemetry/opentelemetry-python-contrib/actions/workflows/prepare-patch-release.yml).
4750
* Press the "Run workflow" button, then select the release branch from the dropdown list,
4851
e.g. `release/v1.9.x`, and click the "Run workflow" button below that.
4952
* Review and merge the pull request that it creates for updating the version.
53+
* Note: If you are doing a patch release in `-contrib` repo, you should also do an equivalent patch release in `-core` repo (even if there's no fix to release), otherwise tests in CI will fail.
5054

5155
### Preparing a patch release for individual package
5256

docs/nitpick-exceptions.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ py-class=
4444
psycopg.Connection
4545
psycopg.AsyncConnection
4646
ObjectProxy
47+
fastapi.applications.FastAPI
4748

4849
any=
4950
; API

exporter/opentelemetry-exporter-richconsole/src/opentelemetry/exporter/richconsole/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@
6464
import opentelemetry.trace
6565
from opentelemetry.sdk.trace import ReadableSpan
6666
from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult
67-
from opentelemetry.semconv.trace import SpanAttributes
67+
from opentelemetry.semconv._incubating.attributes.db_attributes import (
68+
DB_STATEMENT,
69+
)
6870

6971

7072
def _ns_to_time(nanoseconds):
@@ -120,7 +122,7 @@ def _child_add_optional_attributes(child: Tree, span: ReadableSpan):
120122
label=Text.from_markup("[bold cyan]Attributes :[/bold cyan] ")
121123
)
122124
for attribute in span.attributes:
123-
if attribute == SpanAttributes.DB_STATEMENT:
125+
if attribute == DB_STATEMENT:
124126
attributes.add(
125127
Text.from_markup(f"[bold cyan]{attribute} :[/bold cyan] ")
126128
)

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+
- Add automatic instrumentation to tool call functions ([#3446](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3446))
11+
1012
## Version 0.2b0 (2025-04-28)
1113

1214
- Add more request configuration options to the span attributes ([#3374](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3374))

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

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import copy
1516
import functools
1617
import json
1718
import logging
@@ -28,6 +29,7 @@
2829
ContentListUnionDict,
2930
ContentUnion,
3031
ContentUnionDict,
32+
GenerateContentConfig,
3133
GenerateContentConfigOrDict,
3234
GenerateContentResponse,
3335
)
@@ -44,6 +46,7 @@
4446
from .dict_util import flatten_dict
4547
from .flags import is_content_recording_enabled
4648
from .otel_wrapper import OTelWrapper
49+
from .tool_call_wrapper import wrapped as wrapped_tool
4750

4851
_logger = logging.getLogger(__name__)
4952

@@ -206,6 +209,29 @@ def _get_response_property(response: GenerateContentResponse, path: str):
206209
return current_context
207210

208211

212+
def _coerce_config_to_object(
213+
config: GenerateContentConfigOrDict,
214+
) -> GenerateContentConfig:
215+
if isinstance(config, GenerateContentConfig):
216+
return config
217+
# Input must be a dictionary; convert by invoking the constructor.
218+
return GenerateContentConfig(**config)
219+
220+
221+
def _wrapped_config_with_tools(
222+
otel_wrapper: OTelWrapper,
223+
config: GenerateContentConfig,
224+
**kwargs,
225+
):
226+
if not config.tools:
227+
return config
228+
result = copy.copy(config)
229+
result.tools = [
230+
wrapped_tool(tool, otel_wrapper, **kwargs) for tool in config.tools
231+
]
232+
return result
233+
234+
209235
class _GenerateContentInstrumentationHelper:
210236
def __init__(
211237
self,
@@ -229,6 +255,17 @@ def __init__(
229255
generate_content_config_key_allowlist or AllowList()
230256
)
231257

258+
def wrapped_config(
259+
self, config: Optional[GenerateContentConfigOrDict]
260+
) -> Optional[GenerateContentConfig]:
261+
if config is None:
262+
return None
263+
return _wrapped_config_with_tools(
264+
self._otel_wrapper,
265+
_coerce_config_to_object(config),
266+
extra_span_attributes={"gen_ai.system": self._genai_system},
267+
)
268+
232269
def start_span_as_current_span(
233270
self, model_name, function_name, end_on_exit=True
234271
):
@@ -556,7 +593,7 @@ def instrumented_generate_content(
556593
self,
557594
model=model,
558595
contents=contents,
559-
config=config,
596+
config=helper.wrapped_config(config),
560597
**kwargs,
561598
)
562599
helper.process_response(response)
@@ -601,7 +638,7 @@ def instrumented_generate_content_stream(
601638
self,
602639
model=model,
603640
contents=contents,
604-
config=config,
641+
config=helper.wrapped_config(config),
605642
**kwargs,
606643
):
607644
helper.process_response(response)
@@ -646,7 +683,7 @@ async def instrumented_generate_content(
646683
self,
647684
model=model,
648685
contents=contents,
649-
config=config,
686+
config=helper.wrapped_config(config),
650687
**kwargs,
651688
)
652689
helper.process_response(response)
@@ -694,7 +731,7 @@ async def instrumented_generate_content_stream(
694731
self,
695732
model=model,
696733
contents=contents,
697-
config=config,
734+
config=helper.wrapped_config(config),
698735
**kwargs,
699736
)
700737
except Exception as error: # pylint: disable=broad-exception-caught

0 commit comments

Comments
 (0)