Class TimeLimitedHandler
- java.lang.Object
-
- io.opencensus.trace.export.SpanExporter.Handler
-
- io.opencensus.exporter.trace.util.TimeLimitedHandler
-
public abstract class TimeLimitedHandler extends SpanExporter.Handler
An abstract class that allows different tracing services to export recorded data for sampled spans in their own format within a given time frame. If export does not complete within the time frame, spans will be dropped and no retries will be performed.Only extend this class if the client APIs don't support timeout natively. If there is a timeout option in the client APIs (for example Stackdriver Trace V2 API allows you to set timeout), use that instead.
To export data this MUST be register to to the ExportComponent using
SpanExporter.registerHandler(String, Handler).- Since:
- 0.22
-
-
Field Summary
Fields Modifier and Type Field Description private Durationdeadlineprivate java.lang.StringexportSpanNameprivate static java.util.logging.Loggerloggerprivate static SamplerlowProbabilitySamplerprivate static Tracertracer
-
Constructor Summary
Constructors Modifier Constructor Description protectedTimeLimitedHandler(Duration deadline, java.lang.String exportSpanName)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidexport(java.util.Collection<SpanData> spanDataList)Exports a list of sampled (seeTraceOptions.isSampled())Spans using the immutable representationSpanData.private static voidhandleException(java.lang.Exception e, java.lang.String logMessage)private ScopenewExportScope()abstract voidtimeLimitedExport(java.util.Collection<SpanData> spanDataList)Exports a list of sampled (seeTraceOptions.isSampled())Spans using the immutable representationSpanData, within the givendeadlineof thisTimeLimitedHandler.
-
-
-
Constructor Detail
-
TimeLimitedHandler
protected TimeLimitedHandler(Duration deadline, java.lang.String exportSpanName)
-
-
Method Detail
-
timeLimitedExport
public abstract void timeLimitedExport(java.util.Collection<SpanData> spanDataList) throws java.lang.Exception
Exports a list of sampled (seeTraceOptions.isSampled())Spans using the immutable representationSpanData, within the givendeadlineof thisTimeLimitedHandler.- Parameters:
spanDataList- a list ofSpanDataobjects to be exported.- Throws:
java.lang.Exception- throws exception when failed to export.- Since:
- 0.22
-
export
public void export(java.util.Collection<SpanData> spanDataList)
Description copied from class:SpanExporter.HandlerExports a list of sampled (seeTraceOptions.isSampled())Spans using the immutable representationSpanData.This may be called from a different thread than the one that called
Span.end().Implementation SHOULD not block the calling thread. It should execute the export on a different thread if possible.
- Specified by:
exportin classSpanExporter.Handler- Parameters:
spanDataList- a list ofSpanDataobjects to be exported.
-
newExportScope
@MustBeClosed private Scope newExportScope()
-
handleException
private static void handleException(java.lang.Exception e, java.lang.String logMessage)
-
-