Path: blob/main/pkg/traces/remotewriteexporter/factory.go
4096 views
package remotewriteexporter12import (3"context"4"time"56"github.com/prometheus/client_golang/prometheus"7"go.opentelemetry.io/collector/component"8"go.opentelemetry.io/collector/config"9)1011const (12// TypeStr is the unique identifier for the Prometheus remote write exporter.13// TODO: Rename to walexporter (?). Remote write makes no sense, it appends to a WAL.14TypeStr = "remote_write"15)1617var _ config.Exporter = (*Config)(nil)1819// Config holds the configuration for the Prometheus remote write processor.20type Config struct {21config.ExporterSettings `mapstructure:",squash"`2223ConstLabels prometheus.Labels `mapstructure:"const_labels"`24Namespace string `mapstructure:"namespace"`25PromInstance string `mapstructure:"metrics_instance"`26// StaleTime is the duration after which a series is considered stale and will be removed.27StaleTime time.Duration `mapstructure:"stale_time"`28// LoopInterval is the duration after which the exporter will be checked for new data.29// New data is flushed to a WAL.30LoopInterval time.Duration `mapstructure:"loop_interval"`31}3233// NewFactory returns a new factory for the Prometheus remote write processor.34func NewFactory() component.ExporterFactory {35return component.NewExporterFactory(36TypeStr,37createDefaultConfig,38component.WithMetricsExporter(createMetricsExporter, component.StabilityLevelUndefined),39)40}4142func createDefaultConfig() config.Exporter {43return &Config{44ExporterSettings: config.NewExporterSettings(config.NewComponentIDWithName(TypeStr, TypeStr)),45}46}4748func createMetricsExporter(49_ context.Context,50_ component.ExporterCreateSettings,51cfg config.Exporter,52) (component.MetricsExporter, error) {5354eCfg := cfg.(*Config)55return newRemoteWriteExporter(eCfg)56}575859