Example usage for com.amazonaws Request addHandlerContext

List of usage examples for com.amazonaws Request addHandlerContext

Introduction

In this page you can find the example usage for com.amazonaws Request addHandlerContext.

Prototype

<X> void addHandlerContext(HandlerContextKey<X> key, X value);

Source Link

Document

Adds a context to that is visible to all com.amazonaws.handlers.RequestHandler2 s.

Usage

From source file:io.opentracing.contrib.aws.TracingRequestHandler.java

License:Apache License

/**
 * {@inheritDoc}//from  w ww.  j  av a2 s  .c om
 */
@Override
public void beforeRequest(Request<?> request) {
    Tracer.SpanBuilder spanBuilder = tracer.buildSpan(request.getOriginalRequest().getClass().getSimpleName())
            .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);

    if (parentContext != null) {
        spanBuilder.asChildOf(parentContext);
    }

    Span span = spanBuilder.start();
    SpanDecorator.onRequest(request, span);

    tracer.inject(span.context(), Format.Builtin.HTTP_HEADERS, new TextMapAdapter(request.getHeaders()));

    request.addHandlerContext(contextKey, span);
}