Repository navigation
Commit 7b32953
authored
feat: make the OpenTelemetry sampler configurable, and compress the ADRs (#222)
* feat: make the OpenTelemetry sampler configurable
`OpenTelemetryInstrument.bootstrap()` built the provider without a sampler, so
`parentbased_always_on` applied unless the environment overrode it, and there was
no way to express a sampler from Python. #184 measured ~55 µs/request between
always-on and `ParentBased(TraceIdRatioBased(0.01))` on an endpoint whose bare
cost is 16 µs.
`opentelemetry_sampler` takes a `Sampler` rather than the sample-rate float the
issue leaned towards: the config already carries `BaseInstrumentor` and Sentry's
types as quoted `TYPE_CHECKING` annotations, so the "keep SDK types out of the
config" argument for a float does not apply here, and a float would leave
`ALWAYS_OFF`, a bare `TraceIdRatioBased` and vendor samplers unreachable behind
an instrument that owns provider construction and offers no escape hatch. A float
can still be layered on later. ADR-0010 records it.
The field is passed unconditionally. Contrary to the issue, `TracerProvider(sampler=None)`
is identical to omitting the argument — the SDK does `if not sampler: sampler =
_get_from_env_or_default()`, at the declared 1.28 floor and at 1.44 alike — so the
default is unchanged and `OTEL_TRACES_SAMPLER` keeps working when the field is unset.
Both are pinned by tests.
* docs: compress the ADRs to the domain-modeling format
The `**Decision:** / ## Context / ## Rejected alternatives / **Revisit trigger:**`
shape had grown to 3,421 words across ten files, most of it scaffolding. The
domain-modeling skill's format is a title plus a short body, with sections only
where they earn their place; revisit conditions fold into the prose.
Two merges, no drops. 0004 (exclusion policy stays in one method) joins 0002:
both record a rejected re-organization refused for the same reason, that it moves
complexity rather than concentrating it. 0006 (OTLP-HTTP as a sibling extra)
joins 0005: both are the same decision applied twice - a native dependency with
no free-threaded wheels becomes an opt-in extra, never a combinatorial matrix of
per-framework variants. Numbers 0004 and 0006 are retired rather than reused, so
every surviving citation still resolves.
3,421 words -> 1,423. The floor is set by the facts a reader opens these for: the
`wrap_for_formatter` incompatibility, pydantic's `TypedDict` refusal below 3.12,
the four framework binding styles.
* docs: renumber the ADRs to close the merge gaps
The two merges retired 0004 and 0006, leaving holes. Closing them so the set runs
0001-0008 and the next ADR is 0009: extras 0005->0004, typing-extensions
0007->0005, structlog/Sentry seam 0008->0006, Django 0009->0007, sampler
0010->0008.
Renumbering breaks references, so all nine in the repo were audited, not just the
one shape the citation test enforces. That test reads full `docs/adr/NNNN-slug.md`
paths in Python and there is exactly one (opentelemetry_instrument.py); the other
eight are bare `ADR-NNNN` numbers in comments and prose, invisible to it. Four
needed rewriting: logging_factory, test_core_import_surface, floor_smoke and the
sampler comment's number alongside its path. pyproject's 0001 path, base.py's
0003, the ADR-0001 cross-reference in the Django ADR and domain.md's 0002 example
all kept their numbers; domain.md's gloss was updated to the merged title.
`docs/agents/domain.md` now records the format and the numbering rule, so the next
ADR does not reintroduce the old scaffolding or reuse a retired number.
* test: check bare `ADR-NNNN` citations, and citations outside Python
The renumber exposed the gap: the invariant read full `docs/adr/NNNN-slug.md`
paths in Python, and the repo has exactly one of those. The other eight citations
are bare numbers in comments and prose, plus a path in `pyproject.toml`'s fastmcp
floor comment — none of them checked by anything. `scripts/floor_smoke.py` was
left pointing at the wrong ADR and only a manual grep caught it.
So the scanner now reads `.py`, `.md` and `.toml`, and resolves both forms: a
path must exist, a bare number must match some `docs/adr/NNNN-*.md`. The AST pass
stays Python-only, since it exists for citations split across adjacent literals.
`site/` is skipped as mkdocs output, a second copy of docs/ whose citations are
the originals'.
Verified by breaking each form in turn: a dangling number in
test_core_import_surface and a dangling path in pyproject both fail the invariant,
and both pass again once restored. The limit is in the docstring — a number
renumbered onto a different live ADR still resolves, and nothing here can know it
now names the wrong decision.
* docs: point at the skill's ADR format instead of restating it
domain.md is the pointer file for the engineering skills; the format itself is
the `/domain-modeling` skill's to define, and a paraphrase here is one more copy
to drift. The numbering rule goes for the same reason - the skill already says to
take the next free number, and with the gaps closed there are no retired numbers
left to warn about.
* docs: restore domain.md to the setup skill's template
The file had drifted into repo prose — sections renamed and reordered, the
`proceed silently` rule dropped, bullets rewritten to editorialise about
CONTEXT.md's contents and the ADR format. All of that is the skills' to say.
Back to the seed template verbatim, with only the branches this repo already
answered resolved: single-context, so no CONTEXT-MAP bullet and no multi-context
tree, and the trees and ADR example name real files. triage-labels.md and
issue-tracker.md were checked against their templates and are byte-identical.
* docs: restore the AGENTS.md agent-skills block to its native shape
`## Agent docs` with three bullets was a compressed variant of the block the
setup skill writes. Back to `## Agent skills` with a sub-heading per artifact,
carrying the same three answers. Nothing referenced the old heading.1 parent ffbd378 commit 7b32953
25 files changed
Lines changed: 328 additions & 367 deletions
File tree
- docs
- adr
- agents
- introduction
- lite_bootstrap/instruments
- scripts
- tests
- instruments
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
32 | 40 | | |
33 | 41 | | |
34 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments