123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- // Copyright The OpenTelemetry Authors
- // SPDX-License-Identifier: Apache-2.0
- package redisreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver"
- import (
- "context"
- "time"
- "go.opentelemetry.io/collector/component"
- "go.opentelemetry.io/collector/config/confignet"
- "go.opentelemetry.io/collector/config/configtls"
- "go.opentelemetry.io/collector/consumer"
- "go.opentelemetry.io/collector/receiver"
- "go.opentelemetry.io/collector/receiver/scraperhelper"
- "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver/internal/metadata"
- )
- // NewFactory creates a factory for Redis receiver.
- func NewFactory() receiver.Factory {
- return receiver.NewFactory(
- metadata.Type,
- createDefaultConfig,
- receiver.WithMetrics(createMetricsReceiver, metadata.MetricsStability))
- }
- func createDefaultConfig() component.Config {
- scs := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
- scs.CollectionInterval = 10 * time.Second
- return &Config{
- NetAddr: confignet.NetAddr{
- Transport: "tcp",
- },
- TLS: configtls.TLSClientSetting{
- Insecure: true,
- },
- ScraperControllerSettings: scs,
- MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
- }
- }
- func createMetricsReceiver(
- _ context.Context,
- set receiver.CreateSettings,
- cfg component.Config,
- consumer consumer.Metrics,
- ) (receiver.Metrics, error) {
- oCfg := cfg.(*Config)
- scrp, err := newRedisScraper(oCfg, set)
- if err != nil {
- return nil, err
- }
- return scraperhelper.NewScraperControllerReceiver(&oCfg.ScraperControllerSettings, set, consumer, scraperhelper.AddScraper(scrp))
- }
|