-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
1/2 Add receiverhelper functions for creating flexible "scraper" metrics receiver #1886
1/2 Add receiverhelper functions for creating flexible "scraper" metrics receiver #1886
Conversation
} | ||
|
||
return componenterror.CombineErrors(errors) | ||
} |
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 / extend NewTraceReceiver
, NewMetricReceiver
, & 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 I'm not sure if it would be straightforward to factor out that code, or worth the effort. For now, these helper functions are only intended to support the NewMetricReceiver
function where you are configuring at least one scrape target, i.e. for "pull" type receivers.
type MetricOption func(*metricsReceiver) | ||
|
||
// WithBaseOptions applies any base options to a metrics receiver. | ||
func WithBaseOptions(options ...Option) MetricOption { |
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'm interested if anyone can think of a better way of doing this btw. This seems slightly nicer than changing the NewMetricReceiver
definition to:
func NewMetricReceiver(config configmodels.Receiver, nextConsumer consumer.MetricsConsumer, baseOptions []Option, options ...MetricOption) (component.Receiver, error)
Seems like scraping could be its own package that builds on top of receiverhelper. Trying to sketch out what this might look like in use: Edit: ignore most of this, yours is more in line with the existing API. But what do you think about having the embedded ScrapeConfig struct that gets passed around instead of having to call WithCollectionInterval() (maybe we'll add more options in the future to scraper config and this would prevent having to update all receivers that use it from having to update to pass them through). package scraping
type ScrapeConfig struct {
CollectionInterval int
}
package redisreceiver
type Config struct {
scraping.ScrapeConfig
// other config here
}
type scraper struct {
}
// maybe put these in params so it can be easily expanded later. would
// probably need log instance in it as well?
func (s *scraper) collect(ctx, consumer.MetricsConsumer) {
}
type redisReceiver struct {
}
func (r *redisReceiver) start() {
}
func (r *redisReceiver) shutdown() {
}
s := &scraper{}
r := &redisReceiver{}
sb := scraping.Builder{}
sb.AddScraper(
cfg.ScrapeConfig,
scraping.WithInit(s.init),
scraping.WithCollect(s.collect),
scraping.WithClose(s.close))
// Build takes all receiverhelper options and calls them before scraper Inits / after scraper Closes.
sb.NewMetricsReceiver(cfg, receiverhelper.WithStart(r.start), receiverhelper.WithShutdown(r.shutdown)) |
355ae91
to
d8901b5
Compare
Yea I went back and forwards on this, but I guess it is nicer & more future proof to include this. Have added & updated examples - LMKWYT. I could go further and also add a |
Codecov Report
@@ Coverage Diff @@
## master #1886 +/- ##
==========================================
+ Coverage 91.28% 91.32% +0.03%
==========================================
Files 277 279 +2
Lines 16489 16574 +85
==========================================
+ Hits 15052 15136 +84
- Misses 1006 1007 +1
Partials 431 431
Continue to review full report at Codecov.
|
…y adding scrape targets
d8901b5
to
9ddaf6f
Compare
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 we should merge this and iterate over the design
…#1211) Adds skeleton for Windows Performance Counters Receiver with very basic initial functionality that can read simple counters that do not include any instance into a Gauge metric - see the added README.md for more details. **Link to tracking Issue:** #1088 Note the scaffolding code makes use of the new `receiverhelper` & `scraperhelper` functions added in the Core PRs referenced below. **Depends on:** #1175, open-telemetry/opentelemetry-collector#1886, open-telemetry/opentelemetry-collector#1890
…#1886) * Add support for scheme in OTEL_EXPORTER_OTLP_ENDPOINT according to the spec * Changes after review from pellared * Changes after review from pellared - 2 * Changes after review from pellared - 3 Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Update changelog * Update java agent to 1.14.2
receiverhelper
functions that follow a similar pattern to the other component helpers.scrape
targets that make it easy to construct a receiver that scrapes sets of metrics at configured frequency(ies).Example Usages:
Resolves #934
Supersedes #1875