-
Notifications
You must be signed in to change notification settings - Fork 77
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
Export the versions of Go modules linked into the binary #578
Conversation
Path: "example.com/path/to/main/module", | ||
Version: "(devel)", | ||
}, | ||
Deps: []*debug.Module{{ |
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.
nit: consider adding a case of replaced=true
?
internal/prometheusbpint/modules.go
Outdated
goModules.With(prometheus.Labels{ | ||
"go_module": mod.Path, | ||
"module_role": role, | ||
"replaced": strconv.FormatBool(mod.Replace != nil), |
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.
🔕 I think overall we want to avoid using single word labels, as the whole label indices are global so two unrelated metrics emitting with the same label (e.g. conflicted labels) will make searching by label slower. I'd suggest use module_replaced
instead.
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.
hmm, makes it a not-strict backport but I can make the change to v2 as well.
internal/prometheusbpint/modules.go
Outdated
}, []string{"go_module", "module_role", "module_replaced", "module_version"}) | ||
|
||
func RecordModuleVersions(info *debug.BuildInfo) { | ||
record := func(role string, mod *debug.Module) { |
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.
Out of curiosity, what's the reason for defining this inside rather than at the top-level?
internal/prometheusbpint/modules.go
Outdated
Help: "Export the version information for included Go modules, and whether the module is the 'main' module or a 'dependency'. Always 1", | ||
}, []string{"go_module", "module_role", "module_replaced", "module_version"}) | ||
|
||
func RecordModuleVersions(info *debug.BuildInfo) { |
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.
🔕 also, do we want to consider moving this to prometheusbp
so some more customized services (that don't use baseplate.New
) can also use it?
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.
+1 I think it would be useful to not lock this behind internal
internal/prometheusbpint/modules.go
Outdated
Help: "Export the version information for included Go modules, and whether the module is the 'main' module or a 'dependency'. Always 1", | ||
}, []string{"go_module", "module_role", "module_replaced", "module_version"}) | ||
|
||
func RecordModuleVersions(info *debug.BuildInfo) { |
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.
+1 I think it would be useful to not lock this behind internal
baseplate.go
Outdated
@@ -310,7 +309,7 @@ func New(ctx context.Context, args NewArgs) (context.Context, Baseplate, error) | |||
bp := impl{cfg: cfg, closers: batchcloser.New()} | |||
|
|||
if info, ok := debug.ReadBuildInfo(); ok { | |||
prometheusbpint.RecordModuleVersions(info) | |||
metricsbp.RecordModuleVersions(info) |
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.
you want prometheusbp
instead of metricsbp
😅
💸 TL;DR
Backport of module metrics from v2.0.0
✅ Checks
Contributor License Agreement (CLA) completed if not a Reddit employee