99 "os"
1010
1111 "github.com/cobaltcore-dev/prysm/pkg/producers/opslog"
12+ "github.com/rs/zerolog"
1213 "github.com/rs/zerolog/log"
1314 "github.com/spf13/cobra"
1415)
@@ -239,13 +240,10 @@ Following this configuration change, the RadosGW will log operations to the file
239240 event .Int ("prometheus_port" , config .PrometheusPort )
240241 }
241242
242- // Debugging all tracking options from config.MetricsConfig
243- event .Bool ("track_everything" , config .MetricsConfig .TrackEverything )
244- event .Bool ("track_requests_detailed" , config .MetricsConfig .TrackRequestsDetailed )
245- event .Bool ("track_requests_per_user" , config .MetricsConfig .TrackRequestsPerUser )
246- event .Bool ("track_bytes_sent_detailed" , config .MetricsConfig .TrackBytesSentDetailed )
247- event .Bool ("track_errors_detailed" , config .MetricsConfig .TrackErrorsDetailed )
248- event .Bool ("track_latency_detailed" , config .MetricsConfig .TrackLatencyDetailed )
243+ // Enhanced debugging for tracking options
244+ debugTrackingConfig (event , config .MetricsConfig )
245+
246+ event .Msg ("OpsLog configuration initialized" )
249247
250248 event .Msg ("OpsLog configuration initialized" )
251249
@@ -259,6 +257,271 @@ Following this configuration change, the RadosGW will log operations to the file
259257 },
260258}
261259
260+ // debugTrackingConfig adds comprehensive metrics configuration to the zerolog event
261+ func debugTrackingConfig (event * zerolog.Event , config opslog.MetricsConfig ) {
262+ // Count enabled metrics for summary
263+ totalEnabled := 0
264+
265+ // Shortcut configuration
266+ event .Bool ("track_everything" , config .TrackEverything )
267+ if config .TrackEverything {
268+ event .Str ("memory_usage" , "high" ).Str ("note" , "all metrics enabled" )
269+ return // Don't add individual flags if everything is enabled
270+ }
271+
272+ // Request tracking
273+ requestMetrics := []string {}
274+ if config .TrackRequestsDetailed {
275+ requestMetrics = append (requestMetrics , "detailed" )
276+ totalEnabled ++
277+ }
278+ if config .TrackRequestsPerUser {
279+ requestMetrics = append (requestMetrics , "per-user" )
280+ totalEnabled ++
281+ }
282+ if config .TrackRequestsPerBucket {
283+ requestMetrics = append (requestMetrics , "per-bucket" )
284+ totalEnabled ++
285+ }
286+ if config .TrackRequestsPerTenant {
287+ requestMetrics = append (requestMetrics , "per-tenant" )
288+ totalEnabled ++
289+ }
290+ if len (requestMetrics ) > 0 {
291+ event .Strs ("request_tracking" , requestMetrics )
292+ }
293+
294+ // Method-based tracking
295+ methodMetrics := []string {}
296+ if config .TrackRequestsByMethodDetailed {
297+ methodMetrics = append (methodMetrics , "detailed" )
298+ totalEnabled ++
299+ }
300+ if config .TrackRequestsByMethodPerUser {
301+ methodMetrics = append (methodMetrics , "per-user" )
302+ totalEnabled ++
303+ }
304+ if config .TrackRequestsByMethodPerBucket {
305+ methodMetrics = append (methodMetrics , "per-bucket" )
306+ totalEnabled ++
307+ }
308+ if config .TrackRequestsByMethodPerTenant {
309+ methodMetrics = append (methodMetrics , "per-tenant" )
310+ totalEnabled ++
311+ }
312+ if config .TrackRequestsByMethodGlobal {
313+ methodMetrics = append (methodMetrics , "global" )
314+ totalEnabled ++
315+ }
316+ if len (methodMetrics ) > 0 {
317+ event .Strs ("method_tracking" , methodMetrics )
318+ }
319+
320+ // Operation-based tracking
321+ operationMetrics := []string {}
322+ if config .TrackRequestsByOperationDetailed {
323+ operationMetrics = append (operationMetrics , "detailed" )
324+ totalEnabled ++
325+ }
326+ if config .TrackRequestsByOperationPerUser {
327+ operationMetrics = append (operationMetrics , "per-user" )
328+ totalEnabled ++
329+ }
330+ if config .TrackRequestsByOperationPerBucket {
331+ operationMetrics = append (operationMetrics , "per-bucket" )
332+ totalEnabled ++
333+ }
334+ if config .TrackRequestsByOperationPerTenant {
335+ operationMetrics = append (operationMetrics , "per-tenant" )
336+ totalEnabled ++
337+ }
338+ if config .TrackRequestsByOperationGlobal {
339+ operationMetrics = append (operationMetrics , "global" )
340+ totalEnabled ++
341+ }
342+ if len (operationMetrics ) > 0 {
343+ event .Strs ("operation_tracking" , operationMetrics )
344+ }
345+
346+ // Status-based tracking
347+ statusMetrics := []string {}
348+ if config .TrackRequestsByStatusDetailed {
349+ statusMetrics = append (statusMetrics , "detailed" )
350+ totalEnabled ++
351+ }
352+ if config .TrackRequestsByStatusPerUser {
353+ statusMetrics = append (statusMetrics , "per-user" )
354+ totalEnabled ++
355+ }
356+ if config .TrackRequestsByStatusPerBucket {
357+ statusMetrics = append (statusMetrics , "per-bucket" )
358+ totalEnabled ++
359+ }
360+ if config .TrackRequestsByStatusPerTenant {
361+ statusMetrics = append (statusMetrics , "per-tenant" )
362+ totalEnabled ++
363+ }
364+ if len (statusMetrics ) > 0 {
365+ event .Strs ("status_tracking" , statusMetrics )
366+ }
367+
368+ // Bytes tracking
369+ bytesMetrics := []string {}
370+ if config .TrackBytesSentDetailed {
371+ bytesMetrics = append (bytesMetrics , "sent-detailed" )
372+ totalEnabled ++
373+ }
374+ if config .TrackBytesSentPerUser {
375+ bytesMetrics = append (bytesMetrics , "sent-per-user" )
376+ totalEnabled ++
377+ }
378+ if config .TrackBytesSentPerBucket {
379+ bytesMetrics = append (bytesMetrics , "sent-per-bucket" )
380+ totalEnabled ++
381+ }
382+ if config .TrackBytesSentPerTenant {
383+ bytesMetrics = append (bytesMetrics , "sent-per-tenant" )
384+ totalEnabled ++
385+ }
386+ if config .TrackBytesReceivedDetailed {
387+ bytesMetrics = append (bytesMetrics , "received-detailed" )
388+ totalEnabled ++
389+ }
390+ if config .TrackBytesReceivedPerUser {
391+ bytesMetrics = append (bytesMetrics , "received-per-user" )
392+ totalEnabled ++
393+ }
394+ if config .TrackBytesReceivedPerBucket {
395+ bytesMetrics = append (bytesMetrics , "received-per-bucket" )
396+ totalEnabled ++
397+ }
398+ if config .TrackBytesReceivedPerTenant {
399+ bytesMetrics = append (bytesMetrics , "received-per-tenant" )
400+ totalEnabled ++
401+ }
402+ if len (bytesMetrics ) > 0 {
403+ event .Strs ("bytes_tracking" , bytesMetrics )
404+ }
405+
406+ // Error tracking
407+ errorMetrics := []string {}
408+ if config .TrackErrorsDetailed {
409+ errorMetrics = append (errorMetrics , "detailed" )
410+ totalEnabled ++
411+ }
412+ if config .TrackErrorsPerUser {
413+ errorMetrics = append (errorMetrics , "per-user" )
414+ totalEnabled ++
415+ }
416+ if config .TrackErrorsPerBucket {
417+ errorMetrics = append (errorMetrics , "per-bucket" )
418+ totalEnabled ++
419+ }
420+ if config .TrackErrorsPerTenant {
421+ errorMetrics = append (errorMetrics , "per-tenant" )
422+ totalEnabled ++
423+ }
424+ if config .TrackErrorsPerStatus {
425+ errorMetrics = append (errorMetrics , "per-status" )
426+ totalEnabled ++
427+ }
428+ if config .TrackErrorsByIP {
429+ errorMetrics = append (errorMetrics , "by-ip" )
430+ totalEnabled ++
431+ }
432+ if len (errorMetrics ) > 0 {
433+ event .Strs ("error_tracking" , errorMetrics )
434+ }
435+
436+ // IP-based tracking
437+ ipMetrics := []string {}
438+ if config .TrackRequestsByIPDetailed {
439+ ipMetrics = append (ipMetrics , "requests-detailed" )
440+ totalEnabled ++
441+ }
442+ if config .TrackRequestsByIPPerTenant {
443+ ipMetrics = append (ipMetrics , "requests-per-tenant" )
444+ totalEnabled ++
445+ }
446+ if config .TrackRequestsByIPBucketMethodTenant {
447+ ipMetrics = append (ipMetrics , "requests-bucket-method-tenant" )
448+ totalEnabled ++
449+ }
450+ if config .TrackRequestsByIPGlobalPerTenant {
451+ ipMetrics = append (ipMetrics , "requests-global-per-tenant" )
452+ totalEnabled ++
453+ }
454+ if config .TrackBytesSentByIPDetailed {
455+ ipMetrics = append (ipMetrics , "bytes-sent-detailed" )
456+ totalEnabled ++
457+ }
458+ if config .TrackBytesSentByIPPerTenant {
459+ ipMetrics = append (ipMetrics , "bytes-sent-per-tenant" )
460+ totalEnabled ++
461+ }
462+ if config .TrackBytesSentByIPGlobalPerTenant {
463+ ipMetrics = append (ipMetrics , "bytes-sent-global-per-tenant" )
464+ totalEnabled ++
465+ }
466+ if config .TrackBytesReceivedByIPDetailed {
467+ ipMetrics = append (ipMetrics , "bytes-received-detailed" )
468+ totalEnabled ++
469+ }
470+ if config .TrackBytesReceivedByIPPerTenant {
471+ ipMetrics = append (ipMetrics , "bytes-received-per-tenant" )
472+ totalEnabled ++
473+ }
474+ if config .TrackBytesReceivedByIPGlobalPerTenant {
475+ ipMetrics = append (ipMetrics , "bytes-received-global-per-tenant" )
476+ totalEnabled ++
477+ }
478+ if len (ipMetrics ) > 0 {
479+ event .Strs ("ip_tracking" , ipMetrics )
480+ }
481+
482+ // Latency tracking (uses histograms, not storage maps)
483+ latencyMetrics := []string {}
484+ if config .TrackLatencyDetailed {
485+ latencyMetrics = append (latencyMetrics , "detailed" )
486+ totalEnabled ++
487+ }
488+ if config .TrackLatencyPerUser {
489+ latencyMetrics = append (latencyMetrics , "per-user" )
490+ totalEnabled ++
491+ }
492+ if config .TrackLatencyPerBucket {
493+ latencyMetrics = append (latencyMetrics , "per-bucket" )
494+ totalEnabled ++
495+ }
496+ if config .TrackLatencyPerTenant {
497+ latencyMetrics = append (latencyMetrics , "per-tenant" )
498+ totalEnabled ++
499+ }
500+ if config .TrackLatencyPerMethod {
501+ latencyMetrics = append (latencyMetrics , "per-method" )
502+ totalEnabled ++
503+ }
504+ if config .TrackLatencyPerBucketAndMethod {
505+ latencyMetrics = append (latencyMetrics , "per-bucket-and-method" )
506+ totalEnabled ++
507+ }
508+ if len (latencyMetrics ) > 0 {
509+ event .Strs ("latency_tracking" , latencyMetrics )
510+ }
511+
512+ // Summary information
513+ event .Int ("total_enabled_metrics" , totalEnabled )
514+
515+ // Memory efficiency classification
516+ if totalEnabled == 0 {
517+ event .Str ("memory_usage" , "minimal" ).Str ("note" , "only basic counters" )
518+ } else if totalEnabled > 30 {
519+ event .Str ("memory_usage" , "high" ).Str ("note" , "consider reducing in production" )
520+ } else {
521+ event .Str ("memory_usage" , "efficient" ).Str ("architecture" , "dedicated storage" )
522+ }
523+ }
524+
262525func mergeOpsLogConfigWithEnv (cfg opslog.OpsLogConfig ) opslog.OpsLogConfig {
263526 cfg .LogFilePath = getEnv ("LOG_FILE_PATH" , cfg .LogFilePath )
264527 cfg .TruncateLogOnStart = getEnvBool ("TRUNCATE_LOG_ON_START" , cfg .TruncateLogOnStart )
@@ -446,4 +709,51 @@ func validateOpsLogConfig(config opslog.OpsLogConfig) {
446709 fmt .Println ("One or more required parameters are missing. Please provide them through flags or environment variables." )
447710 os .Exit (1 )
448711 }
712+
713+ // Performance warnings
714+ if config .MetricsConfig .TrackEverything {
715+ log .Warn ().Msg ("Performance Warning: --track-everything enables all metrics. Monitor memory usage in production." )
716+ }
717+
718+ // Count enabled detailed metrics (highest memory usage)
719+ detailedCount := 0
720+ if config .MetricsConfig .TrackRequestsDetailed {
721+ detailedCount ++
722+ }
723+ if config .MetricsConfig .TrackRequestsByMethodDetailed {
724+ detailedCount ++
725+ }
726+ if config .MetricsConfig .TrackRequestsByOperationDetailed {
727+ detailedCount ++
728+ }
729+ if config .MetricsConfig .TrackRequestsByStatusDetailed {
730+ detailedCount ++
731+ }
732+ if config .MetricsConfig .TrackBytesSentDetailed {
733+ detailedCount ++
734+ }
735+ if config .MetricsConfig .TrackBytesReceivedDetailed {
736+ detailedCount ++
737+ }
738+ if config .MetricsConfig .TrackErrorsDetailed {
739+ detailedCount ++
740+ }
741+ if config .MetricsConfig .TrackRequestsByIPDetailed {
742+ detailedCount ++
743+ }
744+ if config .MetricsConfig .TrackBytesSentByIPDetailed {
745+ detailedCount ++
746+ }
747+ if config .MetricsConfig .TrackBytesReceivedByIPDetailed {
748+ detailedCount ++
749+ }
750+
751+ if detailedCount > 5 {
752+ log .Warn ().Int ("detailed_metrics" , detailedCount ).Msg ("Many detailed metrics enabled - these have highest memory usage" )
753+ }
754+
755+ // Interval warning for high-frequency environments
756+ if config .PrometheusIntervalSeconds < 30 && config .MetricsConfig .TrackEverything {
757+ log .Warn ().Int ("interval_seconds" , config .PrometheusIntervalSeconds ).Msg ("Short interval with comprehensive tracking may impact performance" )
758+ }
449759}
0 commit comments