File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,12 @@ func runDaemon() {
157157 logger .Warning ("Initial metrics collection failed: %v" , err )
158158 } else {
159159 logger .Debug ("Initial metrics collected successfully" )
160+ // Force immediate export so dashboard shows data right away
161+ if err := metrics .ForceFlush (); err != nil {
162+ logger .Warning ("Initial metrics flush failed: %v" , err )
163+ } else {
164+ logger .Info ("Initial metrics sent to backend" )
165+ }
160166 }
161167 }
162168
Original file line number Diff line number Diff line change @@ -450,6 +450,22 @@ func StopOTelCollector() error {
450450 return err
451451}
452452
453+ // ForceFlush forces immediate export of all pending metrics
454+ // Call this after initial metrics collection to send data immediately
455+ func ForceFlush () error {
456+ otelMu .Lock ()
457+ defer otelMu .Unlock ()
458+
459+ if ! otelStarted || meterProvider == nil {
460+ return nil
461+ }
462+
463+ ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
464+ defer cancel ()
465+
466+ return meterProvider .ForceFlush (ctx )
467+ }
468+
453469// =============================================================================
454470// OTel Metrics Registration
455471// =============================================================================
You can’t perform that action at this time.
0 commit comments