-
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.
- Loading branch information
Showing
7 changed files
with
58 additions
and
51 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
24 changes: 11 additions & 13 deletions
24
...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 |
---|---|---|
@@ -1,25 +1,23 @@ | ||
package datadog.trace.instrumentation.jbossmodules; | ||
|
||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
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 final Function<ClassLoader, Supplier<String>> NAME_EXTRACTOR = | ||
classLoader -> { | ||
final Matcher matcher = | ||
SUBDEPLOYMENT_MATCH.matcher( | ||
((ModuleClassLoader) classLoader).getModule().getIdentifier().getName()); | ||
if (matcher.matches()) { | ||
final String result = matcher.group(1); | ||
return () -> result; | ||
} | ||
return () -> null; | ||
}; | ||
|
||
public static String extractDeploymentName(@Nonnull final ClassLoader classLoader) { | ||
final Matcher matcher = | ||
SUBDEPLOYMENT_MATCH.matcher( | ||
((ModuleClassLoader) classLoader).getModule().getIdentifier().getName()); | ||
if (matcher.matches()) { | ||
return matcher.group(1); | ||
} | ||
return null; | ||
}; | ||
} |
31 changes: 14 additions & 17 deletions
31
...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 |
---|---|---|
@@ -1,25 +1,22 @@ | ||
package datadog.trace.instrumentation.liberty20; | ||
|
||
import com.ibm.ws.classloading.internal.ThreadContextClassLoader; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
public class BundleNameHelper { | ||
private BundleNameHelper() {} | ||
|
||
public static final Function<ClassLoader, Supplier<String>> EXTRACTOR = | ||
classLoader -> { | ||
final String id = ((ThreadContextClassLoader) 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 < 0) { | ||
return () -> null; | ||
} | ||
final String name = id.substring(head + 1, tail); | ||
return () -> name; | ||
}; | ||
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('#', head); | ||
if (tail < 0) { | ||
return null; | ||
} | ||
final String name = id.substring(head + 1, tail); | ||
return null; | ||
} | ||
} |
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