-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Service naming: split by jee deployment (#8064)
* Service naming: split by jee deployment * Do not use invokedynamic * fix tests * collapse enter and local * Adjust service name for non legacy tracing * Add wildfly ejb test * limit max java verson to 11 for wildfly 15 * renaming * refactor according to the review * remove helper * avoid casting * review
- Loading branch information
Showing
35 changed files
with
529 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...ss-modules/src/main/java/datadog/trace/instrumentation/jbossmodules/ModuleNameHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package datadog.trace.instrumentation.jbossmodules; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
import javax.annotation.Nonnull; | ||
import org.jboss.modules.ModuleClassLoader; | ||
|
||
public class ModuleNameHelper { | ||
private ModuleNameHelper() {} | ||
|
||
private static final Pattern SUBDEPLOYMENT_MATCH = | ||
Pattern.compile("deployment(?>.+\\.ear)?\\.(.+)\\.[j|w]ar"); | ||
|
||
public static String extractDeploymentName(@Nonnull final ModuleClassLoader classLoader) { | ||
final Matcher matcher = | ||
SUBDEPLOYMENT_MATCH.matcher(classLoader.getModule().getIdentifier().getName()); | ||
if (matcher.matches()) { | ||
return matcher.group(1); | ||
} | ||
return null; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...on/liberty-20/src/main/java/datadog/trace/instrumentation/liberty20/BundleNameHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package datadog.trace.instrumentation.liberty20; | ||
|
||
import com.ibm.ws.classloading.internal.ThreadContextClassLoader; | ||
|
||
public class BundleNameHelper { | ||
private BundleNameHelper() {} | ||
|
||
public static String extractDeploymentName(final ThreadContextClassLoader classLoader) { | ||
final String id = classLoader.getKey(); | ||
// id is something like <type>:name#somethingelse | ||
final int head = id.indexOf(':'); | ||
if (head < 0) { | ||
return null; | ||
} | ||
final int tail = id.lastIndexOf('#'); | ||
if (tail <= head) { | ||
return null; | ||
} | ||
return id.substring(head + 1, tail); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...java/datadog/trace/instrumentation/liberty20/ThreadContextClassloaderInstrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package datadog.trace.instrumentation.liberty20; | ||
|
||
import static net.bytebuddy.matcher.ElementMatchers.isConstructor; | ||
|
||
import com.google.auto.service.AutoService; | ||
import com.ibm.ws.classloading.internal.ThreadContextClassLoader; | ||
import datadog.trace.agent.tooling.Instrumenter; | ||
import datadog.trace.agent.tooling.InstrumenterModule; | ||
import datadog.trace.api.naming.ClassloaderServiceNames; | ||
import net.bytebuddy.asm.Advice; | ||
|
||
@AutoService(InstrumenterModule.class) | ||
public class ThreadContextClassloaderInstrumentation extends InstrumenterModule.Tracing | ||
implements Instrumenter.ForSingleType { | ||
|
||
public ThreadContextClassloaderInstrumentation() { | ||
super("liberty", "liberty-classloading"); | ||
} | ||
|
||
@Override | ||
public String instrumentedType() { | ||
return "com.ibm.ws.classloading.internal.ThreadContextClassLoader"; | ||
} | ||
|
||
@Override | ||
public String[] helperClassNames() { | ||
return new String[] { | ||
packageName + ".BundleNameHelper", | ||
}; | ||
} | ||
|
||
@Override | ||
public void methodAdvice(MethodTransformer transformer) { | ||
transformer.applyAdvice( | ||
isConstructor(), getClass().getName() + "$ThreadContextClassloaderAdvice"); | ||
} | ||
|
||
public static class ThreadContextClassloaderAdvice { | ||
@Advice.OnMethodExit(suppress = Throwable.class) | ||
public static void afterConstruct(@Advice.This ThreadContextClassLoader self) { | ||
final String name = BundleNameHelper.extractDeploymentName(self); | ||
if (name != null && !name.isEmpty()) { | ||
ClassloaderServiceNames.addServiceName(self, name); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.