Package codes.grow.packages.skywalking
Class SkyWalkingConfig.Builder
java.lang.Object
codes.grow.packages.skywalking.SkyWalkingConfig.Builder
- Enclosing class:
SkyWalkingConfig
Builder of the configuration.
Unset fields take the environment (when fromEnv(EnvReader) is called) or the
default.
-
Method Summary
Modifier and TypeMethodDescriptionauthentication(Secret authentication) Sets the OAP gRPC token (SW_AUTHENTICATION).authentication(String authentication) Sets the OAP gRPC token (SW_AUTHENTICATION).build()Builds and validates the configuration.Sets the connect timeout (default 10 s).Fills every field that was not set explicitly from the environment:url(URL,GROW_SKYWALKING_URL,SW_GRAPHQL_URLwithout/graphql,SW_OAP_ADDRESS),GRAPHQL_PATH,otlpEndpoint(OTLP_ENDPOINT,OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,OTEL_EXPORTER_OTLP_ENDPOINT,SW_AGENT_COLLECTOR_BACKEND_SERVICESashttp://host:port),otlpProtocol,otlpHeaders(OTEL_EXPORTER_OTLP_[TRACES_]HEADERS),authentication(AUTHENTICATION,SW_AUTHENTICATION,SW_AGENT_AUTHENTICATION),zipkinUrl(ZIPKIN_URL,SW_ZIPKIN_ADDRESSplus/zipkin),TRACE_BACKENDand the common timeout, retry, TLS and proxy variables.graphqlPath(String graphqlPath) Sets the GraphQL path (default/graphql).Adds a header sent with every HTTP request (for example gateway credentials).Sets request hooks.Sets the logger (default silent).otlpEndpoint(String otlpEndpoint) Sets the OTLP endpoint (defaulthttp://<url host>:11800).otlpHeader(String name, String value) Adds an OTLP exporter header (gRPC metadata).otlpHeaders(Map<String, String> otlpHeaders) Replaces the OTLP exporter headers.otlpProtocol(OtlpProtocol otlpProtocol) Sets the OTLP protocol (defaultOtlpProtocol.GRPC).Sets an explicit proxy URL; environment proxies (HTTPS_PROXY) are never used.Sets the per-attempt timeout (default 30 s).retry(RetryPolicy retry) Sets the retry policy (defaultRetryPolicy.defaults()).tls(TlsOptions tls) Sets the TLS options; environment TLS variables are then ignored.Sets the total timeout per call including retries (default 120 s).traceBackend(TraceBackend traceBackend) Sets the trace store read bySkyWalkingClient.traces()(defaultTraceBackend.AUTO).Sets the REST/GraphQL base URL (defaulthttp://127.0.0.1:12800); a trailing/graphqlis stripped.userAgentSuffix(String suffix) Sets the text appended to theUser-Agent.Sets the Zipkin query API base (defaulthttp://<url host>:9412/zipkin).
-
Method Details
-
fromEnv
Fills every field that was not set explicitly from the environment:url(URL,GROW_SKYWALKING_URL,SW_GRAPHQL_URLwithout/graphql,SW_OAP_ADDRESS),GRAPHQL_PATH,otlpEndpoint(OTLP_ENDPOINT,OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,OTEL_EXPORTER_OTLP_ENDPOINT,SW_AGENT_COLLECTOR_BACKEND_SERVICESashttp://host:port),otlpProtocol,otlpHeaders(OTEL_EXPORTER_OTLP_[TRACES_]HEADERS),authentication(AUTHENTICATION,SW_AUTHENTICATION,SW_AGENT_AUTHENTICATION),zipkinUrl(ZIPKIN_URL,SW_ZIPKIN_ADDRESSplus/zipkin),TRACE_BACKENDand the common timeout, retry, TLS and proxy variables.- Parameters:
env- environment reader- Returns:
- this builder
- Throws:
ConfigException- when a variable holds an invalid value
-
url
Sets the REST/GraphQL base URL (defaulthttp://127.0.0.1:12800); a trailing/graphqlis stripped.- Parameters:
url-httporhttpsURL- Returns:
- this builder
-
graphqlPath
Sets the GraphQL path (default/graphql).- Parameters:
graphqlPath- path starting with/- Returns:
- this builder
-
otlpEndpoint
Sets the OTLP endpoint (defaulthttp://<url host>:11800). Never point it at port 12800: OAP 10.4 serves OTLP over gRPC only.- Parameters:
otlpEndpoint-httporhttpsURL- Returns:
- this builder
-
otlpProtocol
Sets the OTLP protocol (defaultOtlpProtocol.GRPC).- Parameters:
otlpProtocol- protocol- Returns:
- this builder
-
otlpHeader
Adds an OTLP exporter header (gRPC metadata).- Parameters:
name- header name (lower-cased)value- header value- Returns:
- this builder
-
otlpHeaders
Replaces the OTLP exporter headers.- Parameters:
otlpHeaders- headers- Returns:
- this builder
-
zipkinUrl
Sets the Zipkin query API base (defaulthttp://<url host>:9412/zipkin).- Parameters:
zipkinUrl-httporhttpsURL- Returns:
- this builder
-
authentication
Sets the OAP gRPC token (SW_AUTHENTICATION).- Parameters:
authentication- token- Returns:
- this builder
-
authentication
Sets the OAP gRPC token (SW_AUTHENTICATION).- Parameters:
authentication- token- Returns:
- this builder
-
traceBackend
Sets the trace store read bySkyWalkingClient.traces()(defaultTraceBackend.AUTO).- Parameters:
traceBackend- backend- Returns:
- this builder
-
connectTimeout
Sets the connect timeout (default 10 s).- Parameters:
d- positive duration- Returns:
- this builder
-
requestTimeout
Sets the per-attempt timeout (default 30 s).- Parameters:
d- positive duration- Returns:
- this builder
-
totalTimeout
Sets the total timeout per call including retries (default 120 s).- Parameters:
d- positive duration- Returns:
- this builder
-
retry
Sets the retry policy (defaultRetryPolicy.defaults()).- Parameters:
retry- policy- Returns:
- this builder
-
tls
Sets the TLS options; environment TLS variables are then ignored.- Parameters:
tls- options- Returns:
- this builder
-
proxy
Sets an explicit proxy URL; environment proxies (HTTPS_PROXY) are never used.- Parameters:
proxy- proxy URL- Returns:
- this builder
-
header
Adds a header sent with every HTTP request (for example gateway credentials).- Parameters:
name- header namevalue- header value- Returns:
- this builder
-
userAgentSuffix
Sets the text appended to theUser-Agent.- Parameters:
suffix- suffix- Returns:
- this builder
-
hooks
Sets request hooks.- Parameters:
hooks- hooks- Returns:
- this builder
-
logger
Sets the logger (default silent).- Parameters:
logger- logger- Returns:
- this builder
-
build
Builds and validates the configuration.- Returns:
- the configuration
- Throws:
ConfigException- when a rule is violated
-