5.4 KiB
5.4 KiB
0. Pre-flight (non-negotiable)
- 0.1 Confirm clean working tree (
git statusreports nothing) and no in-flight worktrees with uncommitted work (git worktree listthengit statusin each) - 0.2 If any worktrees exist under
.claude/worktrees/, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (git worktree remove) before opening a new one — code that has been lost twice on main is the failure mode this guards against. - 0.3 Confirm the package set in
MANIFEST.mdmatchesfind packages -maxdepth 3 -name package.jsoncount. Drift here means a prior change archived without regenerating the manifest.
1. Catalog and package skeleton
- 1.1 Add
@opentelemetry/sdk-node,@opentelemetry/sdk-trace-node, and@opentelemetry/exporter-trace-otlp-httpto rootpackage.jsoncatalogs.observability(skip any already pinned by@suaveplan/opentelemetry). - 1.2 Create
packages/testing/testing-integration-otel-collector/withpackage.json(version0.1.0,type: "module",sideEffects: false,workspace:^dep on@suaveplan/testing-integration, catalog dep ontestcontainers). - 1.3 Add
tsconfig.lib.jsonextending@suaveplan/typescript-config/library-node.json; addvite.config.tswithpreserveModules: true; addvitest.config.tsviacreateTestConfig(). - 1.4 Stub
README.md(one-paragraph description, install, quick start, Modules index linking each co-located.md).
2. ServiceFixture implementation
- 2.1 Implement
src/fixture/otel-collector-fixture.ts—OtelCollectorFixtureimplementingServiceFixture<OtelCollectorConfig>; constructor accepts injectablecontainerFactoryandfetchFn. - 2.2 Implement
src/config/synthesize-config.ts— produceotelcol-config.yamlfrom{ receivers, exporters }; include the in-memory exporter wiring when'memory'is requested. - 2.3 Implement
src/health/health-check.ts— HTTP GET on:13133/health/status, default timeout 60 s, retries viaHealthPollerfrom@suaveplan/testing-integration. - 2.4 Implement
src/env-bridge/env-bridge.ts— setsOTEL_EXPORTER_OTLP_ENDPOINT,OTEL_EXPORTER_OTLP_PROTOCOL, optionalOTEL_EXPORTER_OTLP_HEADERS; restores prior values on teardown. - 2.5 Implement
src/query/get-spans.ts—getSpans({ filter })queries the memory exporter via the collector's debug HTTP endpoint; returnsReadableSpan[]; throwsIntegrationError("INTEGRATION.OTEL_COLLECTOR.MEMORY_EXPORTER_NOT_CONFIGURED", …)when the memory exporter is not in the active config. - 2.6 Implement
src/errors/codes.ts— string-literal-union of everyINTEGRATION.OTEL_COLLECTOR.<REASON>code thrown by the package. - 2.7 Co-locate
*.test.ts,*.schemas.ts,*.mdfor every implementation file (.md≥ 200 words with simple + advanced examples peropenspec/AGENTS.md§4).
3. Image pinning (tracked, follow-up)
- 3.1 Tag-pin
otel/opentelemetry-collector-contrib:0.<minor>initially. - 3.2 Open a tracking task to migrate to digest-pin (
@sha256:…) once the minor version is locked — referenced from audit §5 "Images pinned by tag, not digest".
4. Runner reporter — @suaveplan/testing/reporters/otel
- 4.1 Add subpath export
./reporters/oteltopackages/testing/testing/package.json. - 4.2 Implement
src/reporters/otel/vitest-reporter.ts— Vitest reporter that opens a span perit/test, recordsexception.*events on assertion failure, and writes the full span tree toplaywright-report/traces/<spec>.jsonon red. - 4.3 Implement
src/reporters/otel/bun-test-reporter.ts— equivalent for bun-test (uses bun-test's reporter API). - 4.4 Implement
src/reporters/otel/trace-sink.ts— uploads the failure trace toTESTING_TRACE_SINK_URL(Garage S3 PUT); best-effort (failures logged, not thrown). - 4.5 Implement
src/reporters/otel/fixture-events.ts— hook intoFixtureManagerlifecycle to emitsetup-start/setup-end/teardown-start/teardown-endspan events. - 4.6 Co-locate tests, schemas, and docs for every new file.
5. Spec deltas
- 5.1 Land
specs/testing-integration-otel-collector/spec.mdwith all## ADDED Requirements(image policy, env-bridge, health-check, config shape, span-query, errors). - 5.2 Land
specs/testing/spec.mdwith the## ADDED Requirementsblock carrying the Test-execution OTel export requirement. - 5.3 On ship, fold both into
openspec/specs/testing-integration-otel-collector/spec.md(new file) andopenspec/specs/testing/spec.md(append).
6. Verification
- 6.1
bunx turbo lint typecheck test --filter=@suaveplan/testing-integration-otel-collectorgreen. - 6.2
bunx turbo test:coverage --filter=@suaveplan/testing-integration-otel-collectorat 100% statement / branch / function / line. - 6.3
bunx turbo lint typecheck test --filter=@suaveplan/testinggreen after reporter additions; coverage stays at 100%. - 6.4 End-to-end smoke: a sample test suite with
OTEL_EXPORTER_OTLP_ENDPOINTset produces queryable spans viagetSpans(). - 6.5 Banned-pattern scan (
@deprecated,TODO,FIXME,ts-ignore,ts-expect-error,.skip,.only, bareany) clean.
7. Archive
- 7.1 Move
openspec/changes/enterprise-testing-integration-otel-collector/→openspec/archive/<yyyy-mm-dd>-enterprise-testing-integration-otel-collector/after all gates pass.