Skip to content

fix(observability): align OTLP exporter, resource and logger with the OpenTelemetry spec - #8868

Merged
tim-smart merged 19 commits into
Effect-TS:mainfrom
Makisuo:fix/otel-semconv-exporters
Oct 6, 2026
Merged

tim-smart merged 19 commits into
Effect-TS:mainfrom
Makisuo:fix/otel-semconv-exporters

Conversation

@Makisuo

@Makisuo Makisuo commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Type

  • Bug Fix

Summary

Align built-in OTLP and @effect/opentelemetry logs, traces, and resources with OpenTelemetry conventions. Add release-derived runtime version metadata. Metrics remain unchanged; this is not a claim of complete OpenTelemetry compliance.

Changes

  • Add public effect/Version with synchronous getCurrentVersion() and setCurrentVersion(version). Generate the default from the Effect package version during changeset-version; the fixed release group keeps the two packages aligned.
  • Preserve user-supplied User-Agent values, including case-insensitive header names, before OTel-OTLP-Exporter-JavaScript-Effect-<label>/<version>.
  • Default resource telemetry.sdk.name, telemetry.sdk.language, and telemetry.sdk.version, allowing user attributes to override SDK defaults. OtlpResource.make() accepts an omitted service name. fromConfig() retains configured/environment service-name precedence and the required OTEL_SERVICE_NAME fallback; missing required configuration becomes a defect.
  • Apply SDK defaults to environment-only OpenTelemetry resources too: environment attributes override defaults, and additional attributes win last. Explicit configToAttributes applies SDK defaults, then custom attributes, then dedicated service options. layerEmpty stays empty.
  • Use effect plus the shared version as the instrumentation scope for logs and traces in both integrations. OpenTelemetry tracer layers no longer require Resource; provider layers still receive resource metadata.
  • Emit exception.type and exception.message from the first rendered error and exception.stacktrace from the full cause, including nested causes, replacing built-in log.error.
  • Namespace numeric fiber IDs and log-span durations as effect.fiberId and effect.log_span.<label> (milliseconds instead of strings). Generated values override annotations, outermost duplicate span labels win, and empty causes preserve annotated exception attributes. Built-in log attributes have unique serialized keys.
  • Use the event date for log timestamps and the clock for observed timestamps in both integrations.
  • Include patch changeset entries for effect and @effect/opentelemetry.

Compatibility and boundaries

Default User-Agent and resource metadata, log attribute keys/value types, and log/trace scope identity change. Service names are optional only for OtlpResource.make(); fromConfig() and exporters using it retain the required configuration fallback. No unknown_service fallback is added. OpenTelemetry custom SDK attributes are now respected rather than overwritten.

Metrics behavior and scopes are unchanged, including the pre-existing built-in metrics limitation without a service name. The explicit-resource/environment SDK-attribute precedence edge case remains deferred: defaults from an explicit OpenTelemetry resource configuration can still override environment SDK attributes.

Validation

Focused coverage in Version.test.ts, built-in observability tests, and OpenTelemetry tests covers version overrides, versioned headers and scopes, resource defaults/precedence, absent and configured service names, environment-only Node resources, structured/nested exceptions, attribute uniqueness and precedence, and event/observed timestamps.

Local validation: all 110 tests in 14 Version/observability/OpenTelemetry suites pass; repository lint-fix, typecheck, and git diff --check pass. Final documentation follow-up changes only the changeset and this description, leaving source, tests, and metrics unchanged.

Closes EFF-1802

@changeset-bot

