From cad1e1fd6d72fabcd82f84c005c1e51d413b13cd Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Wed, 15 Apr 2020 16:08:12 -0700 Subject: [PATCH] 5.0: remove NewRelicReflector --- .../com/launchdarkly/sdk/server/LDClient.java | 1 - .../sdk/server/NewRelicReflector.java | 45 ------------------- 2 files changed, 46 deletions(-) delete mode 100644 src/main/java/com/launchdarkly/sdk/server/NewRelicReflector.java diff --git a/src/main/java/com/launchdarkly/sdk/server/LDClient.java b/src/main/java/com/launchdarkly/sdk/server/LDClient.java index 395d2ea84..4a02e333b 100644 --- a/src/main/java/com/launchdarkly/sdk/server/LDClient.java +++ b/src/main/java/com/launchdarkly/sdk/server/LDClient.java @@ -180,7 +180,6 @@ public void identify(LDUser user) { private void sendFlagRequestEvent(Event.FeatureRequest event) { eventProcessor.sendEvent(event); - NewRelicReflector.annotateTransaction(event.getKey(), String.valueOf(event.getValue())); } @Override diff --git a/src/main/java/com/launchdarkly/sdk/server/NewRelicReflector.java b/src/main/java/com/launchdarkly/sdk/server/NewRelicReflector.java deleted file mode 100644 index 62d660f14..000000000 --- a/src/main/java/com/launchdarkly/sdk/server/NewRelicReflector.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.launchdarkly.sdk.server; - -import com.google.common.base.Joiner; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.lang.reflect.Method; - -final class NewRelicReflector { - - private static Class newRelic = null; - - private static Method addCustomParameter = null; - - private static final Logger logger = LoggerFactory.getLogger(NewRelicReflector.class); - - static { - try { - newRelic = Class.forName(getNewRelicClassName()); - addCustomParameter = newRelic.getDeclaredMethod("addCustomParameter", String.class, String.class); - } catch (ClassNotFoundException | NoSuchMethodException e) { - logger.info("No NewRelic agent detected"); - } - } - - static String getNewRelicClassName() { - // This ungainly logic is a workaround for the overly aggressive behavior of the Shadow plugin, which - // will transform any class or package names passed to Class.forName() if they are string literals; - // it will even transform the string "com". - String com = Joiner.on("").join(new String[] { "c", "o", "m" }); - return Joiner.on(".").join(new String[] { com, "newrelic", "api", "agent", "NewRelic" }); - } - - static void annotateTransaction(String featureKey, String value) { - if (addCustomParameter != null) { - try { - addCustomParameter.invoke(null, featureKey, value); - } catch (Exception e) { - logger.error("Unexpected error in LaunchDarkly NewRelic integration: {}", e.toString()); - logger.debug(e.toString(), e); - } - } - } -}