Skip to content

Commit c436abb

Browse files
committed
Revert "Making sure that Transaction Log reservoir is no bigger than it needs (#1728)"
This reverts commit ec31620.
1 parent d49c2ca commit c436abb

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

instrumentation-test/src/main/java/com/newrelic/agent/introspec/internal/IntrospectorLogSenderService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void recordLogEvent(Map<LogAttributeKey, ?> attributes) {
8787
}
8888

8989
@Override
90-
public Logs getTransactionLogs() {
90+
public Logs getTransactionLogs(AgentConfig config) {
9191
return this;
9292
}
9393

newrelic-agent/src/main/java/com/newrelic/agent/Transaction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,8 @@ public Insights getInsightsData() {
620620
public Logs getLogEventData() {
621621
Logs logEventData = logEvents.get();
622622
if (logEventData == null) {
623-
logEvents.compareAndSet(null, ServiceFactory.getServiceManager().getLogSenderService().getTransactionLogs());
623+
AgentConfig defaultConfig = ServiceFactory.getConfigService().getDefaultAgentConfig();
624+
logEvents.compareAndSet(null, ServiceFactory.getServiceManager().getLogSenderService().getTransactionLogs(defaultConfig));
624625
logEventData = logEvents.get();
625626
}
626627
return logEventData;

newrelic-agent/src/main/java/com/newrelic/agent/service/logging/LogSenderService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public interface LogSenderService extends EventService, Logs {
2424
* Returns an insights instance used to track events created during a transaction. The events will be reported to
2525
* the Transaction's application, or to the default application if not in a transaction.
2626
*/
27-
Logs getTransactionLogs();
27+
Logs getTransactionLogs(AgentConfig config);
2828

2929
/**
3030
* Store event into Reservoir following usual sampling using the given appName. Preference should be given to

newrelic-agent/src/main/java/com/newrelic/agent/service/logging/LogSenderServiceImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ protected Map<String, Object> getAttributeMap() {
578578
}
579579

580580
@Override
581-
public Logs getTransactionLogs() {
582-
return new TransactionLogs(maxSamplesStored, contextDataKeyFilter);
581+
public Logs getTransactionLogs(AgentConfig config) {
582+
return new TransactionLogs(config, contextDataKeyFilter);
583583
}
584584

585585
/**
@@ -589,7 +589,8 @@ public static final class TransactionLogs implements Logs {
589589
private final LinkedBlockingQueue<LogEvent> events;
590590
private final ExcludeIncludeFilter contextDataKeyFilter;
591591

592-
TransactionLogs(int maxSamplesStored, ExcludeIncludeFilter contextDataKeyFilter) {
592+
TransactionLogs(AgentConfig config, ExcludeIncludeFilter contextDataKeyFilter) {
593+
int maxSamplesStored = config.getApplicationLoggingConfig().getMaxSamplesStored();
593594
events = new LinkedBlockingQueue<>(maxSamplesStored);
594595
this.contextDataKeyFilter = contextDataKeyFilter;
595596
}

newrelic-agent/src/test/java/com/newrelic/agent/service/logging/LogSenderServiceImplTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public class LogSenderServiceImplTest {
4040
private static final HarvestService harvestService = Mockito.mock(HarvestService.class);
4141
private static final TransactionService txService = Mockito.mock(TransactionService.class);
4242
private static final StatsService statsService = Mockito.mock(StatsService.class);
43-
private static final int LOG_FORWARDING_MAX_SAMPLES_STORED = 100; // should be enough for testing
4443

4544
private static LogSenderServiceImpl createService() throws Exception {
4645
return createService(createConfig());
@@ -90,7 +89,7 @@ public void testHighSecurity() throws Exception {
9089
when(ServiceFactory.getTransactionService().getTransaction(false)).thenReturn(transaction);
9190

9291
LogSenderServiceImpl.TransactionLogs logs = new LogSenderServiceImpl.TransactionLogs(
93-
LOG_FORWARDING_MAX_SAMPLES_STORED, allowAllFilter());
92+
AgentConfigImpl.createAgentConfig(Collections.emptyMap()), allowAllFilter());
9493
when(transaction.getLogEventData()).thenReturn(logs);
9594
when(transaction.getApplicationName()).thenReturn(appName);
9695
when(transaction.isInProgress()).thenReturn(true);
@@ -146,7 +145,7 @@ public void testWithTransaction() throws Exception {
146145
when(ServiceFactory.getTransactionService().getTransaction(false)).thenReturn(transaction);
147146

148147
LogSenderServiceImpl.TransactionLogs logs = new LogSenderServiceImpl.TransactionLogs(
149-
LOG_FORWARDING_MAX_SAMPLES_STORED, allowAllFilter());
148+
AgentConfigImpl.createAgentConfig(Collections.emptyMap()), allowAllFilter());
150149
when(transaction.getLogEventData()).thenReturn(logs);
151150
when(transaction.getApplicationName()).thenReturn(appName);
152151
when(transaction.isInProgress()).thenReturn(true);
@@ -174,7 +173,7 @@ public void testTransactionHarvest() throws Exception {
174173
when(ServiceFactory.getTransactionService().getTransaction(false)).thenReturn(transaction);
175174

176175
LogSenderServiceImpl.TransactionLogs logs = new LogSenderServiceImpl.TransactionLogs(
177-
LOG_FORWARDING_MAX_SAMPLES_STORED, allowAllFilter());
176+
AgentConfigImpl.createAgentConfig(Collections.emptyMap()), allowAllFilter());
178177
when(transaction.getLogEventData()).thenReturn(logs);
179178
when(transaction.getApplicationName()).thenReturn(appName);
180179
when(transaction.isInProgress()).thenReturn(true);

0 commit comments

Comments
 (0)