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.
83 lines
3.0 KiB
Go
83 lines
3.0 KiB
Go
// Copyright 2020, OpenTelemetry Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package datastorelogsexporter
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
|
|
"github.com/hanzoai/otel-collector/utils"
|
|
"go.opentelemetry.io/collector/config/configoptional"
|
|
"go.opentelemetry.io/collector/config/configretry"
|
|
"go.opentelemetry.io/collector/exporter/exporterhelper"
|
|
"go.uber.org/multierr"
|
|
)
|
|
|
|
const (
|
|
defaultPromotedPathsSyncInterval = 5 * time.Minute
|
|
defaultMaxAllowedDataAgeDays int = 15
|
|
)
|
|
|
|
type AttributesLimits struct {
|
|
FetchKeysInterval time.Duration `mapstructure:"fetch_keys_interval"`
|
|
MaxDistinctValues int `mapstructure:"max_distinct_values"`
|
|
}
|
|
|
|
// Config defines configuration for Datastore exporter.
|
|
type Config struct {
|
|
exporterhelper.TimeoutConfig `mapstructure:",squash"`
|
|
BackOffConfig configretry.BackOffConfig `mapstructure:"retry_on_failure"`
|
|
QueueBatchConfig configoptional.Optional[exporterhelper.QueueBatchConfig] `mapstructure:"sending_queue"`
|
|
|
|
// DSN is the Datastore server Data Source Name.
|
|
// For tcp protocol reference: [Datastore/datastore-go#dsn](https://github.com/ClickHouse/clickhouse-go#dsn).
|
|
DSN string `mapstructure:"dsn"`
|
|
UseNewSchema bool `mapstructure:"use_new_schema"`
|
|
LogLevelConcurrency *int `mapstructure:"log_level_concurrency"`
|
|
|
|
AttributesLimits AttributesLimits `mapstructure:"attributes_limits"`
|
|
PromotedPathsSyncInterval *time.Duration `mapstructure:"promoted_paths_sync_interval"`
|
|
BodyJSONEnabled bool `mapstructure:"body_json_enabled"`
|
|
BodyJSONOldBodyEnabled bool `mapstructure:"body_json_old_body_enabled"`
|
|
// MaxAllowedDataAgeDays drops logs older than now minus this many days.
|
|
MaxAllowedDataAgeDays *int `mapstructure:"max_allowed_data_age_days"`
|
|
}
|
|
|
|
var (
|
|
errConfigNoDSN = errors.New("dsn must be specified")
|
|
)
|
|
|
|
// Validate validates the datastore server configuration.
|
|
func (cfg *Config) Validate() (err error) {
|
|
if cfg.DSN == "" {
|
|
err = multierr.Append(err, errConfigNoDSN)
|
|
}
|
|
if cfg.PromotedPathsSyncInterval == nil {
|
|
cfg.PromotedPathsSyncInterval = utils.ToPointer(defaultPromotedPathsSyncInterval)
|
|
}
|
|
|
|
if cfg.LogLevelConcurrency == nil {
|
|
cfg.LogLevelConcurrency = utils.ToPointer(utils.Concurrency())
|
|
}
|
|
if *cfg.LogLevelConcurrency < 1 {
|
|
err = multierr.Append(err, errors.New("concurrency must be greater than 0"))
|
|
}
|
|
if cfg.MaxAllowedDataAgeDays == nil {
|
|
cfg.MaxAllowedDataAgeDays = utils.ToPointer(defaultMaxAllowedDataAgeDays)
|
|
}
|
|
|
|
return err
|
|
}
|