Skip to content

Commit

Permalink
Add supportability metric for log labels feature
Browse files Browse the repository at this point in the history
  • Loading branch information
kaylareopelle committed Nov 1, 2024
1 parent 159bd7c commit d4db438
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions lib/new_relic/agent/log_event_aggregator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class LogEventAggregator < EventAggregator
METRICS_SUPPORTABILITY_FORMAT = 'Supportability/Logging/Metrics/Ruby/%s'.freeze
FORWARDING_SUPPORTABILITY_FORMAT = 'Supportability/Logging/Forwarding/Ruby/%s'.freeze
DECORATING_SUPPORTABILITY_FORMAT = 'Supportability/Logging/LocalDecorating/Ruby/%s'.freeze
LABELS_SUPPORTABILITY_FORMAT = 'Supportability/Logging/Labels/Ruby/%s'.freeze
MAX_BYTES = 32768 # 32 * 1024 bytes (32 kibibytes)

named :LogEventAggregator
Expand All @@ -38,6 +39,7 @@ class LogEventAggregator < EventAggregator
METRICS_ENABLED_KEY = :'application_logging.metrics.enabled'
FORWARDING_ENABLED_KEY = :'application_logging.forwarding.enabled'
DECORATING_ENABLED_KEY = :'application_logging.local_decorating.enabled'
LABELS_ENABLED_KEY = :'application_logging.forwarding.labels.enabled'
LOG_LEVEL_KEY = :'application_logging.forwarding.log_level'
CUSTOM_ATTRIBUTES_KEY = :'application_logging.forwarding.custom_attributes'

Expand Down Expand Up @@ -253,6 +255,7 @@ def register_for_done_configuring(events)
record_configuration_metric(METRICS_SUPPORTABILITY_FORMAT, METRICS_ENABLED_KEY)
record_configuration_metric(FORWARDING_SUPPORTABILITY_FORMAT, FORWARDING_ENABLED_KEY)
record_configuration_metric(DECORATING_SUPPORTABILITY_FORMAT, DECORATING_ENABLED_KEY)
record_configuration_metric(LABELS_SUPPORTABILITY_FORMAT, LABELS_ENABLED_KEY)

add_custom_attributes(NewRelic::Agent.config[CUSTOM_ATTRIBUTES_KEY])
end
Expand Down
21 changes: 14 additions & 7 deletions test/new_relic/agent/log_event_aggregator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def test_records_enabled_metrics_on_startup
LogEventAggregator::OVERALL_ENABLED_KEY => true,
LogEventAggregator::METRICS_ENABLED_KEY => true,
LogEventAggregator::FORWARDING_ENABLED_KEY => true,
LogEventAggregator::DECORATING_ENABLED_KEY => true
LogEventAggregator::DECORATING_ENABLED_KEY => true,
LogEventAggregator::LABELS_ENABLED_KEY => true
) do
NewRelic::Agent.config.notify_server_source_added

Expand All @@ -61,7 +62,8 @@ def test_records_enabled_metrics_on_startup
'Supportability/Logging/Ruby/LogStasher/enabled' => {:call_count => 1},
'Supportability/Logging/Metrics/Ruby/enabled' => {:call_count => 1},
'Supportability/Logging/Forwarding/Ruby/enabled' => {:call_count => 1},
'Supportability/Logging/LocalDecorating/Ruby/enabled' => {:call_count => 1}
'Supportability/Logging/LocalDecorating/Ruby/enabled' => {:call_count => 1},
'Supportability/Logging/Labels/Ruby/enabled' => {:call_count => 1}
},
:ignore_filter => %r{^Supportability/API/})
end
Expand All @@ -72,7 +74,8 @@ def test_records_disabled_metrics_on_startup
LogEventAggregator::OVERALL_ENABLED_KEY => false,
LogEventAggregator::METRICS_ENABLED_KEY => false,
LogEventAggregator::FORWARDING_ENABLED_KEY => false,
LogEventAggregator::DECORATING_ENABLED_KEY => false
LogEventAggregator::DECORATING_ENABLED_KEY => false,
LogEventAggregator::LABELS_ENABLED_KEY => false
) do
NewRelic::Agent.config.notify_server_source_added

Expand All @@ -81,7 +84,8 @@ def test_records_disabled_metrics_on_startup
'Supportability/Logging/Ruby/LogStasher/disabled' => {:call_count => 1},
'Supportability/Logging/Metrics/Ruby/disabled' => {:call_count => 1},
'Supportability/Logging/Forwarding/Ruby/disabled' => {:call_count => 1},
'Supportability/Logging/LocalDecorating/Ruby/disabled' => {:call_count => 1}
'Supportability/Logging/LocalDecorating/Ruby/disabled' => {:call_count => 1},
'Supportability/Logging/Labels/Ruby/disabled' => {:call_count => 1}
},
:ignore_filter => %r{^Supportability/API/})
end
Expand Down Expand Up @@ -343,7 +347,8 @@ def test_high_security_mode
'Supportability/Logging/Ruby/LogStasher/enabled' => {:call_count => 1},
'Supportability/Logging/Metrics/Ruby/enabled' => {:call_count => 1},
'Supportability/Logging/Forwarding/Ruby/enabled' => {:call_count => 1},
'Supportability/Logging/LocalDecorating/Ruby/disabled' => {:call_count => 1}
'Supportability/Logging/LocalDecorating/Ruby/disabled' => {:call_count => 1},
'Supportability/Logging/Labels/Ruby/disabled' => {:call_count => 1}
},
:ignore_filter => %r{^Supportability/API/})
end
Expand All @@ -366,7 +371,8 @@ def test_overall_disabled
'Supportability/Logging/Ruby/LogStasher/disabled' => {:call_count => 1},
'Supportability/Logging/Metrics/Ruby/disabled' => {:call_count => 1},
'Supportability/Logging/Forwarding/Ruby/disabled' => {:call_count => 1},
'Supportability/Logging/LocalDecorating/Ruby/disabled' => {:call_count => 1}
'Supportability/Logging/LocalDecorating/Ruby/disabled' => {:call_count => 1},
'Supportability/Logging/Labels/Ruby/disabled' => {:call_count => 1}
},
:ignore_filter => %r{^Supportability/API/})
end
Expand All @@ -392,7 +398,8 @@ def test_overall_disabled_in_high_security_mode
'Supportability/Logging/Ruby/LogStasher/disabled' => {:call_count => 1},
'Supportability/Logging/Metrics/Ruby/disabled' => {:call_count => 1},
'Supportability/Logging/Forwarding/Ruby/disabled' => {:call_count => 1},
'Supportability/Logging/LocalDecorating/Ruby/disabled' => {:call_count => 1}
'Supportability/Logging/LocalDecorating/Ruby/disabled' => {:call_count => 1},
'Supportability/Logging/Labels/Ruby/disabled' => {:call_count => 1}
},
:ignore_filter => %r{^Supportability/API/})
end
Expand Down

0 comments on commit d4db438

Please sign in to comment.