use of com.newrelic.api.agent.InboundHeaders in project newrelic-java-agent by newrelic.
the class TransactionInboundHeadersTest method testEmptyInstrumentationProvidedHeaders.
@Test
public void testEmptyInstrumentationProvidedHeaders() {
Transaction tx = Transaction.getTransaction();
InboundHeaders headers = createEmptyHTTPInboundHeaders();
tx.provideHeaders(headers);
InboundHeaderState inboundHeaderState = tx.getInboundHeaderState();
Assert.assertTrue(inboundHeaderState != null);
Assert.assertNull(inboundHeaderState.getClientCrossProcessId());
Assert.assertNull(inboundHeaderState.getUnparsedSyntheticsHeader());
Assert.assertNull(inboundHeaderState.getReferrerGuid());
}
use of com.newrelic.api.agent.InboundHeaders in project newrelic-java-agent by newrelic.
the class CrossProcessTransactionStateImpl method processResponseMetadata.
@Override
public void processResponseMetadata(String responseMetadata, URI uri) {
if (tx.getAgentConfig().getDistributedTracingConfig().isEnabled()) {
Agent.LOG.log(Level.FINEST, "Distributed tracing is enabled. Ignoring processResponseMetadata call.");
return;
}
if (!tx.getCrossProcessConfig().isCrossApplicationTracing()) {
return;
}
if (responseMetadata == null) {
return;
}
Tracer lastTracer = tx.getTransactionActivity().getLastTracer();
if (lastTracer == null) {
return;
}
InboundHeaders NRHeaders = decodeMetadata(responseMetadata);
if (NRHeaders != null) {
/*
One of our public APIs doesn't have a URI parameter, so we may not know the host or URI.
See {@link com.newrelic.api.agent.Transaction#processResponseMetadata(String)}
*/
String host = (uri == null || uri.getHost() == null) ? UNKNOWN_HOST : uri.getHost();
String uriString = (uri == null) ? null : uri.toString();
String decodedAppData = HeadersUtil.getAppDataHeader(NRHeaders);
CrossProcessNameFormat crossProcessFormat = CrossProcessNameFormat.create(host, uriString, decodedAppData);
doProcessInboundResponseHeaders(lastTracer, crossProcessFormat, host, true);
MetricNames.recordApiSupportabilityMetric(MetricNames.SUPPORTABILITY_API_PROCESS_RESPONSE_METADATA);
}
}
use of com.newrelic.api.agent.InboundHeaders in project newrelic-java-agent by newrelic.
the class CrossProcessTransactionStateImpl method processRequestMetadata.
@Override
public void processRequestMetadata(String requestMetadata) {
if (tx.getAgentConfig().getDistributedTracingConfig().isEnabled()) {
Agent.LOG.log(Level.FINEST, "Distributed tracing is enabled. Ignoring processRequestMetadata call.");
return;
}
InboundHeaders headers = decodeMetadata(requestMetadata);
Transaction currentTxn = Transaction.getTransaction(false);
if (currentTxn != null) {
currentTxn.provideRawHeaders(headers);
}
MetricNames.recordApiSupportabilityMetric(MetricNames.SUPPORTABILITY_API_PROCESS_REQUEST_METADATA);
}
use of com.newrelic.api.agent.InboundHeaders in project newrelic-java-agent by newrelic.
the class DefaultTracer method reportAsExternal.
@Override
public void reportAsExternal(ExternalParameters externalParameters) {
if (Agent.LOG.isFineEnabled()) {
Agent.LOG.log(Level.FINE, "Setting externalParameters to: " + externalParameters);
}
MetricNames.recordApiSupportabilityMetric(MetricNames.SUPPORTABILITY_API_REPORT_AS_EXTERNAL);
this.externalParameters = externalParameters;
if (this.externalParameters instanceof HttpParameters) {
// URI validity check and logging
HttpParameters httpParameters = (HttpParameters) this.externalParameters;
URI uri = httpParameters.getUri();
if (uri == null || uri.getScheme() == null || uri.getHost() == null || uri.getPort() == -1) {
Agent.LOG.log(Level.FINE, "URI parameter passed to HttpParameters should include a valid scheme, host, and port.");
}
InboundHeaders headers = httpParameters.getInboundResponseHeaders();
if (null != headers) {
readInboundResponseHeaders(headers);
}
} else if (this.externalParameters instanceof MessageProduceParameters) {
catForMessaging(((MessageProduceParameters) this.externalParameters));
} else if (this.externalParameters instanceof MessageConsumeParameters) {
catForMessaging(((MessageConsumeParameters) this.externalParameters));
}
}
use of com.newrelic.api.agent.InboundHeaders in project newrelic-java-agent by newrelic.
the class DefaultTracer method catForMessaging.
private void catForMessaging(MessageConsumeParameters consumeParameters) {
InboundHeaders headers = consumeParameters.getInboundHeaders();
if (headers == null) {
return;
}
// In amqp we don't know if we're sending a request or a response.
DestinationType destinationType = consumeParameters.getDestinationType();
if (destinationType == DestinationType.EXCHANGE) {
getTransaction().provideHeaders(headers);
} else // 2. Consuming a message from a temporary queue, it is processing a response (inbound response).
if (destinationType == DestinationType.NAMED_QUEUE || destinationType == DestinationType.NAMED_TOPIC) {
getTransaction().provideHeaders(headers);
} else if (destinationType == DestinationType.TEMP_QUEUE || destinationType == DestinationType.TEMP_TOPIC) {
// Do not replace with recordInboundResponseHeaders.
// recordInboundResponseHeaders assumes we do CAT request/response in the same tracer.
Transaction transaction = getTransactionActivity().getTransaction();
transaction.getCrossProcessState().processInboundResponseHeaders(headers, this, "Unknown", null, true);
} else {
Agent.LOG.log(Level.FINE, "Unexpected destination type when reporting external metrics for message consume.");
}
}
Aggregations