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.
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.
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.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Class OpenCensusUtils (2.0.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.0.0 (latest)](/java/docs/reference/google-http-client/latest/com.google.api.client.http.OpenCensusUtils)\n- [1.47.1](/java/docs/reference/google-http-client/1.47.1/com.google.api.client.http.OpenCensusUtils)\n- [1.46.3](/java/docs/reference/google-http-client/1.46.3/com.google.api.client.http.OpenCensusUtils)\n- [1.45.3](/java/docs/reference/google-http-client/1.45.3/com.google.api.client.http.OpenCensusUtils)\n- [1.44.2](/java/docs/reference/google-http-client/1.44.2/com.google.api.client.http.OpenCensusUtils)\n- [1.43.2](/java/docs/reference/google-http-client/1.43.2/com.google.api.client.http.OpenCensusUtils)\n- [1.42.3](/java/docs/reference/google-http-client/1.42.3/com.google.api.client.http.OpenCensusUtils)\n- [1.41.8](/java/docs/reference/google-http-client/1.41.8/com.google.api.client.http.OpenCensusUtils) \n\n public class OpenCensusUtils\n\n[Beta](/java/docs/reference/google-http-client/latest/com.google.api.client.util.Beta) \n\nUtilities for Census monitoring and tracing. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e OpenCensusUtils \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nStatic Fields\n-------------\n\n### SPAN_NAME_HTTP_REQUEST_EXECUTE\n\n public static final String SPAN_NAME_HTTP_REQUEST_EXECUTE\n\nSpan name for tracing [HttpRequest#execute()](/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpRequest#com_google_api_client_http_HttpRequest_execute__).\n\nStatic Methods\n--------------\n\n### getEndSpanOptions(Integer statusCode)\n\n public static EndSpanOptions getEndSpanOptions(Integer statusCode)\n\nReturns an EndSpanOptions to end a http span according to the status code.\n\n### getTracer()\n\n public static Tracer getTracer()\n\nReturns the tracing component of OpenCensus.\n\n### isRecordEvent()\n\n public static boolean isRecordEvent()\n\nReturns whether spans should be recorded locally.\n\n### propagateTracingContext(Span span, HttpHeaders headers)\n\n public static void propagateTracingContext(Span span, HttpHeaders headers)\n\nPropagate information of current tracing context. This information will be injected into HTTP\nheader.\n\n### recordReceivedMessageEvent(Span span, long size)\n\n public static void recordReceivedMessageEvent(Span span, long size)\n\nRecords a new message event which contains the size of the response content. Note that the size\nrepresents the message size in application layer, i.e., content-length.\n\n### recordSentMessageEvent(Span span, long size)\n\n public static void recordSentMessageEvent(Span span, long size)\n\nRecords a new message event which contains the size of the request content. Note that the size\nrepresents the message size in application layer, i.e., content-length.\n\n### setIsRecordEvent(boolean recordEvent)\n\n public static void setIsRecordEvent(boolean recordEvent)\n\nSets whether spans should be recorded locally.\n\nThis API allows users of google-http-client to turn on/off local span collection.\n\n### setPropagationTextFormat(TextFormat textFormat)\n\n public static void setPropagationTextFormat(TextFormat textFormat)\n\nSets the TextFormat used in context propagation.\n\nThis API allows users of google-http-client to specify other text format, or disable context\npropagation by setting it to `null`. It should be used along with [#setPropagationTextFormatSetter](/java/docs/reference/google-http-client/latest/com.google.api.client.http.OpenCensusUtils#com_google_api_client_http_OpenCensusUtils_setPropagationTextFormatSetter_) for setting purpose.\n\n### setPropagationTextFormatSetter(TextFormat.Setter textFormatSetter)\n\n public static void setPropagationTextFormatSetter(TextFormat.Setter textFormatSetter)\n\nSets the io.opencensus.trace.propagation.TextFormat.Setter used in context propagation.\n\nThis API allows users of google-http-client to specify other text format setter, or disable\ncontext propagation by setting it to `null`. It should be used along with [#setPropagationTextFormat](/java/docs/reference/google-http-client/latest/com.google.api.client.http.OpenCensusUtils#com_google_api_client_http_OpenCensusUtils_setPropagationTextFormat_) for setting purpose."]]