Skip to content

Commit

Permalink
Add Websphere JMX config and security helper
Browse files Browse the repository at this point in the history
  • Loading branch information
amarziali committed Jul 1, 2024
1 parent 8760a06 commit d2f7c43
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dd-java-agent/agent-jmxfetch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repositories {
mavenLocal()
}
dependencies {
api('com.datadoghq:jmxfetch:0.48.0-SNAPSHOT') {
api('com.datadoghq:jmxfetch:0.49.4-SNAPSHOT') {
exclude group: 'org.slf4j', module: 'slf4j-api'
exclude group: 'org.slf4j', module: 'slf4j-jdk14'
exclude group: 'com.beust', module: 'jcommander'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class JMXFetch {

private static final Logger log = LoggerFactory.getLogger(JMXFetch.class);

public static final List<String> DEFAULT_CONFIGS =
Collections.singletonList("jmxfetch-config.yaml");
private static final String DEFAULT_CONFIG = "jmxfetch-config.yaml";
private static final String WEBSPHERE_CONFIG = "jmxfetch-websphere-config.yaml";

private static final int DELAY_BETWEEN_RUN_ATTEMPTS = 5000;

Expand Down Expand Up @@ -93,6 +93,11 @@ private static void run(final StatsDClientManager statsDClientManager, final Con
final AgentStatsdReporter reporter = new AgentStatsdReporter(statsd);

TracerFlare.addReporter(reporter);
final List<String> defaultConfigs = new ArrayList<>();
defaultConfigs.add(DEFAULT_CONFIG);
if (config.isJmxFetchIntegrationEnabled(Collections.singletonList("websphere"), false)) {
defaultConfigs.add(WEBSPHERE_CONFIG);
}

final AppConfig.AppConfigBuilder configBuilder =
AppConfig.builder()
Expand All @@ -103,7 +108,7 @@ private static void run(final StatsDClientManager statsDClientManager, final Con
.confdDirectory(jmxFetchConfigDir)
.yamlFileList(jmxFetchConfigs)
.targetDirectInstances(true)
.instanceConfigResources(DEFAULT_CONFIGS)
.instanceConfigResources(defaultConfigs)
.metricConfigResources(internalMetricsConfigs)
.metricConfigFiles(metricsConfigs)
.initialRefreshBeansPeriod(initialRefreshBeansPeriod)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
init_config:
is_jmx: true

instances:
- jvm_direct: true
mbean_server_class: com.ibm.ws.management.PlatformMBeanServer
name: dd-java-agent for websphere
collect_default_jvm_metrics: false
conf:
# The metrics are included for now. When we'll have a dedicate core integration we can
# remove that, but we'll need to keep shipping the connection factory
- include:
domain: WebSphere
type: ThreadPool
attribute:
stats.PoolSize.lowerBound:
alias: websphere.thread_pool.lower_bound
stats.PoolSize.upperBound:
alias: websphere.thread_pool.upper_bound
stats.PoolSize.highWaterMark:
alias: websphere.thread_pool.high_water_mark
stats.PoolSize.lowWaterMark:
alias: websphere.thread_pool.low_water_mark
stats.PoolSize.current:
alias: websphere.thread_pool.current
stats.ActiveCount.lowerBound:
alias: websphere.thread_pool.active.lower_bound
stats.ActiveCount.upperBound:
alias: websphere.thread_pool.active.upper_bound
stats.ActiveCount.highWaterMark:
alias: websphere.thread_pool.active.high_water_mark
stats.ActiveCount.lowWaterMark:
alias: websphere.thread_pool.active.low_water_mark
stats.ActiveCount.current:
alias: websphere.thread_pool.active.current
1 change: 1 addition & 0 deletions dd-java-agent/instrumentation/websphere-jmx/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apply from: "$rootDir/gradle/java.gradle"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package datadog.trace.instrumentation.java.lang.management;
package datadog.trace.instrumentation.websphere_jmx;

import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
Expand All @@ -7,22 +7,33 @@
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import datadog.trace.bootstrap.config.provider.ConfigProvider;
import datadog.trace.util.AgentThreadFactory;
import java.util.Collections;
import net.bytebuddy.asm.Advice;

@AutoService(InstrumenterModule.class)
public class WebsphereSecurityInstrumentation extends InstrumenterModule.Tracing
implements Instrumenter.ForSingleType {

public WebsphereSecurityInstrumentation() {
super("websphere-security");
super("websphere-jmx");
}

@Override
public String instrumentedType() {
return "com.ibm.ws.management.util.SecurityHelper";
}

@Override
public boolean isEnabled() {
return super.isEnabled()
&& "com.ibm.ws.management.PlatformMBeanServerBuilder"
.equals(System.getProperty("javax.management.builder.initial"))
&& ConfigProvider.getInstance()
.isEnabled(Collections.singletonList("websphere"), "jmxfetch.", ".enabled", false);
}

@Override
public void methodAdvice(MethodTransformer transformer) {
transformer.applyAdvice(
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ include ':dd-java-agent:instrumentation:vertx-web-3.5'
include ':dd-java-agent:instrumentation:vertx-web-3.9'
include ':dd-java-agent:instrumentation:vertx-web-4.0'
include ':dd-java-agent:instrumentation:redisson-2.0.0'
include ':dd-java-agent:instrumentation:websphere-jmx'
include ':dd-java-agent:instrumentation:zio'
include ':dd-java-agent:instrumentation:zio:zio-2.0'

Expand Down

0 comments on commit d2f7c43

Please sign in to comment.