Skip to content

Commit 074363b

Browse files
authored
Merge pull request #2259 from newrelic/serverside-application-logging
Add support for server-side application logging configs
2 parents 03dee39 + 7459884 commit 074363b

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

newrelic-agent/src/main/java/com/newrelic/agent/config/AgentConfigFactory.java

+17
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ public class AgentConfigFactory {
5656
public static final String COLLECT_SPAN_EVENTS = SPAN_EVENTS_PREFIX + SpanEventsConfig.COLLECT_SPAN_EVENTS;
5757
public static final String COLLECT_CUSTOM_INSIGHTS_EVENTS = CUSTOM_INSIGHT_EVENTS_PREFIX + InsightsConfigImpl.COLLECT_CUSTOM_EVENTS;
5858
public static final String RECORD_SQL = TRANSACTION_TRACER_PREFIX + TransactionTracerConfigImpl.RECORD_SQL;
59+
public static final String APPLICATION_LOGGING_ENABLED = AgentConfigImpl.APPLICATION_LOGGING + DOT_SEPARATOR + ApplicationLoggingConfigImpl.ENABLED;
60+
public static final String APPLICATION_LOGGING_FORWARDING_ENABLED = AgentConfigImpl.APPLICATION_LOGGING + DOT_SEPARATOR +
61+
ApplicationLoggingConfigImpl.FORWARDING + DOT_SEPARATOR + ApplicationLoggingForwardingConfig.ENABLED;
62+
public static final String APPLICATION_LOGGING_FORWARDING_MAX_SAMPLES_STORED = AgentConfigImpl.APPLICATION_LOGGING + DOT_SEPARATOR +
63+
ApplicationLoggingConfigImpl.FORWARDING + DOT_SEPARATOR + ApplicationLoggingForwardingConfig.MAX_SAMPLES_STORED;
64+
public static final String APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED = AgentConfigImpl.APPLICATION_LOGGING + DOT_SEPARATOR +
65+
ApplicationLoggingConfigImpl.LOCAL_DECORATING + DOT_SEPARATOR + ApplicationLoggingForwardingConfig.ENABLED;
66+
public static final String APPLICATION_LOGGING_METRICS_ENABLED = AgentConfigImpl.APPLICATION_LOGGING + DOT_SEPARATOR +
67+
ApplicationLoggingConfigImpl.METRICS + DOT_SEPARATOR + ApplicationLoggingForwardingConfig.ENABLED;
5968
@Deprecated
6069
public static final String SLOW_QUERY_WHITELIST = TRANSACTION_TRACER_PREFIX + TransactionTracerConfigImpl.SLOW_QUERY_WHITELIST;
6170
public static final String COLLECT_SLOW_QUERIES_FROM = TRANSACTION_TRACER_PREFIX + TransactionTracerConfigImpl.COLLECT_SLOW_QUERIES_FROM;
@@ -208,6 +217,14 @@ public static void mergeServerData(Map<String, Object> settings, Map<String, Obj
208217
addServerProp(ConnectionResponse.AGENT_RUN_ID_KEY, serverData.get(ConnectionResponse.AGENT_RUN_ID_KEY), settings);
209218
addServerProp(DistributedTracingConfig.ACCOUNT_ID, serverData.get(DistributedTracingConfig.ACCOUNT_ID), settings);
210219
addServerProp("agent_home", ConfigFileHelper.getNewRelicDirectory().getAbsolutePath(), settings);
220+
221+
// Application logging
222+
addServerProp(APPLICATION_LOGGING_ENABLED, agentData.get(APPLICATION_LOGGING_ENABLED), settings);
223+
addServerProp(APPLICATION_LOGGING_FORWARDING_ENABLED, agentData.get(APPLICATION_LOGGING_FORWARDING_ENABLED), settings);
224+
addServerProp(APPLICATION_LOGGING_FORWARDING_MAX_SAMPLES_STORED, agentData.get(APPLICATION_LOGGING_FORWARDING_MAX_SAMPLES_STORED), settings);
225+
addServerProp(APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED, agentData.get(APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED), settings);
226+
addServerProp(APPLICATION_LOGGING_METRICS_ENABLED, agentData.get(APPLICATION_LOGGING_METRICS_ENABLED), settings);
227+
211228
if (AgentJarHelper.getAgentJarDirectory() != null) {
212229
addServerProp("agent_jar_location", AgentJarHelper.getAgentJarDirectory().getAbsolutePath(), settings);
213230
}

newrelic-agent/src/main/java/com/newrelic/agent/config/ApplicationLoggingConfigImpl.java

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
package com.newrelic.agent.config;
99

10+
import com.google.common.annotations.VisibleForTesting;
11+
1012
import java.util.Collections;
1113
import java.util.List;
1214
import java.util.Map;
@@ -94,6 +96,11 @@ public boolean isLocalDecoratingEnabled() {
9496
return applicationLoggingEnabled && applicationLoggingLocalDecoratingConfig.getEnabled();
9597
}
9698

99+
@VisibleForTesting
100+
public ApplicationLoggingLocalDecoratingConfig getLocalDecoratingConfig() {
101+
return applicationLoggingLocalDecoratingConfig;
102+
}
103+
97104
@Override
98105
public boolean isForwardingEnabled() {
99106
return applicationLoggingEnabled && applicationLoggingForwardingConfig.getEnabled();

newrelic-agent/src/test/java/com/newrelic/agent/config/MergeServerDataTest.java

+15
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ private Map<String, Object> createServerSideConfig() throws ParseException {
5454
" \"beacon\": \"staging-bam.nr-data.net\",\n" +
5555
" \"collect_analytics_events\": true,\n" +
5656
" \"agent_config\": {\n" +
57+
" \"application_logging.enabled\": false, \n" +
58+
" \"application_logging.forwarding.enabled\": false, \n" +
59+
" \"application_logging.forwarding.max_samples_stored\": 10001, \n" +
60+
" \"application_logging.local_decorating.enabled\": true, \n" +
61+
" \"application_logging.metrics.enabled\": false, \n" +
5762
" \"transaction_tracer.explain_enabled\": true,\n" +
5863
" \"transaction_tracer.transaction_threshold\": 0.005,\n" +
5964
" \"transaction_tracer.enabled\": true,\n" +
@@ -107,6 +112,11 @@ public void noLocalOrServerLaspEnabled() throws ParseException, ForceDisconnectE
107112
assertEquals(true, config.getAttributesConfig().isEnabledRoot());
108113
assertEquals(false, config.isCustomInstrumentationEditorAllowed());
109114
assertTrue(config.getAttributesConfig().attributesRootInclude().isEmpty());
115+
assertEquals(true, config.getApplicationLoggingConfig().isEnabled());
116+
assertEquals(true, config.getApplicationLoggingConfig().isForwardingEnabled());
117+
assertEquals(10000, config.getApplicationLoggingConfig().getMaxSamplesStored());
118+
assertEquals(false, ((ApplicationLoggingConfigImpl)config.getApplicationLoggingConfig()).getLocalDecoratingConfig().getEnabled());
119+
assertEquals(true, config.getApplicationLoggingConfig().isMetricsEnabled());
110120
}
111121

112122
@Test
@@ -139,6 +149,11 @@ public void laspDisabledServerOverridesLocal() throws ParseException {
139149
assertEquals(true, config.getAttributesConfig().isEnabledRoot());
140150
assertEquals(true, config.isCustomInstrumentationEditorAllowed());
141151
assertTrue(config.getAttributesConfig().attributesRootInclude().isEmpty());
152+
assertEquals(false, config.getApplicationLoggingConfig().isEnabled());
153+
assertEquals(false, config.getApplicationLoggingConfig().isForwardingEnabled());
154+
assertEquals(10001, config.getApplicationLoggingConfig().getMaxSamplesStored());
155+
assertEquals(true, ((ApplicationLoggingConfigImpl)config.getApplicationLoggingConfig()).getLocalDecoratingConfig().getEnabled());
156+
assertEquals(false, config.getApplicationLoggingConfig().isMetricsEnabled());
142157
}
143158

144159
@Test

0 commit comments

Comments
 (0)