-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from newrelic-experimental/update_gradle
Update gradle
- Loading branch information
Showing
11 changed files
with
126 additions
and
22 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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
43 changes: 43 additions & 0 deletions
43
atomikos-jms-5.0/src/main/java/com/atomikos/jms/AtomikosConnectionFactoryBean.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,43 @@ | ||
package com.atomikos.jms; | ||
|
||
import javax.jms.Connection; | ||
|
||
import com.newrelic.api.agent.weaver.NewField; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
import com.nr.instrumentation.atomikos.jms.DataSourceSampler; | ||
|
||
@Weave | ||
public abstract class AtomikosConnectionFactoryBean { | ||
|
||
public abstract String getUniqueResourceName(); | ||
|
||
public abstract int poolAvailableSize(); | ||
|
||
public abstract int poolTotalSize(); | ||
|
||
@NewField | ||
private boolean initialized = false; | ||
|
||
|
||
public Connection createConnection() { | ||
if(!initialized) { | ||
if(!DataSourceSampler.getInstance().contains(this)) { | ||
DataSourceSampler.getInstance().addPool(this); | ||
} | ||
initialized = true; | ||
} | ||
return Weaver.callOriginal(); | ||
} | ||
|
||
public AtomikosConnectionFactoryBean() { | ||
DataSourceSampler.getInstance().addPool(this); | ||
initialized = true; | ||
} | ||
|
||
|
||
public synchronized void close() { | ||
DataSourceSampler.getInstance().removePool(this); | ||
Weaver.callOriginal(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
atomikos-jms-5.0/src/main/java/com/atomikos/jms/AtomikosJmsXAConnectionFactory.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,8 @@ | ||
package com.atomikos.jms; | ||
|
||
import com.newrelic.api.agent.weaver.SkipIfPresent; | ||
|
||
@SkipIfPresent | ||
abstract class AtomikosJmsXAConnectionFactory { | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
atomikos-jms-5.0/src/main/java/com/nr/instrumentation/atomikos/jms/DataSourceSampler.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,61 @@ | ||
package com.nr.instrumentation.atomikos.jms; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import com.atomikos.jms.AtomikosConnectionFactoryBean; | ||
import com.newrelic.agent.bridge.AgentBridge; | ||
import com.newrelic.api.agent.NewRelic; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
|
||
public class DataSourceSampler implements Runnable { | ||
|
||
private static List<AtomikosConnectionFactoryBean> pools; | ||
|
||
private static String METRIC_PREFIX = "Custom/Atomikos Connection Pools/JMS/"; | ||
|
||
private static DataSourceSampler instance = null; | ||
|
||
public static DataSourceSampler getInstance() { | ||
if(instance == null) { | ||
instance = new DataSourceSampler(); | ||
} | ||
return instance; | ||
} | ||
|
||
public boolean contains(AtomikosConnectionFactoryBean b) { | ||
return pools.contains(b); | ||
} | ||
|
||
public void addPool(AtomikosConnectionFactoryBean b) { | ||
if(!pools.contains(b)) { | ||
pools.add(b); | ||
} | ||
} | ||
|
||
public boolean removePool(AtomikosConnectionFactoryBean b) { | ||
return pools.remove(b); | ||
} | ||
|
||
private DataSourceSampler() { | ||
pools = new ArrayList<AtomikosConnectionFactoryBean>(); | ||
AgentBridge.instrumentation.registerCloseable(Weaver.getImplementationTitle(),AgentBridge.privateApi.addSampler(this, 15, TimeUnit.SECONDS)); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
NewRelic.recordMetric(METRIC_PREFIX+"Pools Monitored", pools.size()); | ||
for(AtomikosConnectionFactoryBean pool : pools) { | ||
String poolName = pool.getUniqueResourceName(); | ||
int available = pool.poolAvailableSize(); | ||
int total = pool.poolTotalSize(); | ||
String metricName = METRIC_PREFIX + poolName + "/Available"; | ||
NewRelic.recordMetric(metricName, available); | ||
metricName = METRIC_PREFIX + poolName + "/Total"; | ||
NewRelic.recordMetric(metricName, total); | ||
|
||
} | ||
} | ||
|
||
} |
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,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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,5 +1,6 @@ | ||
rootProject.name = 'newrelic-java-atomikos' | ||
include 'atomikos-cp' | ||
include 'atomikos-jms' | ||
include 'atomikos-jms-3.9' | ||
include 'atomikos-jms-5.0' | ||
include 'atomikos-cp-4.0' | ||
include 'atomikos-cp-5.0' |