Skip to content

import: prefer resource service.name over scope name in stdouttrace parser#147

Merged
andrewh merged 1 commit into
mainfrom
claude/friendly-hypatia-0ejtxb
Jun 11, 2026
Merged

import: prefer resource service.name over scope name in stdouttrace parser#147
andrewh merged 1 commit into
mainfrom
claude/friendly-hypatia-0ejtxb

Conversation

@andrewh

@andrewh andrewh commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Fixes #146

The stdouttrace parser took the service name from InstrumentationScope.Name, falling back to the synth.service attribute only when the scope name was empty. Current binaries emit a constant module-path scope name (github.com/andrewh/motel) on every span, so importing motel's own --stdout output collapsed all spans into a single service named after the Go module path, and the resulting topology failed validation.

Changes

  • The stdouttrace event struct now decodes the Resource attributes, and the service name precedence is: resource service.name, then the synth.service attribute, then the instrumentation scope name — matching the OTLP path.
  • The SDK's unknown_service placeholder is treated as absent in both the stdouttrace and OTLP paths, so output from older binaries (placeholder resource service.name, per-service scope names) still imports correctly. The checked-in fixtures continue to pass for this reason, now via the synth.service fallback rather than the scope name.
  • Added serviceNameKey/synthServiceKey constants in place of repeated string literals.

Tests

  • Table-driven unit tests covering the three precedence cases (current binary shape, older binary shape with the placeholder resource, placeholder resource without synth.service).
  • A round-trip regression test (TestRunStdoutImportRoundTrip) that runs run --stdout and feeds the fresh output through import and validate, rather than relying on the checked-in fixture that masked this regression. It also asserts the inferred topology does not contain the module path as a service name.

Verified the exact repro from the issue with the built binary: run --stdoutimportvalidate now produces a valid topology with the original service names.

https://claude.ai/code/session_01L9tNd23CewbWJ8hMTGheyf


Generated by Claude Code

The stdouttrace parser took the service name from the instrumentation
scope name, falling back to the synth.service attribute only when the
scope name was empty. Current binaries emit a constant module-path
scope name on every span, so importing motel's own --stdout output
collapsed all spans into a single service named after the Go module
path, and the resulting topology failed validation.

Parse the Resource attributes and use resource service.name first,
then the synth.service attribute, then the scope name, matching the
OTLP path's precedence. The SDK's unknown_service placeholder is
ignored in both paths so older outputs (placeholder resource,
per-service scope names) still import correctly.

Adds a round-trip regression test that imports the output of a fresh
run --stdout instead of the checked-in fixture.

Fixes #146

https://claude.ai/code/session_01L9tNd23CewbWJ8hMTGheyf
@andrewh
andrewh merged commit af26e75 into main Jun 11, 2026
2 checks passed
@andrewh
andrewh deleted the claude/friendly-hypatia-0ejtxb branch June 11, 2026 05:16
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.

import: stdouttrace parser uses instrumentation scope name as service name, breaking import of motel's own output

2 participants