Skip to content

Commit

Permalink
Use debug level to reduce unnecessary log spam and add config for type (
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv authored Sep 11, 2024
1 parent b1e3b58 commit dada755
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
5 changes: 3 additions & 2 deletions exporter/clickhousemetricsexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ type Config struct {

WatcherInterval time.Duration `mapstructure:"watcher_interval"`

WriteTSToV4 bool `mapstructure:"write_ts_to_v4"`
DisableV2 bool `mapstructure:"disable_v2"`
WriteTSToV4 bool `mapstructure:"write_ts_to_v4"`
DisableV2 bool `mapstructure:"disable_v2"`
EnableExpHist bool `mapstructure:"enable_exp_hist"`
}

// RemoteWriteQueue allows to configure the remote write queue.
Expand Down
1 change: 1 addition & 0 deletions exporter/clickhousemetricsexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func Test_loadConfig(t *testing.T) {
WatcherInterval: 30 * time.Second,
WriteTSToV4: true,
DisableV2: false,
EnableExpHist: false,
})
}

Expand Down
13 changes: 9 additions & 4 deletions exporter/clickhousemetricsexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type PrwExporter struct {
metricNameToMeta map[string]base.MetricMeta
mux *sync.Mutex
logger *zap.Logger
enableExpHist bool
}

// NewPrwExporter initializes a new PrwExporter instance and sets fields accordingly.
Expand Down Expand Up @@ -135,6 +136,7 @@ func NewPrwExporter(cfg *Config, set exporter.CreateSettings) (*PrwExporter, err
metricNameToMeta: make(map[string]base.MetricMeta),
mux: new(sync.Mutex),
logger: set.Logger,
enableExpHist: cfg.EnableExpHist,
}, nil
}

Expand Down Expand Up @@ -252,7 +254,7 @@ func (prwe *PrwExporter) PushMetrics(ctx context.Context, md pmetric.Metrics) er
dataPoints := metric.Histogram().DataPoints()
if dataPoints.Len() == 0 {
dropped++
prwe.logger.Warn("Dropped histogram metric with no data points", zap.String("name", metric.Name()))
prwe.logger.Debug("Dropped histogram metric with no data points", zap.String("name", metric.Name()))
}
for x := 0; x < dataPoints.Len(); x++ {
addSingleHistogramDataPoint(dataPoints.At(x), resource, metric, prwe.namespace, tsMap, prwe.externalLabels)
Expand All @@ -261,23 +263,26 @@ func (prwe *PrwExporter) PushMetrics(ctx context.Context, md pmetric.Metrics) er
dataPoints := metric.Summary().DataPoints()
if dataPoints.Len() == 0 {
dropped++
prwe.logger.Warn("Dropped summary metric with no data points", zap.String("name", metric.Name()))
prwe.logger.Debug("Dropped summary metric with no data points", zap.String("name", metric.Name()))
}
for x := 0; x < dataPoints.Len(); x++ {
addSingleSummaryDataPoint(dataPoints.At(x), resource, metric, prwe.namespace, tsMap, prwe.externalLabels)
}
case pmetric.MetricTypeExponentialHistogram:
if !prwe.enableExpHist {
continue
}
// we don't support cumulative exponential histograms
if temporality == pmetric.AggregationTemporalityCumulative {
dropped++
prwe.logger.Warn("Dropped cumulative histogram metric", zap.String("name", metric.Name()))
prwe.logger.Debug("Dropped cumulative histogram metric", zap.String("name", metric.Name()))
continue
}

dataPoints := metric.ExponentialHistogram().DataPoints()
if dataPoints.Len() == 0 {
dropped++
prwe.logger.Warn("Dropped exponential histogram metric with no data points", zap.String("name", metric.Name()))
prwe.logger.Debug("Dropped exponential histogram metric with no data points", zap.String("name", metric.Name()))
}

for x := 0; x < dataPoints.Len(); x++ {
Expand Down
1 change: 1 addition & 0 deletions exporter/clickhousemetricsexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,6 @@ func createDefaultConfig() component.Config {
WatcherInterval: 30 * time.Second,
WriteTSToV4: true,
DisableV2: false,
EnableExpHist: false,
}
}

0 comments on commit dada755

Please sign in to comment.