use of com.github.kristofa.brave.KeyValueAnnotation in project camel by apache.
the class ZipkinClientResponseAdaptor method responseAnnotations.
@Override
public Collection<KeyValueAnnotation> responseAnnotations() {
KeyValueAnnotation key1 = KeyValueAnnotation.create("camel.client.endpoint.url", url);
KeyValueAnnotation key2 = KeyValueAnnotation.create("camel.client.exchange.id", exchange.getExchangeId());
KeyValueAnnotation key3 = KeyValueAnnotation.create("camel.client.exchange.pattern", exchange.getPattern().name());
KeyValueAnnotation key4 = null;
if (eventNotifier.isIncludeMessageBody() || eventNotifier.isIncludeMessageBodyStreams()) {
boolean streams = eventNotifier.isIncludeMessageBodyStreams();
StreamCache cache = prepareBodyForLogging(exchange, streams);
String body = MessageHelper.extractBodyForLogging(exchange.hasOut() ? exchange.getOut() : exchange.getIn(), "", streams, streams);
key4 = KeyValueAnnotation.create("camel.client.exchange.message.response.body", body);
if (cache != null) {
cache.reset();
}
}
KeyValueAnnotation key5 = null;
// lets capture http response code for http based components
String responseCode = exchange.hasOut() ? exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE, String.class) : exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE, String.class);
if (responseCode != null) {
key5 = KeyValueAnnotation.create("camel.client.exchange.message.response.code", responseCode);
}
List<KeyValueAnnotation> list = new ArrayList<>();
list.add(key1);
list.add(key2);
list.add(key3);
if (key4 != null) {
list.add(key4);
}
if (key5 != null) {
list.add(key5);
}
return list;
}
use of com.github.kristofa.brave.KeyValueAnnotation in project camel by apache.
the class ZipkinServerResponseAdapter method responseAnnotations.
@Override
public Collection<KeyValueAnnotation> responseAnnotations() {
String id = exchange.getExchangeId();
String mep = exchange.getPattern().name();
KeyValueAnnotation key1 = KeyValueAnnotation.create("camel.server.endpoint.url", url);
KeyValueAnnotation key2 = KeyValueAnnotation.create("camel.server.exchange.id", id);
KeyValueAnnotation key3 = KeyValueAnnotation.create("camel.server.exchange.pattern", mep);
KeyValueAnnotation key4 = null;
if (exchange.getException() != null) {
String message = exchange.getException().getMessage();
key4 = KeyValueAnnotation.create("camel.server.exchange.failure", message);
} else if (eventNotifier.isIncludeMessageBody() || eventNotifier.isIncludeMessageBodyStreams()) {
boolean streams = eventNotifier.isIncludeMessageBodyStreams();
StreamCache cache = prepareBodyForLogging(exchange, streams);
String body = MessageHelper.extractBodyForLogging(exchange.hasOut() ? exchange.getOut() : exchange.getIn(), "", streams, streams);
key4 = KeyValueAnnotation.create("camel.server.exchange.message.response.body", body);
if (cache != null) {
cache.reset();
}
}
KeyValueAnnotation key5 = null;
// lets capture http response code for http based components
String responseCode = exchange.hasOut() ? exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE, String.class) : exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE, String.class);
if (responseCode != null) {
key5 = KeyValueAnnotation.create("camel.server.exchange.message.response.code", responseCode);
}
List<KeyValueAnnotation> list = new ArrayList<>();
list.add(key1);
list.add(key2);
list.add(key3);
if (key4 != null) {
list.add(key4);
}
if (key5 != null) {
list.add(key5);
}
return list;
}
use of com.github.kristofa.brave.KeyValueAnnotation in project camel by apache.
the class ZipkinClientRequestAdapter method requestAnnotations.
@Override
public Collection<KeyValueAnnotation> requestAnnotations() {
KeyValueAnnotation key1 = KeyValueAnnotation.create("camel.client.endpoint.url", url);
KeyValueAnnotation key2 = KeyValueAnnotation.create("camel.client.exchange.id", exchange.getExchangeId());
KeyValueAnnotation key3 = KeyValueAnnotation.create("camel.client.exchange.pattern", exchange.getPattern().name());
KeyValueAnnotation key4 = null;
if (eventNotifier.isIncludeMessageBody() || eventNotifier.isIncludeMessageBodyStreams()) {
boolean streams = eventNotifier.isIncludeMessageBodyStreams();
StreamCache cache = prepareBodyForLogging(exchange, streams);
String body = MessageHelper.extractBodyForLogging(exchange.hasOut() ? exchange.getOut() : exchange.getIn(), "", streams, streams);
key4 = KeyValueAnnotation.create("camel.client.exchange.message.request.body", body);
if (cache != null) {
cache.reset();
}
}
List<KeyValueAnnotation> list = new ArrayList<>();
list.add(key1);
list.add(key2);
list.add(key3);
if (key4 != null) {
list.add(key4);
}
return list;
}
use of com.github.kristofa.brave.KeyValueAnnotation in project camel by apache.
the class ZipkinServerRequestAdapter method requestAnnotations.
@Override
public Collection<KeyValueAnnotation> requestAnnotations() {
KeyValueAnnotation key1 = KeyValueAnnotation.create("camel.server.endpoint.url", url);
KeyValueAnnotation key2 = KeyValueAnnotation.create("camel.server.exchange.id", exchange.getExchangeId());
KeyValueAnnotation key3 = KeyValueAnnotation.create("camel.server.exchange.pattern", exchange.getPattern().name());
KeyValueAnnotation key4 = null;
if (eventNotifier.isIncludeMessageBody() || eventNotifier.isIncludeMessageBodyStreams()) {
boolean streams = eventNotifier.isIncludeMessageBodyStreams();
StreamCache cache = prepareBodyForLogging(exchange, streams);
String body = MessageHelper.extractBodyForLogging(exchange.hasOut() ? exchange.getOut() : exchange.getIn(), "", streams, streams);
key4 = KeyValueAnnotation.create("camel.server.exchange.message.request.body", body);
if (cache != null) {
cache.reset();
}
}
List<KeyValueAnnotation> list = new ArrayList<>();
list.add(key1);
list.add(key2);
list.add(key3);
if (key4 != null) {
list.add(key4);
}
return list;
}
Aggregations