Package com.google.api.client.http
Class OpenCensusUtils
- java.lang.Object
-
- com.google.api.client.http.OpenCensusUtils
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.concurrent.atomic.AtomicLongidGeneratorSequence id generator for message event.private static booleanisRecordEventWhether spans should be recorded locally.private static java.util.logging.Loggerlogger(package private) static io.opencensus.trace.propagation.TextFormatpropagationTextFormatTextFormatused in tracing context propagation.(package private) static io.opencensus.trace.propagation.TextFormat.SetterpropagationTextFormatSetterTextFormat.SetterforpropagationTextFormat.static java.lang.StringSPAN_NAME_HTTP_REQUEST_EXECUTESpan name for tracingHttpRequest.execute().private static io.opencensus.trace.TracertracerOpenCensus tracing component.
-
Constructor Summary
Constructors Modifier Constructor Description privateOpenCensusUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static io.opencensus.trace.EndSpanOptionsgetEndSpanOptions(java.lang.Integer statusCode)Returns anEndSpanOptionsto end a http span according to the status code.static io.opencensus.trace.TracergetTracer()Returns the tracing component of OpenCensus.static booleanisRecordEvent()Returns whether spans should be recorded locally.static voidpropagateTracingContext(io.opencensus.trace.Span span, HttpHeaders headers)Propagate information of current tracing context.(package private) static voidrecordMessageEvent(io.opencensus.trace.Span span, long size, io.opencensus.trace.MessageEvent.Type eventType)Records a message event of a certainMessageEvent.Type.static voidrecordReceivedMessageEvent(io.opencensus.trace.Span span, long size)Records a new message event which contains the size of the response content.static voidrecordSentMessageEvent(io.opencensus.trace.Span span, long size)Records a new message event which contains the size of the request content.static voidsetIsRecordEvent(boolean recordEvent)Sets whether spans should be recorded locally.static voidsetPropagationTextFormat(io.opencensus.trace.propagation.TextFormat textFormat)Sets theTextFormatused in context propagation.static voidsetPropagationTextFormatSetter(io.opencensus.trace.propagation.TextFormat.Setter textFormatSetter)Sets theTextFormat.Setterused in context propagation.
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
SPAN_NAME_HTTP_REQUEST_EXECUTE
public static final java.lang.String SPAN_NAME_HTTP_REQUEST_EXECUTE
Span name for tracingHttpRequest.execute().
-
tracer
private static final io.opencensus.trace.Tracer tracer
OpenCensus tracing component. When no OpenCensus implementation is provided, it will return a no-op tracer.
-
idGenerator
private static final java.util.concurrent.atomic.AtomicLong idGenerator
Sequence id generator for message event.
-
isRecordEvent
private static volatile boolean isRecordEvent
Whether spans should be recorded locally. Defaults to true.
-
propagationTextFormat
@Nullable static volatile io.opencensus.trace.propagation.TextFormat propagationTextFormat
TextFormatused in tracing context propagation.
-
propagationTextFormatSetter
@Nullable static volatile io.opencensus.trace.propagation.TextFormat.Setter propagationTextFormatSetter
TextFormat.SetterforpropagationTextFormat.
-
-
Method Detail
-
setPropagationTextFormat
public static void setPropagationTextFormat(@Nullable io.opencensus.trace.propagation.TextFormat textFormat)Sets theTextFormatused in context propagation.This API allows users of google-http-client to specify other text format, or disable context propagation by setting it to
null. It should be used along withsetPropagationTextFormatSetter(io.opencensus.trace.propagation.TextFormat.Setter)for setting purpose.- Parameters:
textFormat- the text format.
-
setPropagationTextFormatSetter
public static void setPropagationTextFormatSetter(@Nullable io.opencensus.trace.propagation.TextFormat.Setter textFormatSetter)Sets theTextFormat.Setterused in context propagation.This API allows users of google-http-client to specify other text format setter, or disable context propagation by setting it to
null. It should be used along withsetPropagationTextFormat(io.opencensus.trace.propagation.TextFormat)for setting purpose.- Parameters:
textFormatSetter- theTextFormat.Setterfor the text format.
-
setIsRecordEvent
public static void setIsRecordEvent(boolean recordEvent)
Sets whether spans should be recorded locally.This API allows users of google-http-client to turn on/off local span collection.
- Parameters:
recordEvent- record span locally if true.
-
getTracer
public static io.opencensus.trace.Tracer getTracer()
Returns the tracing component of OpenCensus.- Returns:
- the tracing component of OpenCensus.
-
isRecordEvent
public static boolean isRecordEvent()
Returns whether spans should be recorded locally.- Returns:
- whether spans should be recorded locally.
-
propagateTracingContext
public static void propagateTracingContext(io.opencensus.trace.Span span, HttpHeaders headers)Propagate information of current tracing context. This information will be injected into HTTP header.- Parameters:
span- the span to be propagated.headers- the headers used in propagation.
-
getEndSpanOptions
public static io.opencensus.trace.EndSpanOptions getEndSpanOptions(@Nullable java.lang.Integer statusCode)Returns anEndSpanOptionsto end a http span according to the status code.- Parameters:
statusCode- the status code, can be null to represent no valid response is returned.- Returns:
- an
EndSpanOptionsthat best suits the status code.
-
recordSentMessageEvent
public static void recordSentMessageEvent(io.opencensus.trace.Span span, long size)Records a new message event which contains the size of the request content. Note that the size represents the message size in application layer, i.e., content-length.- Parameters:
span- Thespanin which the send event occurs.size- Size of the request.
-
recordReceivedMessageEvent
public static void recordReceivedMessageEvent(io.opencensus.trace.Span span, long size)Records a new message event which contains the size of the response content. Note that the size represents the message size in application layer, i.e., content-length.- Parameters:
span- Thespanin which the receive event occurs.size- Size of the response.
-
recordMessageEvent
static void recordMessageEvent(io.opencensus.trace.Span span, long size, io.opencensus.trace.MessageEvent.Type eventType)Records a message event of a certainMessageEvent.Type. This method is package protected sinceMessageEventmight be deprecated in future releases.- Parameters:
span- Thespanin which the event occurs.size- Size of the message.eventType- TheNetworkEvent.Typeof the message event.
-
-