Skip to content

Commit 58245f6

Browse files
authored
Merge branch 'main' into revise-patch-release-instrunctions
2 parents cd5e327 + d185288 commit 58245f6

52 files changed

Lines changed: 2336 additions & 227 deletions

Some content is hidden

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

.github/labeler.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
gen-ai:
2+
- changed-files:
3+
- any-glob-to-any-file:
4+
- 'instrumentation-genai/**'
5+
- 'util/opentelemetry-util-genai/**'
6+
- 'docs/instrumentation-genai/**'

.github/workflows/labeler.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: PR Labeler
2+
3+
on:
4+
pull_request_target:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
label:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
steps:
16+
- uses: actions/labeler@v6
17+
with:
18+
sync-labels: false

CHANGELOG.md

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

4545
### Added
4646

47+
- Enabled the flake8-tidy-import plugins rules for the ruff linter. These rules throw warnings for relative imports in the modules.
48+
([#4395](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4395))
4749
- `opentelemetry-instrumentation-asgi`: Respect `suppress_http_instrumentation` context in ASGI middleware to skip server span creation when HTTP instrumentation is suppressed
4850
([#4375](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4375))
4951
- `opentelemetry-instrumentation-confluent-kafka`: Loosen confluent-kafka upper bound to <3.0.0

CONTRIBUTING.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Before you can contribute, you will need to sign the [Contributor License Agreem
1717

1818
Please also read the [OpenTelemetry Contributor Guide](https://github.com/open-telemetry/community/blob/main/guides/contributor/README.md).
1919

20+
If you are using AI agents to assist with contributions, please read [AGENTS.md](AGENTS.md) for guidance on how to use them responsibly in this project.
21+
2022
## Index
2123

2224
- [Contributing to opentelemetry-python-contrib](#contributing-to-opentelemetry-python-contrib)
@@ -204,7 +206,13 @@ git commit
204206
git push fork feature
205207
```
206208

207-
Open a pull request against the main `opentelemetry-python-contrib` repo.
209+
Open a pull request (PR) against the main `opentelemetry-python-contrib` repo.
210+
211+
A descriptive PR title will help the community better triage and review your changes. Make sure to prefix with the name(s) of the package/subdirectory/domain that your PR updates. Following any of these examples will help:
212+
213+
* "opentelemetry-instrumentation-dbapi: add client operation duration metrics"
214+
* "GenAI Utils: Add _BaseAgent base class and agent creation lifecycle"
215+
* "docs(google-genai): document config recording environment variables"
208216

209217
### How to Receive Comments
210218

instrumentation-genai/AGENTS.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,32 @@ This layer is responsible only for:
1919
Everything else (span creation, metric recording, event emission, context propagation)
2020
belongs in `util/opentelemetry-util-genai`.
2121

22-
## 2. Invocation Pattern
22+
## 2. TelemetryHandler Initialization
23+
24+
Construct `TelemetryHandler` once inside `_instrument()`, passing all OTel providers and the
25+
completion hook. Always prefer an explicitly injected hook (`kwargs.get("completion_hook")`)
26+
over the entry-point hook loaded by `load_completion_hook()`, so test code can override the
27+
hook without touching the environment.
28+
29+
```python
30+
from opentelemetry.util.genai.completion_hook import load_completion_hook
31+
from opentelemetry.util.genai.handler import TelemetryHandler
32+
33+
def _instrument(self, **kwargs):
34+
tracer_provider = kwargs.get("tracer_provider")
35+
meter_provider = kwargs.get("meter_provider")
36+
logger_provider = kwargs.get("logger_provider")
37+
38+
handler = TelemetryHandler(
39+
tracer_provider=tracer_provider,
40+
meter_provider=meter_provider,
41+
logger_provider=logger_provider,
42+
completion_hook=kwargs.get("completion_hook") or load_completion_hook(),
43+
)
44+
# pass handler to each patch/wrapper function
45+
```
46+
47+
## 3. Invocation Pattern
2348

2449
Use `start_*()` and control span lifetime manually:
2550

@@ -36,7 +61,7 @@ except Exception as exc:
3661
raise
3762
```
3863

39-
## 3. Semantic conventions
64+
## 4. Semantic conventions
4065

4166
Attributes, spans, events, and metrics follow the
4267
[GenAI semantic conventions](https://github.com/open-telemetry/semantic-conventions/tree/main/docs/gen-ai).
@@ -45,14 +70,14 @@ Do not emit signals that are not covered by semconv.
4570
`gen_ai.*` attribute names and the enums for well-known values (e.g. `GenAiOutputTypeValues` for
4671
`gen_ai.output.type`) live in `opentelemetry.semconv._incubating.attributes.gen_ai_attributes`.
4772

48-
## 4. Tests
73+
## 5. Tests
4974

5075
- Use VCR cassettes for provider calls. Do not skip tests when an API key is missing.
5176
- Cover streaming and non-streaming variants when both exist.
5277
- Cover error scenarios, at minimum: provider error / endpoint unavailable, stream interrupted by
5378
network, stream closed early by the caller.
5479

55-
## 5. Examples
80+
## 6. Examples
5681

5782
New instrumentations ship a minimal example under the package's `examples/` directory, with
5883
both a `manual/` setup and a `zero-code/` (auto-instrumentation) variant.

instrumentation-genai/opentelemetry-instrumentation-anthropic/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+
- Update `opentelemetry-util-genai` dependency range to `>= 0.4b0.dev, <0.5b0`
11+
([#4520](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4520))
1012
- Fix compatibility with wrapt 2.x by using positional arguments in `wrap_function_wrapper()` calls
1113
([#4445](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4445))
1214

instrumentation-genai/opentelemetry-instrumentation-anthropic/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies = [
2828
"opentelemetry-api ~= 1.39",
2929
"opentelemetry-instrumentation ~= 0.60b0",
3030
"opentelemetry-semantic-conventions ~= 0.60b0",
31-
"opentelemetry-util-genai >= 0.2b0, <0.4b0",
31+
"opentelemetry-util-genai >= 0.4b0.dev, <0.5b0",
3232
]
3333

3434
[project.optional-dependencies]

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/requirements.oldest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# This variant of the requirements aims to test the system using
1616
# the oldest supported version of external dependencies.
1717

18-
-e util/opentelemetry-util-genai
18+
-e util/opentelemetry-util-genai # todo: update to 0.4b0 when it's released
1919
anthropic==0.51.0
2020
pytest==7.4.4
2121
pytest-vcr==1.0.2

instrumentation-genai/opentelemetry-instrumentation-claude-agent-sdk/CHANGELOG.md

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

88
## Unreleased
99

10+
- Update `opentelemetry-util-genai` dependency range to `>= 0.4b0.dev, <0.5b0`
11+
([#4520](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4520))
12+
1013
### Added
1114

instrumentation-genai/opentelemetry-instrumentation-claude-agent-sdk/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencies = [
2727
"opentelemetry-api ~= 1.39",
2828
"opentelemetry-instrumentation ~= 0.60b0",
2929
"opentelemetry-semantic-conventions ~= 0.60b0",
30-
"opentelemetry-util-genai >= 0.2b0, <0.4b0",
30+
"opentelemetry-util-genai >= 0.2b0, <0.5b0",
3131
]
3232

3333
[project.optional-dependencies]

0 commit comments

Comments
 (0)