Skip to content

Commit 46d14f9

Browse files
authored
Merge branch 'main' into 4209
2 parents fec2c6d + d9d586c commit 46d14f9

45 files changed

Lines changed: 1187 additions & 62 deletions

File tree

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

CONTRIBUTING.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,13 @@ git commit
206206
git push fork feature
207207
```
208208

209-
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"
210216

211217
### How to Receive Comments
212218

RELEASING.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ To keep the process lightweight, it's OK to approve the PRs you generate and mer
4444

4545
## Preparing a new patch release
4646

47-
* Backport pull request(s) to the release branch.
47+
### Backporting
48+
49+
Creating manual backports of pull request(s) requires the `backport` label to be added in order to have a green CI. Even if there where
50+
no changes on a repo the patch release preparation workflow requires an empty `## Unreleased` header in `CHANGELOG.md`.
51+
52+
Backport of pull request(s) can be automated by a workflow only if there where no changes that will create conflicts in the release
53+
branch, unfortunately every `CHANGELOG.md` change will create one.
54+
55+
To use the workflow to backport pull request(s) to the release branch:
4856
* Run the [Backport workflow](https://github.com/open-telemetry/opentelemetry-python-contrib/actions/workflows/backport.yml).
4957
* Press the "Run workflow" button, then select the release branch from the dropdown list,
5058
e.g. `release/v1.9.x`, then enter the pull request number that you want to backport,
@@ -54,6 +62,9 @@ To keep the process lightweight, it's OK to approve the PRs you generate and mer
5462
* Review and merge the backport pull request that it generates.
5563
* Merge a pull request to the release branch updating the `CHANGELOG.md`.
5664
* The heading for the unreleased entries should be `## Unreleased`.
65+
66+
### Preparing a patch release
67+
5768
* Run the [Prepare patch release workflow](https://github.com/open-telemetry/opentelemetry-python-contrib/actions/workflows/prepare-patch-release.yml).
5869
* Press the "Run workflow" button, then select the release branch from the dropdown list,
5970
e.g. `release/v1.9.x`, and click the "Run workflow" button below that.

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)