public class OpenCensusUtils
Beta
Utilities for Census monitoring and tracing.
Static Fields
SPAN_NAME_HTTP_REQUEST_EXECUTE
public static final String SPAN_NAME_HTTP_REQUEST_EXECUTE
Span name for tracing HttpRequest#execute().
Field Value | |
---|---|
Type | Description |
String |
Static Methods
getEndSpanOptions(Integer statusCode)
public static EndSpanOptions getEndSpanOptions(Integer statusCode)
Returns an EndSpanOptions to end a http span according to the status code.
Parameter | |
---|---|
Name | Description |
statusCode | Integer the status code, can be null to represent no valid response is returned. |
Returns | |
---|---|
Type | Description |
io.opencensus.trace.EndSpanOptions | an |
getTracer()
public static Tracer getTracer()
Returns the tracing component of OpenCensus.
Returns | |
---|---|
Type | Description |
io.opencensus.trace.Tracer | the tracing component of OpenCensus. |
isRecordEvent()
public static boolean isRecordEvent()
Returns whether spans should be recorded locally.
Returns | |
---|---|
Type | Description |
boolean | whether spans should be recorded locally. |
propagateTracingContext(Span span, HttpHeaders headers)
public static void propagateTracingContext(Span span, HttpHeaders headers)
Propagate information of current tracing context. This information will be injected into HTTP header.
Parameters | |
---|---|
Name | Description |
span | io.opencensus.trace.Span the span to be propagated. |
headers | HttpHeaders the headers used in propagation. |
recordReceivedMessageEvent(Span span, long size)
public static void recordReceivedMessageEvent(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 | |
---|---|
Name | Description |
span | io.opencensus.trace.Span The |
size | long Size of the response. |
recordSentMessageEvent(Span span, long size)
public static void recordSentMessageEvent(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 | |
---|---|
Name | Description |
span | io.opencensus.trace.Span The |
size | long Size of the request. |
setIsRecordEvent(boolean recordEvent)
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.
Parameter | |
---|---|
Name | Description |
recordEvent | boolean record span locally if true. |
setPropagationTextFormat(TextFormat textFormat)
public static void setPropagationTextFormat(TextFormat textFormat)
Sets the TextFormat used 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 with #setPropagationTextFormatSetter for setting purpose.
Parameter | |
---|---|
Name | Description |
textFormat | io.opencensus.trace.propagation.TextFormat the text format. |
setPropagationTextFormatSetter(TextFormat.Setter textFormatSetter)
public static void setPropagationTextFormatSetter(TextFormat.Setter textFormatSetter)
Sets the io.opencensus.trace.propagation.TextFormat.Setter used 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 with #setPropagationTextFormat for setting purpose.
Parameter | |
---|---|
Name | Description |
textFormatSetter | io.opencensus.trace.propagation.TextFormat.Setter the |