Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Murphy Chen <[email protected]>
  • Loading branch information
Frapschen committed Oct 8, 2024
1 parent 46b8dfc commit 3f92a43
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 84 deletions.
52 changes: 34 additions & 18 deletions exporter/clickhouseexporter/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,53 @@

The following telemetry is emitted by this component.

### otelcol_exporter_clickhouse_sent_batch_size
### otelcol_exporter_clickhouse_sent_logs

How many count of a batch sent to Clickhouse. Clickhouse recommend inserting data in packets of at least 1000 rows, or no more than a single request per second.
Number of logs the exporter sent.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| int | Histogram | Int |
| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {logs} | Sum | Int | true |

### otelcol_exporter_clickhouse_sent_data_points
### otelcol_exporter_clickhouse_sent_logs_batch_size

Number of data points the exporter sent.
How many counts of a batch are sent to Clickhouse. Clickhouse recommend inserting metric in packets of at least 1000 rows, or no more than a single request per second.

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {data_points} | Sum | Int | true |
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| int | Histogram | Int |

### otelcol_exporter_clickhouse_sent_data_points_latency
### otelcol_exporter_clickhouse_sent_logs_latency

Latency (in milliseconds) of each sent data points batch.
Latency (in milliseconds) of each sent log batch.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| ms | Histogram | Int |

### otelcol_exporter_clickhouse_sent_logs
### otelcol_exporter_clickhouse_sent_metric_points

Number of logs the exporter sent.
Number of metric points the exporter sent.

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {logs} | Sum | Int | true |
| {metric_points} | Sum | Int | true |

### otelcol_exporter_clickhouse_sent_logs_latency
### otelcol_exporter_clickhouse_sent_metric_points_batch_size

Latency (in milliseconds) of each sent log batch.
How many counts of a batch are sent to Clickhouse. Clickhouse recommend inserting metric in packets of at least 1000 rows, or no more than a single request per second.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| ms | Histogram | Int |
| int | Histogram | Int |

### otelcol_exporter_clickhouse_sent_metric_points_latency

Metric.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| 1 | Histogram | Int |

### otelcol_exporter_clickhouse_sent_spans

Expand All @@ -54,6 +62,14 @@ Number of spans the exporter sent.
| ---- | ----------- | ---------- | --------- |
| {spans} | Sum | Int | true |

### otelcol_exporter_clickhouse_sent_spans_batch_size

How many counts of a batch are sent to Clickhouse. Clickhouse recommend inserting metric in packets of at least 1000 rows, or no more than a single request per second.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| int | Histogram | Int |

### otelcol_exporter_clickhouse_sent_spans_latency

Latency (in milliseconds) of each sent span batch.
Expand Down
5 changes: 2 additions & 3 deletions exporter/clickhouseexporter/exporter_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ type logsExporter struct {
}

func newLogsExporter(settings exporter.Settings, cfg *Config) (*logsExporter, error) {
telemetry, err := metadata.NewTelemetryBuilder(settings.TelemetrySettings,
metadata.WithLevel(settings.TelemetrySettings.MetricsLevel))
telemetry, err := metadata.NewTelemetryBuilder(settings.TelemetrySettings)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -288,7 +287,7 @@ func doWithTx(_ context.Context, db *sql.DB, fn func(tx *sql.Tx) error) error {

func recordLogsInternalMetrics(ctx context.Context, telemetry *metadata.TelemetryBuilder, count int64, duration time.Duration, hasError bool) {
if !hasError {
telemetry.ExporterClickhouseSentBatchSize.Record(ctx, count, metric.WithAttributes(attribute.KeyValue{Key: "telemetry_type", Value: attribute.StringValue("logs")}))
telemetry.ExporterClickhouseSentLogsBatchSize.Record(ctx, count)
}
telemetry.ExporterClickhouseSentLogs.Add(ctx, count, metric.WithAttributes(attribute.KeyValue{Key: "error", Value: attribute.BoolValue(hasError)}))
telemetry.ExporterClickhouseSentLogsLatency.Record(ctx, duration.Milliseconds(), metric.WithAttributes(attribute.KeyValue{Key: "error", Value: attribute.BoolValue(hasError)}))
Expand Down
3 changes: 1 addition & 2 deletions exporter/clickhouseexporter/exporter_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ type metricsExporter struct {
}

func newMetricsExporter(settings exporter.Settings, cfg *Config) (*metricsExporter, error) {
telemetry, err := metadata.NewTelemetryBuilder(settings.TelemetrySettings,
metadata.WithLevel(settings.TelemetrySettings.MetricsLevel))
telemetry, err := metadata.NewTelemetryBuilder(settings.TelemetrySettings)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions exporter/clickhouseexporter/exporter_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ type tracesExporter struct {
}

func newTracesExporter(settings exporter.Settings, cfg *Config) (*tracesExporter, error) {
telemetry, err := metadata.NewTelemetryBuilder(settings.TelemetrySettings,
metadata.WithLevel(settings.TelemetrySettings.MetricsLevel))
telemetry, err := metadata.NewTelemetryBuilder(settings.TelemetrySettings)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -326,7 +325,7 @@ func renderTraceIDTsMaterializedViewSQL(cfg *Config) string {

func recordSpansInternalMetrics(ctx context.Context, telemetry *metadata.TelemetryBuilder, count int64, duration time.Duration, hasError bool) {
if !hasError {
telemetry.ExporterClickhouseSentBatchSize.Record(ctx, count, metric.WithAttributes(attribute.KeyValue{Key: "telemetry_type", Value: attribute.StringValue("Traces")}))
telemetry.ExporterClickhouseSentSpansBatchSize.Record(ctx, count)
}
telemetry.ExporterClickhouseSentSpans.Add(ctx, count, metric.WithAttributes(attribute.KeyValue{Key: "error", Value: attribute.BoolValue(hasError)}))
telemetry.ExporterClickhouseSentSpansLatency.Record(ctx, duration.Milliseconds(), metric.WithAttributes(attribute.KeyValue{Key: "error", Value: attribute.BoolValue(hasError)}))
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

117 changes: 69 additions & 48 deletions exporter/clickhouseexporter/internal/metadata/generated_telemetry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions exporter/clickhouseexporter/internal/metrics_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ func newPlaceholder(count int) *string {

func recordMetricsInternalMetrics(ctx context.Context, telemetry *metadata.TelemetryBuilder, count int64, duration time.Duration, hasError bool) {
if !hasError {
telemetry.ExporterClickhouseSentBatchSize.Record(ctx, count, metric.WithAttributes(attribute.KeyValue{Key: "telemetry_type", Value: attribute.StringValue("metrics")}))
telemetry.ExporterClickhouseSentMetricPointsBatchSize.Record(ctx, count)
}
telemetry.ExporterClickhouseSentDataPoints.Add(ctx, count, metric.WithAttributes(attribute.KeyValue{Key: "error", Value: attribute.BoolValue(hasError)}))
telemetry.ExporterClickhouseSentDataPointsLatency.Record(ctx, duration.Milliseconds(), metric.WithAttributes(attribute.KeyValue{Key: "error", Value: attribute.BoolValue(hasError)}))
telemetry.ExporterClickhouseSentMetricPoints.Add(ctx, count, metric.WithAttributes(attribute.KeyValue{Key: "error", Value: attribute.BoolValue(hasError)}))
telemetry.ExporterClickhouseSentMetricPointsLatency.Record(ctx, duration.Milliseconds(), metric.WithAttributes(attribute.KeyValue{Key: "error", Value: attribute.BoolValue(hasError)}))
}
Loading

0 comments on commit 3f92a43

Please sign in to comment.