123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // Copyright The OpenTelemetry Authors
- // SPDX-License-Identifier: Apache-2.0
- package memoryscraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/memoryscraper"
- import (
- "context"
- "go.opentelemetry.io/collector/receiver"
- "go.opentelemetry.io/collector/receiver/scraperhelper"
- "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal"
- "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/memoryscraper/internal/metadata"
- )
- // This file implements Factory for Memory scraper.
- const (
- // TypeStr the value of "type" key in configuration.
- TypeStr = "memory"
- )
- // Factory is the Factory for scraper.
- type Factory struct {
- }
- // CreateDefaultConfig creates the default configuration for the Scraper.
- func (f *Factory) CreateDefaultConfig() internal.Config {
- return &Config{
- MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
- }
- }
- // CreateMetricsScraper creates a scraper based on provided config.
- func (f *Factory) CreateMetricsScraper(
- ctx context.Context,
- settings receiver.CreateSettings,
- config internal.Config,
- ) (scraperhelper.Scraper, error) {
- cfg := config.(*Config)
- s := newMemoryScraper(ctx, settings, cfg)
- return scraperhelper.NewScraper(
- TypeStr, s.scrape, scraperhelper.WithStart(s.start))
- }
|