Skip to content

Commit

Permalink
added
Browse files Browse the repository at this point in the history
  • Loading branch information
dhilpipre committed Jan 15, 2025
1 parent c96a578 commit f1fa2c0
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 0 deletions.
33 changes: 33 additions & 0 deletions fabric-runtime/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

// Build.gradle generated for instrumentation module fabric-runtime

apply plugin: 'java'

dependencies {
implementation 'javax.servlet:servlet-api:2.5'
compileOnly group: 'javax', name: 'javaee-api', version: '6.0'

// New Relic Java Agent dependencies
implementation 'com.newrelic.agent.java:newrelic-agent:6.4.0'
implementation 'com.newrelic.agent.java:newrelic-api:6.4.0'
implementation fileTree(include: ['*.jar'], dir: '../libs')
implementation fileTree(include: ['*.jar'], dir: 'lib')
implementation fileTree(include: ['*.jar'], dir: '../test-lib')
}

jar {
manifest {
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.fabric-runtime'
attributes 'Implementation-Vendor': 'New Relic Labs'
attributes 'Implementation-Vendor-Id': 'com.newrelic.labs'
attributes 'Implementation-Version': 1.0
}
}

verifyInstrumentation {
// Verifier plugin documentation:
// https://github.com/newrelic/newrelic-gradle-verify-instrumentation
// Example:
// passes 'javax.servlet:servlet-api:[2.2,2.5]'
// exclude 'javax.servlet:servlet-api:2.4.public_draft'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.newrelic.instrumentation.labs.fabric.runtime;

public class FabricPathInfo {

private String dn;
private String serviceName;

public FabricPathInfo(String dn, String serviceName) {
super();
this.dn = dn;
this.serviceName = serviceName;
}

public String getDn() {
return dn;
}

public String getServiceName() {
return serviceName;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.newrelic.instrumentation.labs.fabric.runtime;

import oracle.integration.platform.blocks.PathInfo;
import oracle.integration.platform.blocks.soap.WebServiceEntryBindingComponent;

public class FabricRuntimeUtils {


public static FabricPathInfo getServiceName(String pathInfo, WebServiceEntryBindingComponent wsEntryBC) {
if(pathInfo == null || pathInfo.isEmpty()) return null;

String temp = pathInfo.startsWith("/") ? pathInfo.substring(1) : pathInfo;
String[] path = temp.split("/");
if(path.length == 0) return null;

if(path.length == 1) {
PathInfo info = wsEntryBC.getCustomPath(pathInfo);
if(info != null) {
return new FabricPathInfo(info.getCompositeName(), info.getService());
}
} else {
String dn = path[0] + '/' + path[1];
String serviceName = path.length == 3 ? path[2] : null;
return new FabricPathInfo(dn, serviceName);
}



return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package oracle.integration.platform.blocks.mesh;


import com.newrelic.api.agent.NewRelic;
import com.newrelic.api.agent.Trace;
import com.newrelic.api.agent.weaver.Weave;
import com.newrelic.api.agent.weaver.Weaver;

import oracle.fabric.common.InvocationContext;
import oracle.fabric.common.NormalizedMessage;
import oracle.fabric.common.Operation;

@Weave
public class MeshImpl {

@Trace
public NormalizedMessage request(NormalizedMessage message, Operation operation, InvocationContext context) {
if(operation != null) {
String opName = operation.getName();
if(opName != null) {
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Fabric","Mesh","request",opName);
}
}
return Weaver.callOriginal();
}

@Trace
public void post(NormalizedMessage message, Operation operation, InvocationContext context) {
if(operation != null) {
String opName = operation.getName();
if(opName != null) {
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Fabric","Mesh","post",opName);
}
}
Weaver.callOriginal();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package oracle.integration.platform.blocks.mesh;

import com.newrelic.api.agent.NewRelic;
import com.newrelic.api.agent.Trace;
import com.newrelic.api.agent.weaver.MatchType;
import com.newrelic.api.agent.weaver.Weave;
import com.newrelic.api.agent.weaver.Weaver;

import oracle.fabric.common.InvocationContext;
import oracle.fabric.common.NormalizedMessage;
import oracle.fabric.common.Operation;

@Weave(type = MatchType.Interface)
public abstract class MessageHandler {

@Trace
public NormalizedMessage doCallbackRequest(NormalizedMessage var1, Operation var2, InvocationContext var3) {
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Fabric","MessageHandler",getClass().getSimpleName(),"doCallbackRequest");
return Weaver.callOriginal();
}

@Trace
public NormalizedMessage doRequest(NormalizedMessage var1, Operation var2, InvocationContext var3) {
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Fabric","MessageHandler",getClass().getSimpleName(),"doRequest");
return Weaver.callOriginal();
}

@Trace
public void doCallbackPost(NormalizedMessage var1, Operation var2, InvocationContext var3) {
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Fabric","MessageHandler",getClass().getSimpleName(),"doCallbackPost");
Weaver.callOriginal();
}

@Trace
public void doPost(NormalizedMessage var1, Operation var2, InvocationContext var3) {
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Fabric","MessageHandler",getClass().getSimpleName(),"doPost");
Weaver.callOriginal();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package oracle.integration.platform.blocks.mesh;

import com.newrelic.api.agent.NewRelic;
import com.newrelic.api.agent.Trace;
import com.newrelic.api.agent.weaver.Weave;
import com.newrelic.api.agent.weaver.Weaver;

import oracle.fabric.common.InvocationContext;
import oracle.fabric.common.NormalizedMessage;
import oracle.fabric.common.Operation;

@Weave
public abstract class MessageRouter {

@Trace
public NormalizedMessage request(NormalizedMessage message, Operation operation, InvocationContext context) {
if(operation != null) {
String opName = operation.getName();
if(opName != null) {
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Fabric","MessageRouter","request",opName);
}
}
return Weaver.callOriginal();
}

public void post(NormalizedMessage message, Operation operation, InvocationContext context) {
if(operation != null) {
String opName = operation.getName();
if(opName != null) {
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Fabric","MessageRouter","post",opName);
}
}
Weaver.callOriginal();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package oracle.integration.platform.blocks.soap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.newrelic.api.agent.NewRelic;
import com.newrelic.api.agent.Trace;
import com.newrelic.api.agent.TransactionNamePriority;
import com.newrelic.api.agent.weaver.Weave;
import com.newrelic.api.agent.weaver.Weaver;
import com.newrelic.instrumentation.labs.fabric.runtime.FabricPathInfo;
import com.newrelic.instrumentation.labs.fabric.runtime.FabricRuntimeUtils;

@Weave
public abstract class FabricProviderServlet {

protected WebServiceEntryBindingComponent wsEntryBC = Weaver.callOriginal();

@Trace
protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
Weaver.callOriginal();
}

@Trace
protected void doPost(HttpServletRequest request, HttpServletResponse response) {
String pInfo = request.getPathInfo();
if(pInfo != null) {
FabricPathInfo fInfo = FabricRuntimeUtils.getServiceName(pInfo, wsEntryBC);
if(fInfo != null) {
String tName = fInfo.getServiceName() != null ? fInfo.getDn() + "/" + fInfo.getServiceName() : fInfo.getDn() + "/Unknown";
NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.FRAMEWORK_HIGH, false, "Fabric", tName);
}
}
Weaver.callOriginal();
}
}

0 comments on commit f1fa2c0

Please sign in to comment.