Skip to content

Replace OpenTelemetry SDK with direct tracing-subscriber layer - #446

Open
Ziinc wants to merge 2 commits into
mainfrom
claude/bundle-size-increase-4k6rkh
Open

Replace OpenTelemetry SDK with direct tracing-subscriber layer#446
Ziinc wants to merge 2 commits into
mainfrom
claude/bundle-size-increase-4k6rkh

Conversation

@Ziinc

@Ziinc Ziinc commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Simplifies the telemetry pipeline by removing the OpenTelemetry SDK dependency and replacing it with a custom tracing_subscriber::Layer implementation that writes JSON logs directly to disk.

Key Changes

  • Removed OpenTelemetry SDK: Eliminated opentelemetry, opentelemetry_sdk, opentelemetry-appender-tracing, and opentelemetry-stdout dependencies
  • Implemented custom JsonLogLayer: A minimal tracing_subscriber::Layer that writes one JSON object per line to the log file, replacing the previous OTel pipeline (SdkLoggerProvider + OpenTelemetryTracingBridge + hand-rolled OTLP exporter)
  • Simplified TelemetryGuards: Removed manual Drop implementation and ManuallyDrop wrappers; now just holds a WorkerGuard for its Drop impl
  • Removed OTLP formatting: Eliminated complex OTLP envelope construction (otlp_log_record, any_value_to_otlp, otel_value_to_otlp functions) since the log file is only consumed internally
  • Simplified field handling: Added MessageVisitor struct implementing tracing::field::Visit to extract message and field data from tracing events
  • Updated dependencies: Removed unused gix features (blocking-network-client, worktree-mutation)
  • Updated build profile: Changed release LTO from "thin" to "fat" for better optimization

Implementation Details

The new JsonLogLayer captures tracing events and writes them as JSON with:

  • timeUnixNano: Current timestamp in nanoseconds since UNIX_EPOCH
  • severityText: Log level from event metadata
  • target: Event target from metadata
  • message: Extracted from the "message" field
  • fields: All other recorded fields as a map
    This approach eliminates unnecessary complexity since the log file is not parsed back by external tools (unlike core/checks_logs.rs which builds its own OTel-shaped records independently).
    https://claude.ai/code/session_01CrEKvdwuSyrEhoLhMig91S

@github-actions

Copy link
Copy Markdown
Contributor

…l SDK

- profile.release: lto = "thin" -> "fat" for whole-program link-time optimization
- gix: drop unused blocking-network-client and worktree-mutation features
  (code only uses gix::open + local ref read/write; network/checkout ops
  go through jj-lib, not gix directly)
- telemetry: replace the opentelemetry/opentelemetry_sdk/appender-tracing/
  stdout pipeline with a minimal tracing_subscriber::Layer that writes JSON
  lines directly. The log file was already write-only (no reader parses the
  OTLP shape back); core/checks_logs.rs builds its own OTel-shaped SQLite
  records independently and is unaffected.
The OTel SDK (SdkLoggerProvider, OpenTelemetryTracingBridge,
FileLogExporter) this PR replaces was still referenced by
core_logging_test.rs after the merge with main, breaking CI
(unresolved opentelemetry* crates). Rewrite the test against the new
JsonLogLayer, exposing it as pub(crate)->pub so tests can construct it
directly with a thread-local subscriber instead of the removed OTel
pipeline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants