Skip to content

refactor(otel): share OTLP trace provider setup - #2567

Open
krishicks wants to merge 1 commit into
mainfrom
hicks/push-ponlutrqvytw
Open

refactor(otel): share OTLP trace provider setup#2567
krishicks wants to merge 1 commit into
mainfrom
hicks/push-ponlutrqvytw

Conversation

@krishicks

Copy link
Copy Markdown
Collaborator

Summary

Extract common OpenTelemetry provider construction into openshell-otel so OpenShell services share one OTLP/gRPC export implementation.

Related Issue

Refs #2507

Changes

The shared crate owns:

  • typed exporter setup errors and non-fatal provider enablement;
  • endpoint trimming and URI validation before lazy exporter connection;
  • fixed and environment-or-default service-name policies;
  • service version and caller-supplied resource attributes;
  • batch tracer-provider construction; and
  • span-only tracing layers that exclude OpenTelemetry exporter callsites.

Migrate the gateway to the shared provider while retaining its configurable service name, error marking, and tracing test collector. Add the shared crate to the architecture inventory and document the tracing boundary.

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

@copy-pr-bot

copy-pr-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Extract common OpenTelemetry provider construction into openshell-otel so
OpenShell services share one OTLP/gRPC export implementation.

The shared crate owns:

- typed exporter setup errors and non-fatal provider enablement;
- endpoint trimming and URI validation before lazy exporter connection;
- fixed and environment-or-default service-name policies;
- service version and caller-supplied resource attributes;
- batch tracer-provider construction; and
- span-only tracing layers that exclude OpenTelemetry exporter callsites.

Migrate the gateway to the shared provider while retaining its configurable
service name, error marking, and tracing test collector. Add the shared crate
to the architecture inventory and document the tracing boundary.

Refs #2507

Signed-off-by: Kris Hicks <khicks@nvidia.com>
@krishicks
krishicks force-pushed the hicks/push-ponlutrqvytw branch from 2ffd547 to 1011bcd Compare July 30, 2026 22:58
match config.service_name {
ServiceName::Fixed(name) => Resource::builder()
.with_service_name(name.trim().to_string())
.with_attributes(attributes)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an ultra-nit:

[P2] Fixed service names can be overwritten by generic attributes. In crates/openshell-otel/src/lib.rs (line 70), with_service_name() runs before with_attributes(). OpenTelemetry resource merging gives later attributes priority, so a caller-supplied service.name silently defeats ServiceName::Fixed. The EnvironmentOr path has the same ambiguity because caller attributes participate in detecting the selected name. Apply generic attributes first, then enforce the selected service-name policy, and add collision tests.

I guess the only concern here would be if an agent accidentally decided to overwrite service.name, that would be possible because with_attributes comes after with_service_name. meh ¯_(ツ)_/¯

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