Skip to content

(OTEL) Minimally integrate OpenTelemetry - #1795

Open
Mikey Lombardi (He/Him) (michaeltlombardi) wants to merge 1 commit into
PowerShell:mainfrom
michaeltlombardi:otel/main/minimal-otel
Open

Mikey Lombardi (He/Him) (michaeltlombardi) wants to merge 1 commit into
PowerShell:mainfrom
michaeltlombardi:otel/main/minimal-otel

Conversation

@michaeltlombardi

Copy link
Copy Markdown
Collaborator

PR Summary

This change:

  • Updates the dsc-lib-telemetry crate to re-export the following external crates from the crate root:

    • opentelemetry as otel
    • opentelemetry_sdk as otel_sdk
    • opentelemetry_semantic_conventions as otel_conventions
    • tracing
    • tracing_indicatif
    • tracing_log
    • tracing_opentelemetry as tracing_otel
    • tracing_subscriber

    This enables crates to take a singular dependency on dsc-lib-telemetry and gain access to all the re-exported tracing and OpenTelemetry functionality.

    For this initial implementation, the re-exports aren't gated behind crate features.

  • Restructures the dsc-lib-telemetry crate to:

    • Replace the public basic module with the BasicTracingOptions struct with a private options module and re-export the renamed DscTracingOptions struct from the crate root.

      The re-exports for tracing crates are moved to the crate root for more ergonomic access.

    • Move the definition for StderrFormat from the crate root into the private stderr_format module and re-export the enum from the crate root.

  • Implements the FormatEvent trait for a custom tracing event formatter named DscTracingEventFormatter. This formatter keeps the same formatting used by the previous implementation except that it discards span information from the console output.

    This is necessary as we migrate to tracing spans with open telemetry because the upstream formatter emits extremely noisy span information before the event message and any included payloads.

  • Enhances the TracingOptions API to support initializing a tracing subscriber with and without OpenTelemetry integration.

    In the initial implementation, the OpenTelemetry integration uses a no-op exporter for spans. The implementation continues to emit event data to stderr as before. Exporting spans to an actual OpenTelemetry backend or file depends on defining a contract for telemetry exporting extensions for DSC and is deferred at this time.

  • Updates the CLI to immediately start a root span after setting up tracing. This ensures that all subsequent tracing events are captured within the context of the root span, providing a consistent tracing structure for the application's execution.

    Future changes are required to further define spans for discrete operations within the application, ensuring that tracing captures meaningful and structured telemetry data throughout the execution flow.

PR Context

Prior to this change, the DSC library only supported basic tracing functionality using the tracing crate. It used the tracing macros to emit events, which the CLI then emitted to stderr.

Important

This change depends on #1769

This comment was marked as outdated.

Prior to this change, the DSC library only supported basic tracing
functionality using the `tracing` crate. It used the `tracing` macros
to emit events, which the CLI then emitted to stderr.

This change:

- Updates the `dsc-lib-telemetry` crate to re-export the following
  external crates from the crate root:

  - `opentelemetry` as `otel`
  - `opentelemetry_sdk` as `otel_sdk`
  - `opentelemetry_semantic_conventions` as `otel_conventions`
  - `tracing`
  - `tracing_indicatif`
  - `tracing_log`
  - `tracing_opentelemetry` as `tracing_otel`
  - `tracing_subscriber`

  This enables crates to take a singular dependency on
  `dsc-lib-telemetry` and gain access to all the re-exported tracing
  and OpenTelemetry functionality.

  For this initial implementation, the re-exports aren't gated behind
  crate features.

- Restructures the `dsc-lib-telemetry` crate to:

  - Replace the public `basic` module with the `BasicTracingOptions`
    struct with a private `options` module and re-export the renamed
    `DscTracingOptions` struct from the crate root.

    The re-exports for tracing crates are moved to the crate root for
    more ergonomic access.
  - Move the definition for `StderrFormat` from the crate root into
    the private `stderr_format` module and re-export the enum from the
    crate root.

- Implements the `FormatEvent` trait for a custom tracing event
  formatter named `DscTracingEventFormatter`. This formatter keeps the
  same formatting used by the previous implementation except that it
  discards span information from the console output.

  This is necessary as we migrate to tracing spans with open telemetry
  because the upstream formatter emits extremely noisy span information
  before the event message and any included payloads.

- Enhances the `TracingOptions` API to support initializing a tracing
  subscriber with and without OpenTelemetry integration.

  In the initial implementation, the OpenTelemetry integration uses a
  no-op exporter for spans. The implementation continues to emit event
  data to stderr as before. Exporting spans to an actual OpenTelemetry
  backend or file depends on defining a contract for telemetry exporting
  extensions for DSC and is deferred at this time.

- Updates the CLI to immediately start a root span after setting up
  tracing. This ensures that all subsequent tracing events are captured
  within the context of the root span, providing a consistent tracing
  structure for the application's execution.

  Future changes are required to further define spans for discrete
  operations within the application, ensuring that tracing captures
  meaningful and structured telemetry data throughout the execution
  flow.
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