Conversation
There was a problem hiding this comment.
Pull request overview
Adds a service.version resource attribute to lantern-box OpenTelemetry telemetry so deployments can be grouped/filtered properly in the deployments dashboard.
Changes:
- Set
service.versionon the OTELResourceviasemconv.ServiceVersionKey. - Derive the version value from Go build metadata (
vcs.revision) usingruntime/debug.ReadBuildInfo().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| semconv.ServiceNameKey.String("lantern-box"), | ||
| semconv.ServiceVersionKey.String(vcsRevision()), | ||
| }, extras...) |
There was a problem hiding this comment.
buildResource() now adds service.version but there’s no test asserting the attribute is present and that OTEL_RESOURCE_ATTRIBUTES can override it (similar to the existing service.name tests). Adding a unit test will prevent regressions and ensure the dashboard grouping works as expected.
| func vcsRevision() string { | ||
| bi, ok := debug.ReadBuildInfo() | ||
| if !ok { | ||
| return "unknown" | ||
| } | ||
| for _, s := range bi.Settings { | ||
| if s.Key == "vcs.revision" { | ||
| return s.Value | ||
| } |
There was a problem hiding this comment.
vcsRevision() calls debug.ReadBuildInfo() and scans settings every time buildResource() is called (currently at least for metrics, traces, and crash reporting). Consider memoizing the result (e.g., package-level cached string with sync.Once) to avoid repeated build-info parsing during startup/reporting.
lantern-box deployments cannot be monitored with others in the deployments dashboard because the
service.versionattribute is missing.