Skip to content

Commit 8d40dbb

Browse files
Merge branch 'main' into wsgi-asgi-labeler-server-duration
2 parents dfbdb93 + b8ca943 commit 8d40dbb

50 files changed

Lines changed: 1883 additions & 1448 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/workflows/check-links.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: check-links
2+
on:
3+
push:
4+
branches: [ main ]
5+
paths:
6+
- '**/*.md'
7+
- '**/*.rst'
8+
- '.github/workflows/check-links.yml'
9+
- '.github/workflows/check_links_config.json'
10+
pull_request:
11+
paths:
12+
- '**/*.md'
13+
- '**/*.rst'
14+
- '.github/workflows/check-links.yml'
15+
- '.github/workflows/check_links_config.json'
16+
17+
permissions:
18+
contents: read
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
check-links:
26+
runs-on: ubuntu-latest
27+
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'otelbot[bot]' }}
28+
timeout-minutes: 15
29+
steps:
30+
- name: Checkout Repo
31+
uses: actions/checkout@v6
32+
33+
- name: Get changed markdown files
34+
id: changed-files
35+
uses: tj-actions/changed-files@v46
36+
with:
37+
files: |
38+
**/*.md
39+
**/*.rst
40+
41+
- name: Install markdown-link-check
42+
if: steps.changed-files.outputs.any_changed == 'true'
43+
run: npm install -g markdown-link-check@v3.12.2
44+
45+
- name: Run markdown-link-check
46+
if: steps.changed-files.outputs.any_changed == 'true'
47+
run: |
48+
markdown-link-check \
49+
--verbose \
50+
--config .github/workflows/check_links_config.json \
51+
${{ steps.changed-files.outputs.all_changed_files }} \
52+
|| { echo "Check that anchor links are lowercase"; exit 1; }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "http(s)?://\\d+\\.\\d+\\.\\d+\\.\\d+"
5+
},
6+
{
7+
"pattern": "http(s)?://localhost"
8+
},
9+
{
10+
"pattern": "http(s)?://example.com"
11+
}
12+
],
13+
"aliveStatusCodes": [429, 200]
14+
}

.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

0 commit comments

Comments
 (0)