mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-11-03 02:20:04 +00:00
- Fix 'Hanzo O11y' (space) → 'HanzoO11y' in Go struct/func names - Package o11yclickhousemetrics → o11ydatastoremetrics (matches dir) - Package o11yclickhousemeter → o11ydatastoremeter (matches dir) - Import paths aligned with actual directory structure - Component type names kept as signozclickhousemetrics for config compat
45 lines
1.5 KiB
Go
45 lines
1.5 KiB
Go
package o11ydatastoremeter
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"go.opentelemetry.io/collector/component"
|
|
"go.opentelemetry.io/collector/config/configoptional"
|
|
"go.opentelemetry.io/collector/config/configretry"
|
|
"go.opentelemetry.io/collector/exporter/exporterhelper"
|
|
)
|
|
|
|
// Config defines configuration for ClickHouse Metrics exporter.
|
|
type Config struct {
|
|
exporterhelper.TimeoutConfig `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
|
|
BackOffConfig configretry.BackOffConfig `mapstructure:"retry_on_failure"`
|
|
QueueBatchConfig configoptional.Optional[exporterhelper.QueueBatchConfig] `mapstructure:"sending_queue"`
|
|
DSN string `mapstructure:"dsn"`
|
|
Database string `mapstructure:"database"`
|
|
SamplesTable string `mapstructure:"samples_table"`
|
|
}
|
|
|
|
var _ component.Config = (*Config)(nil)
|
|
|
|
// Validate checks if the exporter configuration is valid
|
|
func (cfg *Config) Validate() error {
|
|
if cfg.DSN == "" {
|
|
return errors.New("dsn must be specified")
|
|
}
|
|
if qc := cfg.QueueBatchConfig.Get(); qc != nil {
|
|
if err := qc.Validate(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
if err := cfg.TimeoutConfig.Validate(); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := cfg.BackOffConfig.Validate(); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|