Search in sources :

Example 1 with KeyValueAnnotation

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;
}
Also used : StreamCache(org.apache.camel.StreamCache) KeyValueAnnotation(com.github.kristofa.brave.KeyValueAnnotation) ArrayList(java.util.ArrayList)

Example 2 with KeyValueAnnotation

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;
}
Also used : StreamCache(org.apache.camel.StreamCache) KeyValueAnnotation(com.github.kristofa.brave.KeyValueAnnotation) ArrayList(java.util.ArrayList)

Example 3 with KeyValueAnnotation

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;
}
Also used : StreamCache(org.apache.camel.StreamCache) KeyValueAnnotation(com.github.kristofa.brave.KeyValueAnnotation) ArrayList(java.util.ArrayList)

Example 4 with KeyValueAnnotation

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;
}
Also used : StreamCache(org.apache.camel.StreamCache) KeyValueAnnotation(com.github.kristofa.brave.KeyValueAnnotation) ArrayList(java.util.ArrayList)

Aggregations

KeyValueAnnotation (com.github.kristofa.brave.KeyValueAnnotation)4 ArrayList (java.util.ArrayList)4 StreamCache (org.apache.camel.StreamCache)4