Public: anyone can read this; the crew can change it.

Errors: OpenTelemetry intake alongside the Sentry envelope #17137

opened this

Merged 39h 19m ago, live in production

An app with an OpenTelemetry SDK can now report errors to the forge without Sentry. They group, file issues and count as regressions the same way an envelope does. tsc, the gate and the tests I ran (otlp-errors, error-groups, openapi-drift, route-marks, own-source, contract-openapi-tags) pass.

Notes

opened this

An app with an OpenTelemetry SDK can now report errors to the forge without Sentry. They group, file issues and count as regressions the same way an envelope does. tsc, the gate and the tests I ran (otlp-errors, error-groups, openapi-drift, route-marks, own-source, contract-openapi-tags) pass. I did not run the full suite or check the new door on a preview.

What changed

  • Intake. POST /api/<app id>/otlp/v1/traces and /v1/logs accept OTLP/HTTP JSON, gzip allowed. The app key goes in x-forge-key or Authorization: Bearer.
  • What counts as an error. A span event named exception, or a log record with exception.* attributes.
  • Field mapping. service.version is the release, deployment.environment.name the environment, url.full the page, and enduser.id the user, which is hashed.
  • Failure answers. A wrong key or app answers 404, an oversized body 413, and anything that isn't JSON 415.
  • Sharing. src/core/otlp_errors.ts rebuilds each exception as a Sentry-shaped payload and passes it to the existing eventOf. The allowlist, hashing and fingerprint are not copied. ingest in src/actions/errors.ts takes an optional parser, so the rate limits, group caps and issue filing are the same code. src/http/error_envelope.ts carries the two new routes.
  • App environment. A started app now also gets OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS and OTEL_EXPORTER_OTLP_PROTOCOL=http/json, so a stock exporter works with no setup. The Errors screen hint in the terminal now says "Sentry or OpenTelemetry".
  • Contract and docs. I added the OpenAPI routes, one route mark for /api/:project/otlp, the regenerated src/generated/marks.ts, and the NOT_ROUTED entries in test/openapi-drift.test.ts. docs/features/errors.md has a new OpenTelemetry paragraph.
  • Tests. test/otlp-errors.test.ts is new, and test/error-groups.test.ts now expects the new environment variables.

Left out

  • Protobuf, so an exporter must use http/json. The route says so with a 415.
  • Metrics, and spans that are not errors.
  • Python-style stack traces. Only at fn (file:line:col) lines give frames. Other stacks still group, by type and message.
  • A status field in the OpenAPI description. Route.refuses does not allow 415, so the contract lists only 404.
  • A web card change, to avoid the design and looks gates.

I put a No door: line in the second commit, since the gate wanted a terminal screen and a how-to for the new files. The how-to is the errors page, and the admin reads are unchanged.

Try it: start an app so it gets its key, then curl -X POST $FORGE/api/<app id>/otlp/v1/traces -H 'x-forge-key: <key>' -H 'content-type: application/json' -d '{"resourceSpans":[{"scopeSpans":[{"spans":[{"events":[{"name":"exception","attributes":[{"key":"exception.type","value":{"stringValue":"TypeError"}},{"key":"exception.message","value":{"stringValue":"boom"}}]}]}]}]}]}'. The Errors card then shows a new group and one issue.

Closes #16973

2 earlier comments
commented

An app with an OpenTelemetry SDK can now report errors to the forge without Sentry. They group, file issues and count as regressions the same way an envelope does. tsc, the gate and the tests I ran (otlp-errors, error-groups, openapi-drift, route-marks, own-source, contract-openapi-tags) pass. I did not run the full suite or check the new door on a preview.

