use of com.newrelic.api.agent.Segment in project newrelic-java-agent by newrelic.
the class StandaloneWSRequest_Instrumentation method patch.
public CompletionStage<? extends StandaloneWSResponse> patch(BodyWritable body) {
Segment currentSegment = this.segment;
CompletionStage<? extends StandaloneWSResponse> responseFuture = Weaver.callOriginal();
responseFuture = tryRecordExternalRequest("patch", responseFuture, currentSegment);
return responseFuture;
}
use of com.newrelic.api.agent.Segment in project newrelic-java-agent by newrelic.
the class StandaloneWSRequest_Instrumentation method addCookies.
public StandaloneWSRequest_Instrumentation addCookies(WSCookie... cookies) {
Segment currentSegment = this.segment;
this.segment = null;
StandaloneWSRequest_Instrumentation result = Weaver.callOriginal();
result.segment = currentSegment;
return result;
}
use of com.newrelic.api.agent.Segment in project newrelic-java-agent by newrelic.
the class StandaloneWSRequest_Instrumentation method setAuth.
public StandaloneWSRequest_Instrumentation setAuth(String username, String password, WSAuthScheme scheme) {
Segment currentSegment = this.segment;
this.segment = null;
StandaloneWSRequest_Instrumentation result = Weaver.callOriginal();
result.segment = currentSegment;
return result;
}
use of com.newrelic.api.agent.Segment in project newrelic-java-agent by newrelic.
the class ClientFrontendPipeline_Instrumentation method apply.
@Trace(async = true)
public final void apply(final Tcp.Event event) {
if (event instanceof Http.MessageEvent && ((Http.MessageEvent) event).ev() instanceof HttpMessageEnd) {
final HttpMessageEnd httpMessageEnd = (HttpMessageEnd) ((Http.MessageEvent) event).ev();
if (this.$outer.spray$can$client$ClientFrontend$$anon$$anon$$openRequests().size() == 1) {
RequestRecord_Instrumentation requestRecord = this.$outer.spray$can$client$ClientFrontend$$anon$$anon$$openRequests().head();
HttpRequestPart request = requestRecord.request();
if (request instanceof HttpRequest_Instrumentation) {
Segment segment = ((HttpRequest_Instrumentation) request).segment;
try {
boolean isSSL = ((HttpRequest_Instrumentation) request).isSSL;
InetSocketAddress hostAndPort = ((HttpRequest_Instrumentation) request).remoteAddress;
segment.reportAsExternal(HttpParameters.library("SprayCanClient").uri(new URI((isSSL ? "https" : "http"), null, hostAndPort.getHostName(), hostAndPort.getPort(), ((HttpRequest_Instrumentation) request).uri().path().toString(), null, null)).procedure("connection").inboundHeaders(new InboundHttpHeaders((HttpResponse) httpMessageEnd)).build());
segment.end();
} catch (Exception e) {
NewRelic.getAgent().getLogger().log(Level.FINE, e, "Unable to record SprayCanClient externals");
}
}
}
}
Weaver.callOriginal();
}
use of com.newrelic.api.agent.Segment in project newrelic-java-agent by newrelic.
the class Transformation_Instrumentation method run.
@Trace(excludeFromTransactionTrace = true)
public void run() {
Segment segment = null;
boolean remove = false;
if (tokenAndRefCount != null) {
// If we are here and there is no activeToken in progress we are the first one so we set this boolean in
// order to correctly remove the "activeToken" from the thread local after the original run() method executes
remove = AgentBridge.activeToken.get() == null;
AgentBridge.activeToken.set(tokenAndRefCount);
// getTransaction implicitly makes Transaction available on Thread to runnable
Transaction tx = AgentBridge.getAgent().getTransaction(false);
if (scalaFuturesAsSegments && remove) {
if (tx != null) {
segment = tx.startSegment("Scala", "Callback");
segment.setMetricName("Scala", "Callback", ScalaUtils.nameScalaFunction(_arg.getClass().getName()));
}
}
}
try {
Weaver.callOriginal();
} finally {
if (tokenAndRefCount != null) {
if (segment != null) {
segment.end();
}
if (remove) {
AgentBridge.activeToken.remove();
}
if (tokenAndRefCount.refCount.decrementAndGet() == 0) {
tokenAndRefCount.token.expire();
tokenAndRefCount.token = null;
}
}
}
}
Aggregations