Package io.servicetalk.opentracing.http
Class TracingHttpServiceFilter
- java.lang.Object
-
- io.servicetalk.opentracing.http.TracingHttpServiceFilter
-
- All Implemented Interfaces:
StreamingHttpServiceFilterFactory
public class TracingHttpServiceFilter extends java.lang.Object implements StreamingHttpServiceFilterFactory
AStreamingHttpServicethat supports open tracing.Append this filter before others that are expected to to see
Scopefor this request/response. Filters appended after this filter that use operators with the after* prefix onresponse meta dataor theresponse message body(e.g.Publisher.afterFinally(Runnable)) will execute after this filter invokesScope.close()and therefore will not see theSpanfor the current request/response.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringcomponentNameprotected InMemoryTraceStateFormat<HttpHeaders>formatterprotected io.opentracing.Tracertracer
-
Constructor Summary
Constructors Constructor Description TracingHttpServiceFilter(io.opentracing.Tracer tracer, java.lang.String componentName)Create a new instance.TracingHttpServiceFilter(io.opentracing.Tracer tracer, java.lang.String componentName, boolean validateTraceKeyFormat)Create a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StreamingHttpServiceFiltercreate(StreamingHttpService service)Create aStreamingHttpServiceFilterusing the providedStreamingHttpService.protected java.lang.StringgetOperationName(java.lang.String componentName, HttpRequestMetaData metaData)Get the operation name to build the span with.protected booleaninjectSpanContextIntoResponse(io.opentracing.SpanContext parentSpanContext)Determine if the current span context should be injected into the response.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.servicetalk.http.api.StreamingHttpServiceFilterFactory
append
-
-
-
-
Field Detail
-
tracer
protected final io.opentracing.Tracer tracer
-
componentName
protected final java.lang.String componentName
-
formatter
protected final InMemoryTraceStateFormat<HttpHeaders> formatter
-
-
Constructor Detail
-
TracingHttpServiceFilter
public TracingHttpServiceFilter(io.opentracing.Tracer tracer, java.lang.String componentName)Create a new instance.- Parameters:
tracer- TheTracer.componentName- The component name used during building new spans.
-
TracingHttpServiceFilter
public TracingHttpServiceFilter(io.opentracing.Tracer tracer, java.lang.String componentName, boolean validateTraceKeyFormat)Create a new instance.- Parameters:
tracer- TheTracer.componentName- The component name used during building new spans.validateTraceKeyFormat-trueto validate the contents of the trace ids.
-
-
Method Detail
-
create
public final StreamingHttpServiceFilter create(StreamingHttpService service)
Description copied from interface:StreamingHttpServiceFilterFactoryCreate aStreamingHttpServiceFilterusing the providedStreamingHttpService.- Specified by:
createin interfaceStreamingHttpServiceFilterFactory- Parameters:
service-StreamingHttpServiceto filter- Returns:
StreamingHttpServiceFilterusing the providedStreamingHttpService.
-
getOperationName
protected java.lang.String getOperationName(java.lang.String componentName, HttpRequestMetaData metaData)Get the operation name to build the span with.- Parameters:
componentName- The component name.metaData- TheHttpRequestMetaData.- Returns:
- the operation name to build the span with.
-
injectSpanContextIntoResponse
protected boolean injectSpanContextIntoResponse(@Nullable io.opentracing.SpanContext parentSpanContext)Determine if the current span context should be injected into the response.- Parameters:
parentSpanContext- The parent span extracted from the request.- Returns:
trueif the current span context should be injected into the response.
-
-