Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make jar collector asynchronous #20

Merged
merged 15 commits into from
Aug 20, 2020
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
*
* * Copyright 2020 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.newrelic.agent.introspec.internal;

import com.newrelic.agent.Agent;
import com.newrelic.agent.instrumentation.context.ClassMatchVisitorFactory;
import com.newrelic.agent.logging.IAgentLogger;
import com.newrelic.agent.service.module.JarCollectorService;

public class IgnoringJarCollectorService implements JarCollectorService {
@Override
public ClassMatchVisitorFactory getSourceVisitor() {
return null;
}

@Override
public void harvest(String appName) {

}

@Override
public String getName() {
return null;
}

@Override
public void start() throws Exception {

}

@Override
public void stop() throws Exception {

}

@Override
public boolean isEnabled() {
return false;
}

@Override
public IAgentLogger getLogger() {
return Agent.LOG;
}

@Override
public boolean isStarted() {
return false;
}

@Override
public boolean isStopped() {
return false;
}

@Override
public boolean isStartedOrStarting() {
return false;
}

@Override
public boolean isStoppedOrStopping() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.newrelic.agent.profile.ProfileData;
import com.newrelic.agent.service.AbstractService;
import com.newrelic.agent.service.analytics.TransactionEvent;
import com.newrelic.agent.service.module.Jar;
import com.newrelic.agent.service.module.JarData;
import com.newrelic.agent.sql.SqlTrace;
import com.newrelic.agent.stats.StatsEngine;
import com.newrelic.agent.trace.TransactionTrace;
Expand Down Expand Up @@ -134,7 +134,7 @@ public long getConnectionTimestamp() {
}

@Override
public void sendModules(List<Jar> jarsToSend) {
public void sendModules(List<JarData> jarDataList) {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@
import com.newrelic.agent.environment.EnvironmentService;
import com.newrelic.agent.environment.EnvironmentServiceImpl;
import com.newrelic.agent.extension.ExtensionService;
import com.newrelic.agent.extension.ExtensionsLoadedListener;
import com.newrelic.agent.instrumentation.ClassTransformerService;
import com.newrelic.agent.instrumentation.PointCutClassTransformer;
import com.newrelic.agent.instrumentation.classmatchers.ClassAndMethodMatcher;
import com.newrelic.agent.instrumentation.context.ClassMatchVisitorFactory;
import com.newrelic.agent.instrumentation.context.InstrumentationContextManager;
import com.newrelic.agent.instrumentation.custom.ClassRetransformer;
import com.newrelic.agent.interfaces.ReservoirManager;
import com.newrelic.agent.interfaces.backport.Consumer;
import com.newrelic.agent.jmx.JmxService;
import com.newrelic.agent.language.SourceLanguageService;
import com.newrelic.agent.logging.IAgentLogger;
import com.newrelic.agent.model.SpanEvent;
import com.newrelic.agent.normalization.NormalizationService;
import com.newrelic.agent.normalization.NormalizationServiceImpl;
Expand All @@ -45,7 +40,6 @@
import com.newrelic.agent.service.analytics.*;
import com.newrelic.agent.service.async.AsyncTransactionService;
import com.newrelic.agent.service.module.JarCollectorService;
import com.newrelic.agent.service.module.JarCollectorServiceImpl;
import com.newrelic.agent.sql.SqlTraceService;
import com.newrelic.agent.sql.SqlTraceServiceImpl;
import com.newrelic.agent.stats.StatsService;
Expand All @@ -54,7 +48,6 @@
import com.newrelic.agent.tracing.DistributedTraceServiceImpl;
import com.newrelic.agent.utilization.UtilizationService;

import java.lang.instrument.Instrumentation;
import java.util.*;

class IntrospectorServiceManager extends AbstractService implements ServiceManager {
Expand All @@ -71,9 +64,6 @@ class IntrospectorServiceManager extends AbstractService implements ServiceManag
private volatile StatsService statsService;
private volatile HarvestService harvestService;
private volatile SqlTraceService sqlTraceService;
private volatile BrowserService browserService;
private volatile CacheService cacheService;
private volatile SamplerService samplerService;
private volatile DatabaseService dbService;
private volatile JarCollectorService jarCollectorService;
private volatile TransactionEventsService transactionEventsService;
Expand All @@ -84,7 +74,6 @@ class IntrospectorServiceManager extends AbstractService implements ServiceManag
private volatile RemoteInstrumentationService remoteInstrumentationService;
private volatile ClassTransformerService classTransformerService;
private volatile AttributesService attributesService;
private volatile UtilizationService utilizationService;
private volatile JmxService jmxService;
private volatile AsyncTransactionService asyncTxService;
private volatile CircuitBreakerService circuitBreakerService;
Expand Down Expand Up @@ -128,7 +117,7 @@ public static IntrospectorServiceManager createAndInitialize(Map<String, Object>
config.put("span_events", spanConfig);

if (configOverrides != null) {
config = deepMerge(config, configOverrides);
deepMerge(config, configOverrides);
}
manager.setup(config);
return manager;
Expand All @@ -152,104 +141,19 @@ private void setup(Map<String, Object> config) {
insightsService = new IntrospectorInsightsService();
expirationService = new ExpirationService();
dbService = new DatabaseService();
jarCollectorService = new JarCollectorServiceImpl();
jarCollectorService = new IgnoringJarCollectorService();
distributedTraceService = new DistributedTraceServiceImpl();

TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
transactionEventsService = new TransactionEventsService(transactionDataToDistributedTraceIntrinsics);

normalizationService = new NormalizationServiceImpl();
extensionService = new ExtensionService(configService);
extensionService = new ExtensionService(configService, ExtensionsLoadedListener.NOOP);
tracerService = new TracerService();
commandParser = new CommandParser();
remoteInstrumentationService = new RemoteInstrumentationServiceImpl();
sourceLanguageService = new SourceLanguageService();
classTransformerService = new ClassTransformerService() {
@Override
public void stop() {
}

@Override
public void start() {
}

@Override
public boolean isStoppedOrStopping() {
return false;
}

@Override
public boolean isStopped() {
return false;
}

@Override
public boolean isStartedOrStarting() {
return true;
}

@Override
public boolean isStarted() {
return true;
}

@Override
public boolean isEnabled() {
return true;
}

@Override
public String getName() {
return "ClassTransformer";
}

@Override
public IAgentLogger getLogger() {
return Agent.LOG;
}

@Override
public void retransformMatchingClassesImmediately(Class<?>[] loadedClasses, Collection<ClassMatchVisitorFactory> classMatchers) {
}

@Override
public void retransformMatchingClasses(Collection<ClassMatchVisitorFactory> classMatchers) {
}

@Override
public ClassRetransformer getRemoteRetransformer() {
return null;
}

@Override
public ClassRetransformer getLocalRetransformer() {
return null;
}

@Override
public Instrumentation getExtensionInstrumentation() {
return null;
}

@Override
public InstrumentationContextManager getContextManager() {
return null;
}

@Override
public PointCutClassTransformer getClassTransformer() {
return null;
}

@Override
public void checkShutdown() {
}

@Override
public boolean addTraceMatcher(ClassAndMethodMatcher matcher, String metricPrefix) {
return false;
}
};
classTransformerService = new NoOpClassTransformerService();
jmxService = new JmxService();
attributesService = new AttributesService();
circuitBreakerService = new CircuitBreakerService();
Expand Down Expand Up @@ -324,7 +228,7 @@ public HarvestService getHarvestService() {

@Override
public SamplerService getSamplerService() {
return samplerService;
return null;
}

@Override
Expand Down Expand Up @@ -432,12 +336,12 @@ public SqlTraceService getSqlTraceService() {

@Override
public BrowserService getBrowserService() {
return browserService;
return null;
}

@Override
public CacheService getCacheService() {
return cacheService;
return null;
}

@Override
Expand Down Expand Up @@ -490,7 +394,7 @@ public AsyncTransactionService getAsyncTxService() {

@Override
public UtilizationService getUtilizationService() {
return utilizationService;
return null;
}

@Override
Expand Down Expand Up @@ -521,16 +425,18 @@ private AgentConfig createAgentConfig(Map<String, Object> settings, Map<String,
}

// Override entries in original
private static Map deepMerge(Map original, Map toOverride) {
for (Object key : toOverride.keySet()) {
@SuppressWarnings("unchecked")
private static Map<String, Object> deepMerge(Map<String, Object> original, Map<String, Object> toOverride) {
for (String key : toOverride.keySet()) {
if (toOverride.get(key) instanceof Map && original.get(key) instanceof Map) {
Map originalChild = (Map) original.get(key);
Map newChild = (Map) toOverride.get(key);
Map<String, Object> originalChild = (Map<String, Object>) original.get(key);
Map<String, Object> newChild = (Map<String, Object>) toOverride.get(key);
original.put(key, deepMerge(originalChild, newChild));
} else {
original.put(key, toOverride.get(key));
}
}
return original;
}

}
Loading