123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- // Copyright The OpenTelemetry Authors
- // SPDX-License-Identifier: Apache-2.0
- package couchdbreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/couchdbreceiver"
- import (
- "context"
- "time"
- "go.opentelemetry.io/collector/component"
- "go.opentelemetry.io/collector/config/confighttp"
- "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/couchdbreceiver/internal/metadata"
- )
- // NewFactory creates the couchdbreceiver factory
- func NewFactory() receiver.Factory {
- return receiver.NewFactory(
- metadata.Type,
- createDefaultConfig,
- receiver.WithMetrics(createMetricsReceiver, metadata.MetricsStability))
- }
- func createDefaultConfig() component.Config {
- return &Config{
- MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
- ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
- HTTPClientSettings: confighttp.HTTPClientSettings{
- TLSSetting: configtls.TLSClientSetting{},
- Endpoint: defaultEndpoint,
- Timeout: 1 * time.Minute,
- },
- }
- }
- func createMetricsReceiver(
- _ context.Context,
- params receiver.CreateSettings,
- rConf component.Config,
- consumer consumer.Metrics,
- ) (receiver.Metrics, error) {
- cfg := rConf.(*Config)
- ns := newCouchdbScraper(params, cfg)
- scraper, err := scraperhelper.NewScraper(metadata.Type, ns.scrape, scraperhelper.WithStart(ns.start))
- if err != nil {
- return nil, err
- }
- return scraperhelper.NewScraperControllerReceiver(
- &cfg.ScraperControllerSettings, params, consumer,
- scraperhelper.AddScraper(scraper),
- )
- }
|