Send feedback
Class Context.Builder (3.19.0)
Stay organized with collections
Save and categorize content based on your preferences.
Version 3.19.0 keyboard_arrow_down
public static final class Context . Builder
A builder for {@see Context} objects.
Methods
build()
Creates a {@see Context} object for this builder.
loadCloudTraceContext(String cloudTrace)
public Context . Builder loadCloudTraceContext ( String cloudTrace )
Sets the trace id, span id and trace sampled flag values by parsing the string which
represents xCloud Trace Context. The Cloud Trace Context is passed as
x-cloud-trace-context
header (can be in Pascal case format). The string format is
TRACE_ID/SPAN_ID;o=TRACE_TRUE
.
See Also: Cloud Trace header format.
Parameter
Name
Description
cloudTrace
String
loadOpenTelemetryContext()
public Context . Builder loadOpenTelemetryContext ()
Sets the trace id, span id and trace sampled flag values by parsing detected OpenTelemetry
span context.
See Also: OpenTelemetry SpanContext.
loadW3CTraceParentContext(String traceParent)
public Context . Builder loadW3CTraceParentContext ( String traceParent )
Sets the trace id, span id and trace sampled flag values by parsing the string which
represents the standard W3C trace context propagation header. The context propagation header
is passed as traceparent
header. The method currently supports ONLY version
"00"
. The string format is 00-TRACE_ID-SPAN_ID-FLAGS
. field of the
version-format
value.
See Also: traceparent header value format
Parameter
Name
Description
traceParent
String
setReferer(String referer)
public Context . Builder setReferer ( String referer )
Parameter
Name
Description
referer
String
setRemoteIp(String remoteIp)
public Context . Builder setRemoteIp ( String remoteIp )
Sets the IP address (IPv4 or IPv6) of the client that issued the HTTP request. Examples:
192.168.1.1
, FE80::0202:B3FF:FE1E:8329
.
Parameter
Name
Description
remoteIp
String
setRequest(HttpRequest request)
public Context . Builder setRequest ( HttpRequest request )
setRequestMethod(HttpRequest.RequestMethod method)
public Context . Builder setRequestMethod ( HttpRequest . RequestMethod method )
Sets the HTTP request method.
setRequestUrl(String url)
public Context . Builder setRequestUrl ( String url )
Parameter
Name
Description
url
String
setServerIp(String serverIp)
public Context . Builder setServerIp ( String serverIp )
Sets the IP address (IPv4 or IPv6) of the origin server that the request was sent to.
Examples: 192.168.1.1
, FE80::0202:B3FF:FE1E:8329
.
Parameter
Name
Description
serverIp
String
setSpanId(String spanId)
public Context . Builder setSpanId ( String spanId )
Sets the string as a span id value.
Parameter
Name
Description
spanId
String
setTraceId(String traceId)
public Context . Builder setTraceId ( String traceId )
Sets the string as a trace id value.
Parameter
Name
Description
traceId
String
setTraceSampled(boolean traceSampled)
public Context . Builder setTraceSampled ( boolean traceSampled )
Sets the boolean as trace sampled flag.
Parameter
Name
Description
traceSampled
boolean
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-10 UTC.
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{"lastModified": "Last updated 2024-09-10 UTC."}