-
Notifications
You must be signed in to change notification settings - Fork 1
set service.version for deployment monitoring #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import ( | |
| "context" | ||
| "fmt" | ||
| "os" | ||
| "runtime/debug" | ||
| "time" | ||
|
|
||
| "github.com/sagernet/sing-box/log" | ||
|
|
@@ -95,10 +96,24 @@ func deltaForCounters(kind sdkmetric.InstrumentKind) metricdata.Temporality { | |
| func buildResource(extras ...attribute.KeyValue) *resource.Resource { | ||
| attrs := append([]attribute.KeyValue{ | ||
| semconv.ServiceNameKey.String("lantern-box"), | ||
| semconv.ServiceVersionKey.String(vcsRevision()), | ||
| }, extras...) | ||
| r, _ := resource.New(context.Background(), | ||
| resource.WithAttributes(attrs...), | ||
| resource.WithFromEnv(), | ||
| ) | ||
| return r | ||
| } | ||
|
|
||
| func vcsRevision() string { | ||
| bi, ok := debug.ReadBuildInfo() | ||
| if !ok { | ||
| return "unknown" | ||
| } | ||
| for _, s := range bi.Settings { | ||
| if s.Key == "vcs.revision" { | ||
| return s.Value | ||
| } | ||
|
Comment on lines
+108
to
+116
|
||
| } | ||
| return "unknown" | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buildResource()now addsservice.versionbut there’s no test asserting the attribute is present and thatOTEL_RESOURCE_ATTRIBUTEScan override it (similar to the existingservice.nametests). Adding a unit test will prevent regressions and ensure the dashboard grouping works as expected.