Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/pkg/traces/remotewriteexporter/factory.go
4096 views
1
package remotewriteexporter
2
3
import (
4
"context"
5
"time"
6
7
"github.com/prometheus/client_golang/prometheus"
8
"go.opentelemetry.io/collector/component"
9
"go.opentelemetry.io/collector/config"
10
)
11
12
const (
13
// TypeStr is the unique identifier for the Prometheus remote write exporter.
14
// TODO: Rename to walexporter (?). Remote write makes no sense, it appends to a WAL.
15
TypeStr = "remote_write"
16
)
17
18
var _ config.Exporter = (*Config)(nil)
19
20
// Config holds the configuration for the Prometheus remote write processor.
21
type Config struct {
22
config.ExporterSettings `mapstructure:",squash"`
23
24
ConstLabels prometheus.Labels `mapstructure:"const_labels"`
25
Namespace string `mapstructure:"namespace"`
26
PromInstance string `mapstructure:"metrics_instance"`
27
// StaleTime is the duration after which a series is considered stale and will be removed.
28
StaleTime time.Duration `mapstructure:"stale_time"`
29
// LoopInterval is the duration after which the exporter will be checked for new data.
30
// New data is flushed to a WAL.
31
LoopInterval time.Duration `mapstructure:"loop_interval"`
32
}
33
34
// NewFactory returns a new factory for the Prometheus remote write processor.
35
func NewFactory() component.ExporterFactory {
36
return component.NewExporterFactory(
37
TypeStr,
38
createDefaultConfig,
39
component.WithMetricsExporter(createMetricsExporter, component.StabilityLevelUndefined),
40
)
41
}
42
43
func createDefaultConfig() config.Exporter {
44
return &Config{
45
ExporterSettings: config.NewExporterSettings(config.NewComponentIDWithName(TypeStr, TypeStr)),
46
}
47
}
48
49
func createMetricsExporter(
50
_ context.Context,
51
_ component.ExporterCreateSettings,
52
cfg config.Exporter,
53
) (component.MetricsExporter, error) {
54
55
eCfg := cfg.(*Config)
56
return newRemoteWriteExporter(eCfg)
57
}
58
59