@@ -343,6 +343,74 @@ func newOtelResource(cfg Config) (resource *sdkresource.Resource, err error) {
343343 return
344344}
345345
346+ // RecordConfig records the beholder config as a metric.
347+ func (c * Client ) RecordConfigMetric (ctx context.Context ) error {
348+ configGauge , configAttrs , err := createConfigMetric (c .Meter , c .Config )
349+ if err != nil {
350+ return err
351+ }
352+ configGauge .Record (ctx , 1 , otelmetric .WithAttributes (configAttrs ... ))
353+ return nil
354+ }
355+
356+ // createConfigMetric creates a configuration info metric with Beholder settings as attributes.
357+ func createConfigMetric (meter otelmetric.Meter , cfg Config ) (otelmetric.Int64Gauge , []attribute.KeyValue , error ) {
358+ configGauge , err := meter .Int64Gauge (
359+ "beholder.config.info" ,
360+ otelmetric .WithDescription ("Beholder config info metric" ),
361+ otelmetric .WithUnit ("{info}" ),
362+ )
363+ if err != nil {
364+ return nil , nil , fmt .Errorf ("failed to create beholder config info metric: %w" , err )
365+ }
366+
367+ configAttrs := []attribute.KeyValue {
368+ // Logging config
369+ attribute .Bool (
370+ "log_streaming_enabled" , cfg .LogStreamingEnabled ),
371+ attribute .String (
372+ "log_level" , cfg .LogLevel .String ()),
373+ attribute .Bool (
374+ "log_batch_processor" , cfg .LogBatchProcessor ),
375+ attribute .String (
376+ "log_export_interval" , cfg .LogExportInterval .String ()),
377+ attribute .Int (
378+ "log_export_max_batch_size" , cfg .LogExportMaxBatchSize ),
379+ attribute .Int (
380+ "log_max_queue_size" , cfg .LogMaxQueueSize ),
381+ attribute .String (
382+ "log_compressor" , cfg .LogCompressor ),
383+
384+ // Message emitter config
385+ attribute .Bool (
386+ "chip_ingress_enabled" , cfg .ChipIngressEmitterEnabled ),
387+ attribute .Bool (
388+ "emitter_batch_processor" , cfg .EmitterBatchProcessor ),
389+ attribute .String (
390+ "emitter_export_interval" , cfg .EmitterExportInterval .String ()),
391+ attribute .Int (
392+ "emitter_export_max_batch_size" , cfg .EmitterExportMaxBatchSize ),
393+ attribute .Int (
394+ "emitter_max_queue_size" , cfg .EmitterMaxQueueSize ),
395+
396+ // Tracing config
397+ attribute .Float64 (
398+ "trace_sample_ratio" , cfg .TraceSampleRatio ),
399+ attribute .String (
400+ "trace_batch_timeout" , cfg .TraceBatchTimeout .String ()),
401+ attribute .String (
402+ "trace_compressor" , cfg .TraceCompressor ),
403+
404+ // Metrics config
405+ attribute .String (
406+ "metric_reader_interval" , cfg .MetricReaderInterval .String ()),
407+ attribute .String (
408+ "metric_compressor" , cfg .MetricCompressor ),
409+ }
410+
411+ return configGauge , configAttrs , nil
412+ }
413+
346414type shutdowner interface {
347415 Shutdown (ctx context.Context ) error
348416}
0 commit comments