-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add receiverhelper functions for creating simple "scraper" metrics receiver #1875
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
Add receiverhelper functions for creating simple "scraper" metrics receiver #1875
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1875 +/- ##
==========================================
+ Coverage 91.23% 91.27% +0.03%
==========================================
Files 272 274 +2
Lines 16263 16312 +49
==========================================
+ Hits 14838 14889 +51
+ Misses 998 994 -4
- Partials 427 429 +2
Continue to review full report at Codecov.
|
1da7c50
to
a6816f0
Compare
return br.shutdown(ctx) | ||
} | ||
return 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.
Maybe we would want to add NewTraceReceiver
, NewMetricsReceiver
, & NewLogsReceiver
functions here at some point that implement standard HTTP and/or gRPC servers for "push" type receivers.
I haven't implemented any of those types of receivers so not sure if it would be straightforward to factor out that code, or worth the effort. For now I have left this empty, and these helper functions are only intended to support the NewScraper
function, i.e. for "pull" type receivers.
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 it's fine to make it specific to metrics. I can't think of a case where traces and logs are pull (though I could potentially see wanting to pull logs from a remote source but that seems quite out of scope to this.)
6c63eae
to
1b1b253
Compare
1b1b253
to
79dc850
Compare
"go.opentelemetry.io/collector/consumer/pdata" | ||
) | ||
|
||
// Scraper provides a function to scrape metrics. |
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.
Not sure if its worth moving some of these Scraper types to component
, configmodels
, etc. This is not a first class component so that could be confusing. For now, I've gone with the straightforward approach of leaving these in receiverhelper
.
/cc @pmcollins |
Have you prototyped using this with hostmetrics receiver? Since it has several sub-scrapers will that pose an issue since NewScraper returns a receiver instance? I assume those could be decoupled. |
} | ||
|
||
// SetCollectionInterval sets the scraper collection interval. | ||
func (ss *ScraperSettings) SetCollectionInterval(collectionInterval time.Duration) { |
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.
This feels awfully Java-y. 😛 Maybe can be improved as part of decoupling receiver and scraper as part of the comment above.
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.
This is probably overkill, but replicates what the configmodels.Receiver
interface does so that it can be used in a similar manner (e.g. see usage in NewScraper
below)
Tbh I wasn't really thinking about the Host Metrics receiver when I implemented this as that receiver is a bit of a special case with the internal scrapers. I have a prototype working with a skeleton for the Perf Counters receiver I will add later 😄. But thinking about it now:
|
I doubt other receivers will do the sub-scrapers like hostmetricsreceiver but I could see a receiver wanting to scrape multiple endpoints in parallel and would create a scraper for each. I don't think it should complicate the design too much to decouple the receiver creation from scraper creation and allow the receiver creation to accept multiple scrapers. |
Hmm yea maybe it makes sense to allow multiple |
(I'm re-implementing this with the ability to configure multiple "scrape" targets, will upload this as a new PR when complete for comparison) |
See #1886 which is a much more flexible version of this that supports multiple scrape targets, etc. It should theoretically not be too difficult to refactor the host metrics receiver to use those functions. Leaving this PR open for now just for reference. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
…y#1875) * Ansible: Add proxy configuration for Windows downloads * Add variables to documentation, rename to start with win_ prefix * Update deployments/ansible/roles/collector/tasks/otel_win_install.yml Co-authored-by: Jeff Cheng <[email protected]> * Update deployments/ansible/roles/collector/tasks/win_fluentd_install.yml Co-authored-by: Jeff Cheng <[email protected]> * Update deployments/ansible/roles/collector/README.md Co-authored-by: Jeff Cheng <[email protected]> * code review * add CHANGELOG Co-authored-by: Jeff Cheng <[email protected]>
Added
receiverhelper
functions following a similar pattern to the other component helpers. Also addedscraper
functions to make it easy to construct a simple receiver that scrapes metrics at a configured frequency.I've currently only only implemented basic functionality, and only implemented this for Metrics as I don't believe the "scrape" model applies to Traces or Logs.
Resolves #934