mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-11-03 02:20:04 +00:00
- imports: ClickHouse/ch-go, clickhouse-go/v2, srikanthccv/ClickHouse-go-mock
-> github.com/hanzo-ds/{native,go,mock} (require, clean semver, NO replace)
- identifiers/aliases/type-names/config-keys/type-IDs: clickhouse -> datastore
(receiver dir clickhousesystemtablesreceiver -> datastoresystemtablesreceiver)
- DSN scheme clickhouse:// -> datastore:// (driver treats non-http/https as Native)
- removed the go.opencensus.io version-pin replace (require-pinned instead)
- kept: real external refs (github.com/ClickHouse, clickhouse.com docs) and the
hanzo-ds/mock test API (NewClickHouseNative) pending the mock's own rename
Full ./... build passes. 0 replace directives, 0 signoz.
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 Datastore 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
|
|
}
|