Skip to content

Commit 031369b

Browse files
Merge branch 'main' into google_genai_attribute_improvements
2 parents 5153080 + 6bde73c commit 031369b

File tree

15 files changed

+229
-84
lines changed
  • .github/workflows
  • instrumentation-genai
    • opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai
    • opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2
  • instrumentation
    • opentelemetry-instrumentation-botocore
    • opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc
    • opentelemetry-instrumentation-httpx
    • opentelemetry-instrumentation-kafka-python/src/opentelemetry/instrumentation/kafka
    • opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika
    • opentelemetry-instrumentation-remoulade/src/opentelemetry/instrumentation/remoulade
    • opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy
  • scripts

15 files changed

+229
-84
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: OSSF Scorecard
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
schedule:
8+
- cron: "10 6 * * 1" # once a week
9+
workflow_dispatch:
10+
11+
permissions: read-all
12+
13+
jobs:
14+
analysis:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
# Needed for Code scanning upload
18+
security-events: write
19+
# Needed for GitHub OIDC token if publish_results is true
20+
id-token: write
21+
steps:
22+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
with:
24+
persist-credentials: false
25+
26+
- uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
27+
with:
28+
results_file: results.sarif
29+
results_format: sarif
30+
publish_results: true
31+
32+
# Upload the results as artifacts (optional). Commenting out will disable
33+
# uploads of run results in SARIF format to the repository Actions tab.
34+
# https://docs.github.com/en/actions/advanced-guides/storing-workflow-data-as-artifacts
35+
- name: "Upload artifact"
36+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
37+
with:
38+
name: SARIF file
39+
path: results.sarif
40+
retention-days: 5
41+
42+
# Upload the results to GitHub's code scanning dashboard (optional).
43+
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
44+
- name: "Upload to code-scanning"
45+
uses: github/codeql-action/upload-sarif@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
46+
with:
47+
sarif_file: results.sarif

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- `opentelemetry-instrumentation-dbapi`, `opentelemetry-instrumentation-django`,
2626
`opentelemetry-instrumentation-sqlalchemy`: Fix sqlcomment for non string query and composable object.
2727
([#3113](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3113))
28+
- `opentelemetry-instrumentation-grpc` Fix error when using gprc versions <= 1.50.0 with unix sockets.
29+
([[#3393](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/3393)])
2830

2931
## Version 1.31.0/0.52b0 (2025-03-12)
3032

instrumentation-genai/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
| Instrumentation | Supported Packages | Metrics support | Semconv status |
3+
| --------------- | ------------------ | --------------- | -------------- |
4+
| [opentelemetry-instrumentation-google-genai](./opentelemetry-instrumentation-google-genai) | google-genai >= 1.0.0 | No | development
5+
| [opentelemetry-instrumentation-openai-v2](./opentelemetry-instrumentation-openai-v2) | openai >= 1.26.0 | Yes | development
6+
| [opentelemetry-instrumentation-vertexai](./opentelemetry-instrumentation-vertexai) | google-cloud-aiplatform >= 1.64 | No | development
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
_instruments = ("google-genai >= 1.0.0",)

instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/package.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@
1414

1515

1616
_instruments = ("openai >= 1.26.0",)
17+
18+
_supports_metrics = True

instrumentation/opentelemetry-instrumentation-botocore/README.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,44 @@ OpenTelemetry Botocore Tracing
88

99
This library allows tracing requests made by the Botocore library.
1010

11+
Extensions
12+
----------
13+
14+
The instrumentation supports creating extensions for AWS services for enriching what is collected. We have extensions
15+
for the following AWS services:
16+
17+
- Bedrock Runtime
18+
- DynamoDB
19+
- Lambda
20+
- SNS
21+
- SQS
22+
23+
Bedrock Runtime
24+
***************
25+
26+
This extension implements the GenAI semantic conventions for the following API calls:
27+
28+
- Converse
29+
- ConverseStream
30+
- InvokeModel
31+
- InvokeModelWithResponseStream
32+
33+
For the Converse and ConverseStream APIs tracing, events and metrics are implemented.
34+
35+
For the InvokeModel and InvokeModelWithResponseStream APIs tracing, events and metrics implemented only for a subset of
36+
the available models, namely:
37+
38+
- Amazon Titan models
39+
- Amazon Nova models
40+
- Anthropic Claude
41+
42+
Tool calls with InvokeModel and InvokeModelWithResponseStream APIs are supported with:
43+
44+
- Amazon Nova models
45+
- Anthropic Claude 3+
46+
47+
If you don't have an application using Bedrock APIs yet, try our `zero-code examples <examples/bedrock-runtime/zero-code>`_.
48+
1149
Installation
1250
------------
1351

instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -78,40 +78,6 @@ def response_hook(span, service_name, operation_name, result):
7878
)
7979
ec2 = session.create_client("ec2", region_name="us-west-2")
8080
ec2.describe_instances()
81-
82-
Extensions
83-
----------
84-
85-
The instrumentation supports creating extensions for AWS services for enriching what is collected. We have extensions
86-
for the following AWS services:
87-
88-
- Bedrock Runtime
89-
- DynamoDB
90-
- Lambda
91-
- SNS
92-
- SQS
93-
94-
Bedrock Runtime
95-
***************
96-
97-
This extension implements the GenAI semantic conventions for the following API calls:
98-
99-
- Converse
100-
- ConverseStream
101-
- InvokeModel
102-
- InvokeModelWithResponseStream
103-
104-
For the Converse and ConverseStream APIs tracing, events and metrics are implemented.
105-
106-
For the InvokeModel and InvokeModelWithResponseStream APIs tracing, events and metrics implemented only for a subset of
107-
the available models, namely:
108-
- Amazon Titan models
109-
- Amazon Nova models
110-
- Anthropic Claude
111-
112-
Tool calls with InvokeModel and InvokeModelWithResponseStream APIs are supported with:
113-
- Amazon Nova models
114-
- Anthropic Claude 3+
11581
"""
11682

11783
import logging

instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def _start_span(
239239
# * ipv4:127.0.0.1:57284
240240
# * ipv4:10.2.1.1:57284,127.0.0.1:57284
241241
#
242-
if context.peer() != "unix:":
242+
if not context.peer().startswith("unix:"):
243243
try:
244244
ip, port = (
245245
context.peer()

instrumentation/opentelemetry-instrumentation-httpx/README.rst

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,22 @@ When using the instrumentor, all clients will automatically trace requests.
2727

2828
.. code-block:: python
2929
30-
import httpx
31-
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
30+
import httpx
31+
import asyncio
32+
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
33+
34+
url = "https://example.com"
35+
HTTPXClientInstrumentor().instrument()
36+
37+
with httpx.Client() as client:
38+
response = client.get(url)
3239
33-
url = "https://some.url/get"
34-
HTTPXClientInstrumentor().instrument()
40+
async def get(url):
41+
async with httpx.AsyncClient() as client:
42+
response = await client.get(url)
3543
36-
with httpx.Client() as client:
37-
response = client.get(url)
44+
asyncio.run(get(url))
3845
39-
async with httpx.AsyncClient() as client:
40-
response = await client.get(url)
4146
4247
Instrumenting single clients
4348
****************************
@@ -49,18 +54,21 @@ use the `instrument_client` method.
4954
.. code-block:: python
5055
5156
import httpx
57+
import asyncio
5258
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
5359
54-
url = "https://some.url/get"
60+
url = "https://example.com"
5561
56-
with httpx.Client(transport=telemetry_transport) as client:
62+
with httpx.Client() as client:
5763
HTTPXClientInstrumentor.instrument_client(client)
5864
response = client.get(url)
5965
60-
async with httpx.AsyncClient(transport=telemetry_transport) as client:
61-
HTTPXClientInstrumentor.instrument_client(client)
62-
response = await client.get(url)
66+
async def get(url):
67+
async with httpx.AsyncClient() as client:
68+
HTTPXClientInstrumentor.instrument_client(client)
69+
response = await client.get(url)
6370
71+
asyncio.run(get(url))
6472
6573
Uninstrument
6674
************
@@ -91,12 +99,13 @@ If you don't want to use the instrumentor class, you can use the transport class
9199
.. code-block:: python
92100
93101
import httpx
102+
import asyncio
94103
from opentelemetry.instrumentation.httpx import (
95104
AsyncOpenTelemetryTransport,
96105
SyncOpenTelemetryTransport,
97106
)
98107
99-
url = "https://some.url/get"
108+
url = "https://example.com"
100109
transport = httpx.HTTPTransport()
101110
telemetry_transport = SyncOpenTelemetryTransport(transport)
102111
@@ -106,8 +115,11 @@ If you don't want to use the instrumentor class, you can use the transport class
106115
transport = httpx.AsyncHTTPTransport()
107116
telemetry_transport = AsyncOpenTelemetryTransport(transport)
108117
109-
async with httpx.AsyncClient(transport=telemetry_transport) as client:
110-
response = await client.get(url)
118+
async def get(url):
119+
async with httpx.AsyncClient(transport=telemetry_transport) as client:
120+
response = await client.get(url)
121+
122+
asyncio.run(get(url))
111123
112124
113125
Request and response hooks
@@ -158,6 +170,7 @@ Or if you are using the transport classes directly:
158170

159171
.. code-block:: python
160172
173+
import httpx
161174
from opentelemetry.instrumentation.httpx import SyncOpenTelemetryTransport, AsyncOpenTelemetryTransport
162175
163176
def request_hook(span, request):

instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,21 @@
2323
2424
.. code-block:: python
2525
26-
import httpx
27-
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
26+
import httpx
27+
import asyncio
28+
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
2829
29-
url = "https://some.url/get"
30-
HTTPXClientInstrumentor().instrument()
30+
url = "https://example.com"
31+
HTTPXClientInstrumentor().instrument()
3132
32-
with httpx.Client() as client:
33-
response = client.get(url)
33+
with httpx.Client() as client:
34+
response = client.get(url)
3435
35-
async with httpx.AsyncClient() as client:
36-
response = await client.get(url)
36+
async def get(url):
37+
async with httpx.AsyncClient() as client:
38+
response = await client.get(url)
39+
40+
asyncio.run(get(url))
3741
3842
Instrumenting single clients
3943
****************************
@@ -45,18 +49,21 @@
4549
.. code-block:: python
4650
4751
import httpx
52+
import asyncio
4853
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
4954
50-
url = "https://some.url/get"
55+
url = "https://example.com"
5156
52-
with httpx.Client(transport=telemetry_transport) as client:
57+
with httpx.Client() as client:
5358
HTTPXClientInstrumentor.instrument_client(client)
5459
response = client.get(url)
5560
56-
async with httpx.AsyncClient(transport=telemetry_transport) as client:
57-
HTTPXClientInstrumentor.instrument_client(client)
58-
response = await client.get(url)
61+
async def get(url):
62+
async with httpx.AsyncClient() as client:
63+
HTTPXClientInstrumentor.instrument_client(client)
64+
response = await client.get(url)
5965
66+
asyncio.run(get(url))
6067
6168
Uninstrument
6269
************
@@ -65,17 +72,17 @@
6572
6673
.. code-block:: python
6774
68-
import httpx
69-
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
75+
import httpx
76+
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
7077
71-
HTTPXClientInstrumentor().instrument()
72-
client = httpx.Client()
78+
HTTPXClientInstrumentor().instrument()
79+
client = httpx.Client()
7380
74-
# Uninstrument a specific client
75-
HTTPXClientInstrumentor.uninstrument_client(client)
81+
# Uninstrument a specific client
82+
HTTPXClientInstrumentor.uninstrument_client(client)
7683
77-
# Uninstrument all clients
78-
HTTPXClientInstrumentor().uninstrument()
84+
# Uninstrument all clients
85+
HTTPXClientInstrumentor().uninstrument()
7986
8087
8188
Using transports directly
@@ -87,12 +94,13 @@
8794
.. code-block:: python
8895
8996
import httpx
97+
import asyncio
9098
from opentelemetry.instrumentation.httpx import (
9199
AsyncOpenTelemetryTransport,
92100
SyncOpenTelemetryTransport,
93101
)
94102
95-
url = "https://some.url/get"
103+
url = "https://example.com"
96104
transport = httpx.HTTPTransport()
97105
telemetry_transport = SyncOpenTelemetryTransport(transport)
98106
@@ -102,9 +110,11 @@
102110
transport = httpx.AsyncHTTPTransport()
103111
telemetry_transport = AsyncOpenTelemetryTransport(transport)
104112
105-
async with httpx.AsyncClient(transport=telemetry_transport) as client:
106-
response = await client.get(url)
113+
async def get(url):
114+
async with httpx.AsyncClient(transport=telemetry_transport) as client:
115+
response = await client.get(url)
107116
117+
asyncio.run(get(url))
108118
109119
Request and response hooks
110120
***************************
@@ -154,6 +164,7 @@ async def async_response_hook(span, request, response):
154164
155165
.. code-block:: python
156166
167+
import httpx
157168
from opentelemetry.instrumentation.httpx import SyncOpenTelemetryTransport, AsyncOpenTelemetryTransport
158169
159170
def request_hook(span, request):

0 commit comments

Comments
 (0)