Class Context.Builder (3.16.2)

public static final class Context.Builder

A builder for {@see Context} objects.

Inheritance

java.lang.Object > Context.Builder

Methods

build()

public Context build()

Creates a {@see Context} object for this builder.

Returns
TypeDescription
Context

loadCloudTraceContext(String cloudTrace)

public Context.Builder loadCloudTraceContext(String cloudTrace)

Sets the trace id and span id 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
NameDescription
cloudTraceString
Returns
TypeDescription
Context.Builder

loadW3CTraceParentContext(String traceParent)

public Context.Builder loadW3CTraceParentContext(String traceParent)

Sets the trace id and span id 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
NameDescription
traceParentString
Returns
TypeDescription
Context.Builder

setReferer(String referer)

public Context.Builder setReferer(String referer)

Sets the referer URL of the request, as defined in HTTP/1.1 Header Field Definitions. See Also: HTTP/1.1 Header Field Definitions

Parameter
NameDescription
refererString
Returns
TypeDescription
Context.Builder

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
NameDescription
remoteIpString
Returns
TypeDescription
Context.Builder

setRequest(HttpRequest request)

public Context.Builder setRequest(HttpRequest request)

Sets the HTTP request.

Parameter
NameDescription
requestHttpRequest
Returns
TypeDescription
Context.Builder

setRequestMethod(HttpRequest.RequestMethod method)

public Context.Builder setRequestMethod(HttpRequest.RequestMethod method)

Sets the HTTP request method.

Parameter
NameDescription
methodHttpRequest.RequestMethod
Returns
TypeDescription
Context.Builder

setRequestUrl(String url)

public Context.Builder setRequestUrl(String url)
Parameter
NameDescription
urlString
Returns
TypeDescription
Context.Builder

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
NameDescription
serverIpString
Returns
TypeDescription
Context.Builder

setSpanId(String spanId)

public Context.Builder setSpanId(String spanId)

Sets the string as a span id value.

Parameter
NameDescription
spanIdString
Returns
TypeDescription
Context.Builder

setTraceId(String traceId)

public Context.Builder setTraceId(String traceId)

Sets the string as a trace id value.

Parameter
NameDescription
traceIdString
Returns
TypeDescription
Context.Builder