go-http-server-with-otel/pkg/otel/settings.go

39 lines
648 B
Go
Raw Normal View History

2025-01-04 05:06:49 +00:00
package otel
2025-01-04 02:49:59 +00:00
import "time"
type settings struct {
2025-01-04 05:06:49 +00:00
EnableStdoutExporter bool
EnablePrometheusExporter bool
MetricExportInterval time.Duration
2025-01-04 02:49:59 +00:00
}
type Option interface {
apply(*settings)
}
type enableStdoutExporter struct {
Option
}
func (setting enableStdoutExporter) apply(o *settings) {
o.EnableStdoutExporter = true
}
2025-01-04 05:06:49 +00:00
type enablePrometheusExporter struct {
Option
}
func (setting enablePrometheusExporter) apply(o *settings) {
o.EnablePrometheusExporter = true
}
2025-01-04 02:49:59 +00:00
type exportInterval struct {
Option
interval time.Duration
}
func (setting exportInterval) apply(o *settings) {
o.MetricExportInterval = setting.interval
}