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
AStreamingHttpService
that supports open tracing.Append this filter before others that are expected to to see
Scope
for this request/response. Filters appended after this filter that use operators with the after* prefix onresponse meta data
or theresponse payload body
(e.g.Publisher.afterFinally(Runnable)
) will execute after this filter invokesScope.close()
and therefore will not see theSpan
for the current request/response.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
componentName
protected InMemoryTraceStateFormat<HttpHeaders>
formatter
protected io.opentracing.Tracer
tracer
-
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 StreamingHttpServiceFilter
create(StreamingHttpService service)
Create aStreamingHttpServiceFilter
using the providedStreamingHttpService
.protected java.lang.String
getOperationName(java.lang.String componentName, HttpRequestMetaData metaData)
Get the operation name to build the span with.protected boolean
injectSpanContextIntoResponse(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
-true
to validate the contents of the trace ids.
-
-
Method Detail
-
create
public final StreamingHttpServiceFilter create(StreamingHttpService service)
Description copied from interface:StreamingHttpServiceFilterFactory
Create aStreamingHttpServiceFilter
using the providedStreamingHttpService
.- Specified by:
create
in interfaceStreamingHttpServiceFilterFactory
- Parameters:
service
-StreamingHttpService
to filter- Returns:
StreamingHttpServiceFilter
using 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:
true
if the current span context should be injected into the response.
-
-