use of com.newrelic.agent.dispatchers.Dispatcher in project newrelic-java-agent by newrelic.
the class CrossProcessTransactionStateImpl method writeResponseHeaders.
@Override
public void writeResponseHeaders() {
if (tx.isIgnore()) {
return;
}
Dispatcher dispatcher = tx.getDispatcher();
if (dispatcher == null) {
return;
}
try {
Response response = dispatcher.getResponse();
long contentLength = -1;
if (response instanceof ExtendedResponse) {
contentLength = ((ExtendedResponse) response).getContentLength();
} else {
contentLength = tx.getInboundHeaderState().getRequestContentLength();
}
processOutboundResponseHeaders(response, contentLength);
} catch (Throwable e) {
Agent.LOG.log(Level.FINEST, e, "Error attempting to write response headers in transaction: {0}", tx);
}
}
use of com.newrelic.agent.dispatchers.Dispatcher in project newrelic-java-agent by newrelic.
the class BrowserTransactionStateImpl method canRenderHeaderForJsp.
private boolean canRenderHeaderForJsp() {
if (!canRenderHeader()) {
return false;
}
Dispatcher dispatcher = tx.getDispatcher();
if (dispatcher == null || !dispatcher.isWebTransaction()) {
Agent.LOG.finer("Unable to get browser timing header: transaction is not a web transaction");
return false;
}
try {
String contentType = dispatcher.getResponse().getContentType();
if (!isHtml(contentType)) {
String msg = MessageFormat.format("Unable to inject browser timing header in a JSP: bad content type: {0}", contentType);
Agent.LOG.finer(msg);
return false;
}
} catch (Exception e) {
String msg = MessageFormat.format("Unable to inject browser timing header in a JSP: exception getting content type: {0}", e);
if (Agent.LOG.isLoggable(Level.FINEST)) {
Agent.LOG.log(Level.FINEST, msg, e);
} else if (Agent.LOG.isLoggable(Level.FINER)) {
Agent.LOG.finer(msg);
}
return false;
}
return true;
}
use of com.newrelic.agent.dispatchers.Dispatcher in project newrelic-java-agent by newrelic.
the class InvocationPoint method invoke.
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
if (ignoreApdex) {
Transaction transaction = Transaction.getTransaction(false);
if (transaction != null) {
Dispatcher dispatcher = transaction.getDispatcher();
if (dispatcher != null) {
dispatcher.setIgnoreApdex(true);
if (Agent.LOG.isLoggable(Level.FINER)) {
String msg = MessageFormat.format("Set Ignore apdex to \"{0}\"", true);
Agent.LOG.log(Level.FINER, msg, new Exception());
}
}
}
}
Object t = tracerService.getTracer(tracerFactory, classMethodSignature, args[0], (Object[]) args[1]);
return t;
} catch (Throwable t) {
Agent.LOG.log(Level.FINEST, "Tracer invocation error", t);
}
return null;
}
use of com.newrelic.agent.dispatchers.Dispatcher in project newrelic-java-agent by newrelic.
the class TransactionInboundHeadersTest method testNullDispatcher.
@Test
public void testNullDispatcher() {
Transaction tx = Transaction.getTransaction();
Dispatcher dispatcher = Mockito.mock(Dispatcher.class);
Mockito.when(dispatcher.getRequest()).thenReturn(null);
tx.setDispatcher(dispatcher);
InboundHeaderState inboundHeaderState = tx.getInboundHeaderState();
Assert.assertTrue(inboundHeaderState != null);
Assert.assertNull(inboundHeaderState.getClientCrossProcessId());
Assert.assertNull(inboundHeaderState.getUnparsedSyntheticsHeader());
Assert.assertNull(inboundHeaderState.getReferrerGuid());
}
use of com.newrelic.agent.dispatchers.Dispatcher in project newrelic-java-agent by newrelic.
the class TransactionInboundHeadersTest method TestEmptyRequestHeaders.
@Test
public void TestEmptyRequestHeaders() {
Transaction tx = Transaction.getTransaction();
Dispatcher dispatcher = Mockito.mock(Dispatcher.class);
Request request = Mockito.mock(Request.class);
Mockito.when(dispatcher.getRequest()).thenReturn(request);
tx.setDispatcher(dispatcher);
InboundHeaders requestHeaders = Transaction.getRequestHeaders(tx);
// Non-null request headers should be deobfuscated.
Assert.assertEquals(requestHeaders.getClass(), DeobfuscatedInboundHeaders.class);
}
Aggregations