Skip to content

Commit 9a5e669

Browse files
authored
Merge branch 'main' into fix-redis-cluster-pipeline-commands
2 parents c1ceb7b + 34bfc28 commit 9a5e669

48 files changed

Lines changed: 1660 additions & 1434 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.

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,8 @@ target
6161

6262
# Benchmark result files
6363
*-benchmark.json
64+
65+
# opentelemetry-admin jobs
66+
opentelemetry-admin-jobs.txt
67+
68+
.claude/settings.local.json

.pylintrc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ persistent=yes
3737
# Specify a configuration file.
3838
#rcfile=
3939

40-
# When enabled, pylint would attempt to guess common misconfiguration and emit
41-
# user-friendly hints instead of false-positive error messages.
42-
suggestion-mode=yes
43-
4440
# Allow loading of arbitrary C extensions. Extensions are imported into the
4541
# active Python interpreter and may run arbitrary code.
4642
unsafe-load-any-extension=no
@@ -463,6 +459,9 @@ valid-metaclass-classmethod-first-arg=cls
463459
# Maximum number of arguments for function / method.
464460
max-args=5
465461

462+
# Maximum number of positional arguments for function / method.
463+
max-positional-arguments=12
464+
466465
# Maximum number of attributes for a class (see R0902).
467466
max-attributes=7
468467

AGENTS.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# OpenTelemetry Python Contrib
2+
3+
This file is here to steer AI assisted PRs towards being high quality and valuable contributions
4+
that do not create excessive maintainer burden.
5+
6+
Monorepo with 50+ OpenTelemetry instrumentation packages for Python.
7+
8+
## General Rules and Guidelines
9+
10+
The most important rule is not to post comments on issues or PRs that are AI-generated. Discussions
11+
on the OpenTelemetry repositories are for Users/Humans only.
12+
13+
Follow the PR scoping guidance in [CONTRIBUTING.md](CONTRIBUTING.md). Keep AI-assisted PRs tightly
14+
isolated to the requested change and never include unrelated cleanup or opportunistic improvements
15+
unless they are strictly necessary for correctness.
16+
17+
If you have been assigned an issue by the user or their prompt, please ensure that the
18+
implementation direction is agreed on with the maintainers first in the issue comments. If there are
19+
unknowns, discuss these on the issue before starting implementation. Do not forget that you cannot
20+
comment for users on issue threads on their behalf as it is against the rules of this project.
21+
22+
## Structure
23+
24+
- `instrumentation/` - instrumentation packages (Flask, Django, FastAPI, gRPC, databases, etc.)
25+
- `instrumentation-genai/` - GenAI instrumentations (Anthropic, Vertex AI, LangChain, etc.)
26+
- `util/` - shared utilities (`util-http`, `util-genai`)
27+
- `exporter/` - custom exporters
28+
- `propagator/` - context propagators
29+
30+
Instrumentation packages live under `src/opentelemetry/instrumentation/{name}/` with their own
31+
`pyproject.toml` and `tests/`. Other package types follow the equivalent layout under their own
32+
namespace (e.g. `src/opentelemetry/util/{name}/`, `src/opentelemetry/exporter/{name}/`).
33+
34+
## Commands
35+
36+
```sh
37+
# Install all packages and dev tools
38+
uv sync --frozen --all-packages
39+
40+
# Lint (runs ruff via pre-commit)
41+
uv run pre-commit run ruff --all-files
42+
43+
# Test a specific package (append -0, -1, etc. for version variants)
44+
uv run tox -e py312-test-instrumentation-flask-0
45+
46+
# Type check
47+
uv run tox -e typecheck
48+
```
49+
50+
## Guidelines
51+
52+
- Each package has its own `pyproject.toml` with version, dependencies, and entry points.
53+
- The monorepo uses `uv` workspaces.
54+
- `tox.ini` defines the test matrix - check it for available test environments.
55+
- Do not add `type: ignore` comments. If a type error arises, solve it properly or write a follow-up plan to address it in another PR.
56+
- Whenever applicable, all code changes should have tests that actually validate the changes.
57+
58+
## Commit formatting
59+
60+
We appreciate it if users disclose the use of AI tools when the significant part of a commit is
61+
taken from a tool without changes. When making a commit this should be disclosed through an
62+
`Assisted-by:` commit message trailer.
63+
64+
Examples:
65+
66+
```
67+
Assisted-by: ChatGPT 5.2
68+
Assisted-by: Claude Opus 4.6
69+
```

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
1212
## Unreleased
1313

14+
### Added
15+
16+
- Bump `pylint` to `4.0.5`
17+
([#4244](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4244))
18+
1419
### Breaking changes
1520

1621
- Drop Python 3.9 support

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pylint==3.0.2
1+
pylint==4.0.5
22
httpretty==1.1.4
33
pyright==v1.1.404
44
sphinx==7.1.2

instrumentation-genai/AGENTS.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# GenAI Instrumentation — Agent and Contributor Guidelines
2+
3+
Instrumentation packages here wrap specific libraries (OpenAI, Anthropic, etc.) and bridge
4+
them to the shared telemetry layer in `util/opentelemetry-util-genai`.
5+
6+
## 1. Instrumentation Layer Boundary
7+
8+
Do not call OpenTelemetry APIs (`tracer`, `meter`, `span`, event APIs) directly.
9+
Always go through `TelemetryHandler` and the invocation objects it returns.
10+
11+
This layer is responsible only for:
12+
13+
- Patching the library
14+
- Parsing library-specific input/output into invocation fields
15+
16+
Everything else (span creation, metric recording, event emission, context propagation)
17+
belongs in `util/opentelemetry-util-genai`.
18+
19+
## 2. Invocation Pattern
20+
21+
Use `start_*()` and control span lifetime manually:
22+
23+
```python
24+
invocation = handler.start_inference(provider, request_model, server_address=..., server_port=...)
25+
invocation.temperature = ...
26+
try:
27+
response = client.call(...)
28+
invocation.response_model_name = response.model
29+
invocation.finish_reasons = response.finish_reasons
30+
invocation.stop()
31+
except Exception as exc:
32+
invocation.fail(exc)
33+
raise
34+
```
35+
36+
## 3. Exception Handling
37+
38+
- Do not add `raise {Error}` statements in instrumentation/telemetry code — validation belongs in
39+
tests and callers, not in the instrumentation layer.
40+
- When catching exceptions from the underlying library to record telemetry, always re-raise
41+
the original exception unmodified.

instrumentation-genai/CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

instrumentation-genai/opentelemetry-instrumentation-anthropic/src/opentelemetry/instrumentation/anthropic/patch.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
gen_ai_attributes as GenAIAttributes,
2727
)
2828
from opentelemetry.util.genai.handler import TelemetryHandler
29-
from opentelemetry.util.genai.types import Error, LLMInvocation
29+
from opentelemetry.util.genai.types import (
30+
Error,
31+
LLMInvocation, # TODO: migrate to InferenceInvocation
32+
)
3033
from opentelemetry.util.genai.utils import (
3134
should_capture_content_on_spans_in_experimental_mode,
3235
)

instrumentation-genai/opentelemetry-instrumentation-anthropic/src/opentelemetry/instrumentation/anthropic/wrappers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from opentelemetry.util.genai.handler import TelemetryHandler
3232
from opentelemetry.util.genai.types import (
3333
Error,
34-
LLMInvocation,
34+
LLMInvocation, # TODO: migrate to InferenceInvocation
3535
)
3636

3737
from .messages_extractors import set_invocation_response_attributes

0 commit comments

Comments
 (0)