Skip to content
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

hostmetricsreceiver: refactor load metrics to use generated metrics #2375

Merged
merged 1 commit into from
Jan 20, 2021
Merged

Conversation

mstumpfx
Copy link
Contributor

Description: Adding the load metrics to the metadata.yaml, and refactoring the hostmetricreceivers load metrics to use generated metrics

@mstumpfx mstumpfx requested a review from a team as a code owner January 14, 2021 17:57
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 14, 2021

CLA Signed

The committers are authorized under a signed CLA.

@codecov
Copy link

codecov bot commented Jan 14, 2021

Codecov Report

Merging #2375 (3fddb38) into master (6f772bf) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2375      +/-   ##
==========================================
- Coverage   92.01%   92.00%   -0.01%     
==========================================
  Files         273      272       -1     
  Lines       15434    15405      -29     
==========================================
- Hits        14202    14174      -28     
  Misses        850      850              
+ Partials      382      381       -1     
Impacted Files Coverage Δ
...eiver/internal/scraper/loadscraper/load_scraper.go 100.00% <100.00%> (ø)
internal/data/bytesid.go 76.92% <0.00%> (-4.03%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f772bf...3fddb38. Read the comment docs.

Copy link
Contributor

@jrcamp jrcamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

cmd/mdatagen/metrics.tmpl Show resolved Hide resolved
@@ -24,7 +24,7 @@ import (
// Type is the component type name.
const Type configmodels.Type = "hostmetricsreceiver"

type metricIntf interface {
type Metric interface {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Does this need to be exported? (It was not previously).
  2. Is it possible to come up with a less generic name? Looking at the name Metric I have a hard time understanding what it is supposed to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tigrannajaryan I had changed it to exported to be able to pass through the interface so the Init() function could be called generically -

initializeLoadMetric(metrics.At(0), metadata.Metrics.SystemCPULoadAverage1m, now, avgLoadValues.Load1)
initializeLoadMetric(metrics.At(1), metadata.Metrics.SystemCPULoadAverage5m, now, avgLoadValues.Load5)
initializeLoadMetric(metrics.At(2), metadata.Metrics.SystemCPULoadAverage15m, now, avgLoadValues.Load15)
return metrics, nil
}
func initializeLoadMetric(metric pdata.Metric, metricDescriptor metadata.Metric, now pdata.TimestampUnixNano, value float64) {
metricDescriptor.Init(metric)

I think pattern will occur more as more of the metrics in the receiver are refactored to be based off the generated metrics. The previous use cases were only for the scrapers that emitted a single metric.

I'm indifferent towards the name - MetricIntf? MetricFactory? GeneratedMetric?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, understood re exporting.

As for the name, please use something that reflects the purpose. I do not quite understand what it does to suggest a good name. The generic name Metric does not help me to understand what it is doing.

If unsure keep it unchanged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted the name back to MetricIntf for now and added a comment above to describe it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants