Skip to content

Commit

Permalink
Add an info message when pushing logs and metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
tr11 committed Feb 8, 2024
1 parent c1c0373 commit c300331
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 9 additions & 1 deletion exporter/qrynexporter/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ func convertLogToTimeSerie(fingerprint model.Fingerprint, log plog.LogRecord, la
}

func (e *logsExporter) pushLogsData(ctx context.Context, ld plog.Logs) error {
start := time.Now()

var (
samples []Sample
timeSeries []TimeSerie
Expand Down Expand Up @@ -430,7 +432,13 @@ func (e *logsExporter) pushLogsData(ctx context.Context, ld plog.Logs) error {
}
}

return batchSamplesAndTimeSeries(context.WithValue(ctx, "cluster", e.cluster), e.db, samples, timeSeries)
if err := batchSamplesAndTimeSeries(context.WithValue(ctx, "cluster", e.cluster), e.db, samples, timeSeries); err != nil {
return err
}

e.logger.Info("pushLogsData", zap.Int("samples", len(samples)), zap.Int("timeseries", len(timeSeries)), zap.String("cost", time.Since(start).String()))

return nil
}

func batchSamplesAndTimeSeries(ctx context.Context, db clickhouse.Conn, samples []Sample, timeSeries []TimeSerie) error {
Expand Down
11 changes: 10 additions & 1 deletion exporter/qrynexporter/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math"
"strconv"
"strings"
"time"
"unicode"

"github.com/ClickHouse/clickhouse-go/v2"
Expand Down Expand Up @@ -461,6 +462,8 @@ func (e *metricsExporter) collectFromMetric(metric pmetric.Metric, resource pcom
}

func (e *metricsExporter) pushMetricsData(ctx context.Context, md pmetric.Metrics) error {
start := time.Now()

// for collect samples and timeSeries
var (
samples []Sample
Expand All @@ -479,7 +482,13 @@ func (e *metricsExporter) pushMetricsData(ctx context.Context, md pmetric.Metric
}
}

return batchSamplesAndTimeSeries(context.WithValue(ctx, "cluster", e.cluster), e.db, samples, timeSeries)
if err := batchSamplesAndTimeSeries(context.WithValue(ctx, "cluster", e.cluster), e.db, samples, timeSeries); err != nil {
return err
}

e.logger.Info("pushMetricsData", zap.Int("samples", len(samples)), zap.Int("timeseries", len(timeSeries)), zap.String("cost", time.Since(start).String()))

return nil
}

// isValidAggregationTemporality checks whether an OTel metric has a valid
Expand Down

0 comments on commit c300331

Please sign in to comment.