Repository navigation
Conversation
AGENTS.md tells coding agents how this repository works: its layout and commands, the Node.js core and OpenTelemetry conventions the code follows, how the tests are built around init() activating once per process, how to measure changes to the traced path, and the rules for pull requests. CLAUDE.md imports it, so Claude Code reads the same file. Signed-off-by: Bryan English <bryan@bryanenglish.com>
jsumners-nr
left a comment
There was a problem hiding this comment.
In my experience, these barely have an effect. But 🤷♂️
|
YMMV 🤷 |
AbhiPrasad
left a comment
There was a problem hiding this comment.
In my experience, these barely have an effect. But 🤷♂️
I think they do! I would recommend running evals on your coding agent traces to see for yourself, I've done a bunch and I can see a noticeable difference, even with frontier models.
| ## Layout | ||
|
|
||
| | Path | What it holds | | ||
| |---|---| | ||
| | `index.js` | The public API. | | ||
| | `lib/core.js` | `init()` option validation and the state it sets. | | ||
| | `lib/instrumentations.js` | The `diagnostics_channel` subscribers that create spans and propagate context. | | ||
| | `lib/span.js` | The `Span` class, trace flags, and `traceparent` parsing and formatting. | | ||
| | `lib/sampler.js` | The root sampling decision for `sampleRatio`. | | ||
| | `lib/id.js` | Trace and span ID generation. | | ||
| | `lib/flush.js` | The span buffer, OTLP JSON serialization, the export, and `flush()`. | | ||
| | `lib/guard.js` | `guard()`, which keeps a bug in microtel from breaking the app it traces. | | ||
| | `lib/validate.js` | Ports of Node.js core's argument validators and error helpers. | | ||
| | `scripts/` | The bundle build and the benchmark comparison that CI runs. | | ||
| | `test/` | The tests (`test-*.js`), shared helpers in `test/common/`, and child process fixtures in `test/fixtures/`. | | ||
| | `test/collector/` | A smoke test against a real OpenTelemetry Collector, which runs in its own CI job. | | ||
| | `benchmark/` | The `node:bench` benchmarks. | | ||
| | `dist/microtel.js` | The generated CommonJS bundle from `npm run build`. It's ignored, and `test/test-bundle.js` loads and tests it. | |
There was a problem hiding this comment.
I would shorten this down to just explaining the main folders. Once you've established that, it's often more effective to just have them grep files, or just navigate the files via following exports/imports.
| ## Layout | |
| | Path | What it holds | | |
| |---|---| | |
| | `index.js` | The public API. | | |
| | `lib/core.js` | `init()` option validation and the state it sets. | | |
| | `lib/instrumentations.js` | The `diagnostics_channel` subscribers that create spans and propagate context. | | |
| | `lib/span.js` | The `Span` class, trace flags, and `traceparent` parsing and formatting. | | |
| | `lib/sampler.js` | The root sampling decision for `sampleRatio`. | | |
| | `lib/id.js` | Trace and span ID generation. | | |
| | `lib/flush.js` | The span buffer, OTLP JSON serialization, the export, and `flush()`. | | |
| | `lib/guard.js` | `guard()`, which keeps a bug in microtel from breaking the app it traces. | | |
| | `lib/validate.js` | Ports of Node.js core's argument validators and error helpers. | | |
| | `scripts/` | The bundle build and the benchmark comparison that CI runs. | | |
| | `test/` | The tests (`test-*.js`), shared helpers in `test/common/`, and child process fixtures in `test/fixtures/`. | | |
| | `test/collector/` | A smoke test against a real OpenTelemetry Collector, which runs in its own CI job. | | |
| | `benchmark/` | The `node:bench` benchmarks. | | |
| | `dist/microtel.js` | The generated CommonJS bundle from `npm run build`. It's ignored, and `test/test-bundle.js` loads and tests it. | | |
| ## Layout | |
| | Path | What it holds | | |
| |---|---| | |
| | `index.js` | The public API. | | |
| | `lib/` | The implementation of microtel. | | |
| | `scripts/` | The bundle build and the benchmark comparison that CI runs. | | |
| | `test/` | The tests (`test-*.js`), shared helpers in `test/common/`, and child process fixtures in `test/fixtures/`. | | |
| | `benchmark/` | The `node:bench` benchmarks. | | |
| | `dist/microtel.js` | The generated CommonJS bundle from `npm run build`. It's ignored, and `test/test-bundle.js` loads and tests it. | |
There was a problem hiding this comment.
Agree, I always don't like agent generated document that over-documents the details, and making any change would require additional document tailoring.
| CI runs separate `build`, `test`, `prettier`, and `collector` jobs, and the | ||
| benchmark workflow runs the benchmarks on every push and compares them against | ||
| the base branch on pull requests. |
There was a problem hiding this comment.
we should just say, "read the github action workflow to see what CI runs". This saves us context window, but also makes it easier for the agent to find exactly what they need to understand the problem.
|
|
||
| ## OpenTelemetry behavior | ||
|
|
||
| Follow the OpenTelemetry specification and semantic conventions, and match what |
There was a problem hiding this comment.
I wonder if we should say if agents have confusion over the spec to look it up directly (link to it). Otherwise we risk them hallucinating the spec from memory.
There was a problem hiding this comment.
Agree. For behavior matching the spec, the code should be companioned with a link to the spec.
| - `init()` validates every option before it changes any state, and it copies | ||
| any object it keeps, so a caller changing that object later has no effect. |
There was a problem hiding this comment.
I don't think this is "code conventions". This belongs to it's own code document.
| - Every export settles, on every path, by its `exportTimeout` deadline at the | ||
| latest. `flush()` never rejects for a failed export. Failures are reported as | ||
| throttled `OTelExportWarning` process warnings instead. |
There was a problem hiding this comment.
Ditto, this should be in the code inline doc rather than in the agents.md
|
|
||
| ## OpenTelemetry behavior | ||
|
|
||
| Follow the OpenTelemetry specification and semantic conventions, and match what |
There was a problem hiding this comment.
Agree. For behavior matching the spec, the code should be companioned with a link to the spec.
| ## Performance | ||
|
|
||
| For pull requests, CI compares the benchmarks of the change and its base over | ||
| five interleaved rounds. It reports the mean of each run's mean rate and the |
There was a problem hiding this comment.
5-round was my back-then result pick. It could change and I don't want to update multiple places to change the round number :)
| five interleaved rounds. It reports the mean of each run's mean rate and the | |
| interleaved rounds. It reports the mean of each run's mean rate and the |
| spread, and highlights a change only when every run on one side is faster or | ||
| slower than every run on the other. | ||
|
|
||
| When measuring by hand, interleave runs of main and the change on the same |
There was a problem hiding this comment.
| When measuring by hand, interleave runs of main and the change on the same | |
| When measuring by hand, use ./scripts/compare-benchmarks.js to interleave runs of main and the change on the same |
| `ci:`, `chore:`, and `docs:`. | ||
| - Contributions are made under the Developer's Certificate of Origin in | ||
| CONTRIBUTING.md. | ||
| - A pull request stays open for at least 24 hours before it merges, unless the |
There was a problem hiding this comment.
Please don't duplicate the policies here.
https://bsky.app/profile/did:plc:4v3uz6xgigawvz64fede7ly7/post/3mydaspu3gs2d Same nonsense every single day. |
Adds
AGENTS.mdwith guidance for coding agents working in this repository, and aCLAUDE.mdthat imports it with@AGENTS.md, so Claude Code reads the same file.It covers what agents need that isn't written down anywhere:
init()options before any state changes,guard()for everything handed to Node, exports always settling, and Prettier's scopespawnMicrotel()and its timeoutTODO(handle):items, and README updates for user-facing changesEvery claim in the file was checked against the code, the workflows, and the commit history.