changeset-bot Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e39c32a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 32 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Spec-shaped User-Agent that prefixes a user-supplied one, telemetry.sdk.*
resource attributes, unknown_service fallback, effect scope name for traces,
logs and metrics, and exception.* plus namespaced Effect attributes on log
records in both the OTLP logger and the OpenTelemetry logger.
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 38.79 KB 38.79 KB 0.00 KB (0.00%)
basic.ts 7.06 KB 7.06 KB 0.00 KB (0.00%)
batching.ts 10.14 KB 10.14 KB 0.00 KB (0.00%)
brand.ts 6.73 KB 6.73 KB 0.00 KB (0.00%)
cache.ts 10.89 KB 10.89 KB 0.00 KB (0.00%)
config.ts 22.25 KB 22.25 KB 0.00 KB (0.00%)
differ.ts 21.34 KB 21.34 KB 0.00 KB (0.00%)
http-client.ts 22.44 KB 22.44 KB 0.00 KB (0.00%)
http-router.ts 33.95 KB 33.95 KB 0.00 KB (0.00%)
logger.ts 11.22 KB 11.22 KB 0.00 KB (0.00%)
metric.ts 9.03 KB 9.03 KB 0.00 KB (0.00%)
optic.ts 6.96 KB 6.96 KB 0.00 KB (0.00%)
pubsub.ts 15.18 KB 15.18 KB 0.00 KB (0.00%)
queue.ts 12.13 KB 12.13 KB 0.00 KB (0.00%)
schedule.ts 11.22 KB 11.22 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 13.74 KB 13.74 KB 0.00 KB (0.00%)
schema-binary.ts 40.00 KB 40.00 KB 0.00 KB (0.00%)
schema-class.ts 21.07 KB 21.07 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 32.10 KB 32.10 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.28 KB 27.28 KB 0.00 KB (0.00%)
schema-string-transformation.ts 14.48 KB 14.48 KB 0.00 KB (0.00%)
schema-string.ts 12.00 KB 12.00 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.07 KB 16.07 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 38.32 KB 38.32 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 25.30 KB 25.30 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 20.26 KB 20.26 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 20.45 KB 20.45 KB 0.00 KB (0.00%)
schema-toFormatter.ts 20.57 KB 20.57 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 25.03 KB 25.03 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 20.55 KB 20.55 KB 0.00 KB (0.00%)
schema.ts 20.29 KB 20.29 KB 0.00 KB (0.00%)
stm.ts 13.24 KB 13.24 KB 0.00 KB (0.00%)
stream.ts 9.99 KB 9.99 KB 0.00 KB (0.00%)

@effect-janitor effect-janitor Bot added bug Something isn't working 4.0 labels Oct 6, 2026
Revert the out-of-scope OtlpMetrics scope name and @effect/opentelemetry
OtelLogger changes, render the log exception attributes from a single
prettyErrors pass, and drop the opentelemetry package from the changeset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Expose the release version through a public effect/Version module, kept in
sync by scripts/version.mjs during changeset versioning. Use it for the OTLP
User-Agent, telemetry.sdk.version and the effect instrumentation scope in both
the built-in OTLP exporters and @effect/opentelemetry. Omit service.name when
none is configured instead of falling back to unknown_service, and bring the
@effect/opentelemetry logger in line with the OTLP logger's timestamps,
exception attributes and attribute precedence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@effect-janitor effect-janitor Bot removed the bug Something isn't working label Oct 6, 2026
Build OTLP resources from one attribute object, so the service options also
replace matching attributes instead of duplicating them. Use plain assignment
for generated log attributes, inline the User-Agent merge, and drop tests for
the removed service-name fallback or that duplicate other cases.
Comment thread .changeset/otlp-exporters-semconv.md Outdated
@tim-smart
tim-smart enabled auto-merge (squash) October 6, 2026 23:20
@tim-smart
tim-smart merged commit f5716ad into Effect-TS:main Oct 6, 2026
8 of 10 checks passed
juliusmarminge added a commit to pingdotgg/t3code that referenced this pull request Oct 9, 2026
…ources

Effect 4.0.2 (Effect-TS/effect#8868) puts `telemetry.sdk.*` on every OTLP
resource. The test checks the attributes we pass through, so it skips those.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch is waiting to be deployed

1 waiting deployment
fork — e39c32a1 Waiting Oct 6, 2026 by tim-smart via approval-gate #18019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants