-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Apply new experimental metrics builder to hostmetrics/cpu scraper #6418
Conversation
a3444d5
to
01b3521
Compare
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/internal/metadata/generated_metrics.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/internal/metadata/generated_metrics.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/internal/metadata/generated_metrics.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/cpu_scraper.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/cpu_scraper.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/cpu_scraper.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/cpu_scraper.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/cpu_scraper_linux.go
Outdated
Show resolved
Hide resolved
withStartTime := metadata.WithStartTime(pdata.Timestamp(bootTime * 1e9)) | ||
withStatesCapacity := metadata.WithAttributeStateCapacity(cpuStatesLen) | ||
withCoresCapacity := metadata.WithAttributeCpuCapacity(runtime.NumCPU()) | ||
s.mb = metadata.NewMetricsBuilder(s.config.Metrics, withStartTime, withStatesCapacity, withCoresCapacity) |
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.
Some scrapers will have many more "Capacity" parameters. Should we render these into separate functions, perhaps like this?
s.mb = metadata.NewMetricsBuilder(s.config.Metrics, withStartTime).
WithStatesCapacity(withStatesCapacity).
WithCoresCapacity(withCoresCapacity)
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.
In that case I would change it for all including withStartTime. I like it, but seems like it's not very common pattern in the collector's codebase. @bogdandrutu what's your thought on this?
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 this is the most "go" way to have this:
s.mb = metadata.NewMetricsBuilder(
s.config.Metrics,
metadata.WithStartTime(pdata.Timestamp(bootTime * 1e9)),
metadata.WithAttributeStateCapacity(cpuStatesLen),
metadata.WithAttributeCpuCapacity(runtime.NumCPU()))
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/cpu_scraper.go
Outdated
Show resolved
Hide resolved
336f0f5
to
505d64a
Compare
Introduce new experimental metrics builder interface for metrics scrapers and apply it to hostmetrics/cpu scraper.
505d64a
to
21114a8
Compare
func (mb *MetricsBuilder) Emit(metrics pdata.MetricSlice) { | ||
{{- range $name, $metric := .Metrics }} | ||
if mb.config.{{- $name.Render }}.Enabled { | ||
mb.metrics.{{- $name.Render }}.CopyTo(metrics.AppendEmpty()) |
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.
MoveTo?
…pen-telemetry#6418) Introduce new experimental metrics builder interface for metrics scrapers and apply it to hostmetrics/cpu scraper.
Introduce new experimental metrics builder interface for metrics scrapers and apply it to hostmetrics/cpu scraper.
Link to tracking Issue: open-telemetry/opentelemetry-collector#10904