You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
After running a pstree it was confirmed that the origin was snapd {snapd}(41504)
The source of all of these calls to os.Hostname() seem to come from this little snippet in control/control.go
go func() {
for m := range cMetrics {
// Reapply standard tags after collection as a precaution. It is common for
// plugin authors to inadvertently overwrite or not pass along the data
// passed to CollectMetrics so we will help them out here.
for i := range m {
m[i] = addStandardAndWorkflowTags(m[i], allTags)
}
metrics = append(metrics, m...)
wg.Done()
}
}()
// hostnameReader, hostnamer created for mocking
func init() {
hostnameReader = &hostnameReaderType{}
}
type hostnamer interface {
Hostname() (name string, err error)
}
type hostnameReaderType struct{}
func (h *hostnameReaderType) Hostname() (name string, err error) {
return os.Hostname()
}
While the performance impact isn't that serious due to the nature of /proc/, I do think its expensive enough to store in a var. Let me know what you think and I put in a PR.
Thanks,
Jacob
The text was updated successfully, but these errors were encountered:
I think it makes sense to reduce the number of calls since the hostname shouldn't be changing super often. Were you thinking about having it called once per collect or just once in per snapd startup?
After running a stack trace there was a large number of reads to
/proc/sys/kernel/hostname
After running a pstree it was confirmed that the origin was snapd
{snapd}(41504)
The source of all of these calls to os.Hostname() seem to come from this little snippet in control/control.go
control/metrics.go
While the performance impact isn't that serious due to the nature of
/proc/
, I do think its expensive enough to store in a var. Let me know what you think and I put in a PR.Thanks,
Jacob
The text was updated successfully, but these errors were encountered: