Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions pkg/beholder/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,74 @@ func newOtelResource(cfg Config) (resource *sdkresource.Resource, err error) {
return
}

// RecordConfig records the beholder config as a metric.
func (c *Client) RecordConfigMetric(ctx context.Context) error {
configGauge, configAttrs, err := createConfigMetric(c.Meter, c.Config)
if err != nil {
return err
}
configGauge.Record(ctx, 1, otelmetric.WithAttributes(configAttrs...))
return nil
}

// createConfigMetric creates a configuration info metric with Beholder settings as attributes.
func createConfigMetric(meter otelmetric.Meter, cfg Config) (otelmetric.Int64Gauge, []attribute.KeyValue, error) {
configGauge, err := meter.Int64Gauge(
"beholder.config.info",
otelmetric.WithDescription("Beholder config info metric"),
otelmetric.WithUnit("{info}"),
)
if err != nil {
return nil, nil, fmt.Errorf("failed to create beholder config info metric: %w", err)
}

configAttrs := []attribute.KeyValue{
// Logging config
attribute.Bool(
"log_streaming_enabled", cfg.LogStreamingEnabled),
attribute.String(
"log_level", cfg.LogLevel.String()),
attribute.Bool(
"log_batch_processor", cfg.LogBatchProcessor),
attribute.String(
"log_export_interval", cfg.LogExportInterval.String()),
attribute.Int(
"log_export_max_batch_size", cfg.LogExportMaxBatchSize),
attribute.Int(
"log_max_queue_size", cfg.LogMaxQueueSize),
attribute.String(
"log_compressor", cfg.LogCompressor),

// Message emitter config
attribute.Bool(
"chip_ingress_enabled", cfg.ChipIngressEmitterEnabled),
attribute.Bool(
"emitter_batch_processor", cfg.EmitterBatchProcessor),
attribute.String(
"emitter_export_interval", cfg.EmitterExportInterval.String()),
attribute.Int(
"emitter_export_max_batch_size", cfg.EmitterExportMaxBatchSize),
attribute.Int(
"emitter_max_queue_size", cfg.EmitterMaxQueueSize),

// Tracing config
attribute.Float64(
"trace_sample_ratio", cfg.TraceSampleRatio),
attribute.String(
"trace_batch_timeout", cfg.TraceBatchTimeout.String()),
attribute.String(
"trace_compressor", cfg.TraceCompressor),

// Metrics config
attribute.String(
"metric_reader_interval", cfg.MetricReaderInterval.String()),
attribute.String(
"metric_compressor", cfg.MetricCompressor),
}

return configGauge, configAttrs, nil
}

type shutdowner interface {
Shutdown(ctx context.Context) error
}
Expand Down
Loading