Skip to content

Populate InstrumentationScope fields in trace output#131

Merged
andrewh merged 2 commits into
mainfrom
populate-instrumentation-scope
Mar 6, 2026
Merged

Populate InstrumentationScope fields in trace output#131
andrewh merged 2 commits into
mainfrom
populate-instrumentation-scope

Conversation

@andrewh

@andrewh andrewh commented Mar 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Set InstrumentationScope.Name to the module path (github.com/andrewh/motel), Version to the build version, and SchemaURL to the OTel semconv schema URL. Previously these used the service name and left Version/SchemaURL empty
  • Add motel.synthetic: true scope attribute to demonstrate InstrumentationScope.Attributes to users
  • check.go uses the module path only (no version/schema/attributes) since its in-memory exporter is for analysis, not user-facing output

Test plan

  • make test passes
  • make build && build/motel emit --service core --operation health_check --stdout confirms all scope fields populated
  • make lint — no new issues

🤖 Generated with Claude Code

andrewh added 2 commits March 6, 2026 14:13
Set InstrumentationScope.Name to the module path
("github.com/andrewh/motel"), Version to the build version, and
SchemaURL to the OTel semconv schema URL. Previously these fields
used the service name as the tracer name and left Version/SchemaURL
empty, which doesn't match the OTel spec's intent for scope fields.
…tributes

Shows users that InstrumentationScope.Attributes can carry metadata
about the instrumentation library itself.
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the OpenTelemetry trace output by populating the InstrumentationScope fields with more precise and comprehensive metadata. It configures the tracer to include the module path, build version, and the OpenTelemetry semantic conventions schema URL, along with a synthetic attribute for demonstration. These changes ensure that generated trace data is richer and more informative, aiding in better observability and debugging.

Highlights

  • OpenTelemetry InstrumentationScope fields: The InstrumentationScope.Name is now set to the module path (github.com/andrewh/motel), Version to the build version, and SchemaURL to the OTel semantic conventions schema URL, replacing previous less specific values.
  • Synthetic Scope Attribute: A motel.synthetic: true attribute was added to the InstrumentationScope to demonstrate the use of scope attributes.
  • check.go Tracer Configuration: The check.go file's in-memory exporter now uses only the module path for its tracer, without version, schema, or attributes, as it's intended for analysis rather than user-facing output.
Changelog
  • cmd/motel/main.go
    • Imported go.opentelemetry.io/otel/semconv/v1.39.0 for schema URL.
    • Modified tp.Tracer calls in emitCmd and runGenerate to set InstrumentationScope.Name to "github.com/andrewh/motel", Version using trace.WithInstrumentationVersion(version), SchemaURL using trace.WithSchemaURL(otelsc.SchemaURL), and added motel.synthetic: true attribute.
  • pkg/synth/check.go
    • Updated the tp.Tracer call in SampleTraces to explicitly use "github.com/andrewh/motel" as the instrumentation scope name.
Activity
  • No human activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request correctly populates the InstrumentationScope fields in the trace output, aligning with OpenTelemetry best practices. A security audit confirmed that no new vulnerabilities were introduced, and user-supplied inputs are handled securely. My review also includes a critical fix for an invalid import path that would break the build, and a suggestion to refactor duplicated code for better maintainability.

Comment thread cmd/motel/main.go
Comment thread cmd/motel/main.go
@andrewh
andrewh merged commit 45ea364 into main Mar 6, 2026
2 checks passed
@andrewh
andrewh deleted the populate-instrumentation-scope branch March 6, 2026 14:26
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.

1 participant