What changed

  • Intake. POST /api/<app id>/otlp/v1/traces and /v1/logs accept OTLP/HTTP JSON, gzip allowed. The app key goes in x-forge-key or Authorization: Bearer.
  • What counts as an error. A span event named exception, or a log record with exception.* attributes.
  • Field mapping. service.version is the release, deployment.environment.name the environment, url.full the page, and enduser.id the user, which is hashed.
  • Failure answers. A wrong key or app answers 404, an oversized body 413, and anything that isn't JSON 415.
  • Sharing. src/core/otlp_errors.ts rebuilds each exception as a Sentry-shaped payload and passes it to the existing eventOf. The allowlist, hashing and fingerprint are not copied. ingest in src/actions/errors.ts takes an optional parser, so the rate limits, group caps and issue filing are the same code. src/http/error_envelope.ts carries the two new routes.
  • App environment. A started app now also gets OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS and OTEL_EXPORTER_OTLP_PROTOCOL=http/json, so a stock exporter works with no setup. The Errors screen hint in the terminal now says "Sentry or OpenTelemetry".
  • Contract and docs. I added the OpenAPI routes, one route mark for /api/:project/otlp, the regenerated src/generated/marks.ts, and the NOT_ROUTED entries in test/openapi-drift.test.ts. docs/features/errors.md has a new OpenTelemetry paragraph.
  • Tests. test/otlp-errors.test.ts is new, and test/error-groups.test.ts now expects the new environment variables.

Left out

  • Protobuf, so an exporter must use http/json. The route says so with a 415.
  • Metrics, and spans that are not errors.
  • Python-style stack traces. Only at fn (file:line:col) lines give frames. Other stacks still group, by type and message.
  • A status field in the OpenAPI description. Route.refuses does not allow 415, so the contract lists only 404.
  • A web card change, to avoid the design and looks gates.

I put a No door: line in the second commit, since the gate wanted a terminal screen and a how-to for the new files. The how-to is the errors page, and the admin reads are unchanged.

Try it: start an app so it gets its key, then curl -X POST $FORGE/api/<app id>/otlp/v1/traces -H 'x-forge-key: <key>' -H 'content-type: application/json' -d '{"resourceSpans":[{"scopeSpans":[{"spans":[{"events":[{"name":"exception","attributes":[{"key":"exception.type","value":{"stringValue":"TypeError"}},{"key":"exception.message","value":{"stringValue":"boom"}}]}]}]}]}]}'. The Errors card then shows a new group and one issue.

commented

I merged main into the branch and pushed it (6bbbe9e4b), so #17137 should merge cleanly again.

The only conflict was src/generated/marks.ts, which is generated. I took main's version and regenerated it with bun scripts/own-source.ts. The result has no conflict markers and keeps the api-project-otlp route mark from this pull.

tsc is clean. These five test files pass (44 tests): otlp-errors, error-groups, own-source, route-marks and openapi-drift. I didn't run the full suite. The forge's check will run it on this push.

The pull itself is unchanged: OTLP/HTTP JSON intake for exceptions, at /api/<app id>/otlp/v1/traces and /v1/logs, alongside the Sentry envelope.

commented

I made all four changes from the review and pushed them (cd2c2731f). tsc and the gate are clean, and test/otlp-errors.test.ts and test/unused-exports.test.ts pass. I did not run the full suite.

  1. HIGH, regex DoS. I replaced the backtracking regex in framesOfStack (src/core/otlp_errors.ts) with a plain string parse.
    • The stack is cut to 20,000 characters and at most 200 lines are read.
    • Lines over 500 characters are skipped.
    • The location is read by splitting on : and checking each part is digits, so no pattern backtracks over attacker text.
    • A new test feeds a 360 KB line of repeated a ( :1 and a line with 400 colons, and requires both to finish in under 200 ms.
  2. Docs line. I rewrapped the over-long sentence in docs/features/errors.md.
  3. Dead branch. The log loop now reads list(obj(sl)["logRecords"]), like the traces loop.
  4. Gzip test. A gzip OTLP trace now returns 200, and a body that is not valid gzip returns 400.

My gzip test added a third sighting, so I changed the grouping test's expected count from 2 to 3. That was a mistake in my test, not in the code.

The gate also asked for a Try: line and a No door: line, which are in the commit message. I added no terminal or page change this round because the admin reads are unchanged.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs