Package codes.grow.packages.skywalking
Class SkyWalkingConfig
java.lang.Object
codes.grow.packages.skywalking.SkyWalkingConfig
Immutable configuration of a
SkyWalkingClient (SPEC section 2.2): the OAP REST/GraphQL
endpoint (port 12800), the OTLP endpoint used by SkyWalkingTracing.initTracing(codes.grow.packages.skywalking.tracing.TracingConfig) (gRPC,
port 11800), the Zipkin query API where OAP stores OTLP spans (port 9412) and the common
transport settings.
Build one with builder() or read it from the environment with fromEnv().
Precedence: explicit builder value > GROW_APACHE_SKYWALKING_<NAME> > vendor
variables (GROW_SKYWALKING_<NAME>, then the SkyWalking/OpenTelemetry names) > default.
toString() never prints credentials.
OAP has no query authentication: GraphQL and the native /v3 HTTP API are open. When
OAP runs behind an authenticating gateway, put its credentials in SkyWalkingConfig.Builder.header(java.lang.String, java.lang.String).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder of the configuration. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns the OAP gRPC token (SW_AUTHENTICATION), sent as theauthenticationmetadata on OTLP exports.static StringbaseFromGraphqlUrl(String url) Strips a trailing/graphql(and slashes) from a GraphQL URL:http://oap:12800/graphql→http://oap:12800.static SkyWalkingConfig.Builderbuilder()Starts an empty builder (every field at its default).static StringcollectorToUrl(String value) Turns a SkyWalking agent collector address (host:port[,host:port]) into an OTLP endpoint URL (http://host:port, first entry).Returns the connect timeout.static SkyWalkingConfigfromEnv()Reads the configuration from the process environment.static SkyWalkingConfigReads the configuration from an explicit variable map (tests).Returns the GraphQL path (default/graphql).Returns the absolute GraphQL URL.headers()Returns the extra request headers.hooks()Returns the hooks.Credential values to redact from error messages and logs: the authentication token and the values of sensitive OTLP headers.logger()Returns the logger.Returns the OTLP endpoint ofSkyWalkingTracing.initTracing(codes.grow.packages.skywalking.tracing.TracingConfig)(defaulthttp://<url host>:11800).Returns the extra OTLP exporter headers (gRPC metadata), keys lower-case.Returns the OTLP protocol (defaultOtlpProtocol.GRPC).parseOtlpHeaders(String raw, String source) Parses OpenTelemetry-style headersk1=v1,k2=v2(keys lower-cased, values URL-decoded).proxy()Returns the explicit proxy URL.Returns the per-attempt timeout.retry()Returns the retry policy.tls()Returns the TLS options.Returns a builder holding these values.toString()Returns the total timeout per call including retries.Translates the common fields into transport settings.Returns the trace store read bySkyWalkingClient.traces()(defaultTraceBackend.AUTO).url()Returns the REST/GraphQL base URL (port 12800, no trailing/graphql).Returns the user agent suffix.voidvalidate()Checks the URLs, protocol, backend, positive timeouts, TLS pairs and the proxy.static StringzipkinQueryUrl(String value) Appends/zipkinto a Zipkin address that does not end with it.Returns the Zipkin query API base (defaulthttp://<url host>:9412/zipkin).
-
Field Details
-
DEFAULT_URL
Default REST/GraphQL endpoint.- See Also:
-
DEFAULT_GRAPHQL_PATH
Default GraphQL path below the URL.- See Also:
-
OTLP_GRPC_PORT
public static final int OTLP_GRPC_PORTOAP gRPC port (OTLP receiver).- See Also:
-
ZIPKIN_QUERY_PORT
public static final int ZIPKIN_QUERY_PORTOAP Zipkin query port (SW_QUERY_ZIPKIN).- See Also:
-
-
Method Details
-
builder
Starts an empty builder (every field at its default).- Returns:
- a new builder
-
fromEnv
Reads the configuration from the process environment.- Returns:
- the validated configuration
- Throws:
ConfigException- when a variable holds an invalid value (the message names the variable, never the value)
-
fromEnv
Reads the configuration from an explicit variable map (tests).- Parameters:
env- variable map- Returns:
- the validated configuration
-
baseFromGraphqlUrl
Strips a trailing/graphql(and slashes) from a GraphQL URL:http://oap:12800/graphql→http://oap:12800.- Parameters:
url- URL- Returns:
- the base URL
-
collectorToUrl
Turns a SkyWalking agent collector address (host:port[,host:port]) into an OTLP endpoint URL (http://host:port, first entry).- Parameters:
value- collector address- Returns:
- the endpoint URL
-
zipkinQueryUrl
Appends/zipkinto a Zipkin address that does not end with it.- Parameters:
value- Zipkin address, e.g.http://oap:9412- Returns:
- the query API base, e.g.
http://oap:9412/zipkin
-
parseOtlpHeaders
Parses OpenTelemetry-style headersk1=v1,k2=v2(keys lower-cased, values URL-decoded).- Parameters:
raw- header listsource- variable name for the error message (never the value)- Returns:
- the headers
- Throws:
ConfigException- when an entry is malformed
-
validate
public void validate()Checks the URLs, protocol, backend, positive timeouts, TLS pairs and the proxy.- Throws:
ConfigException- when a rule is violated
-
toTransportConfig
Translates the common fields into transport settings.- Returns:
- the transport configuration
-
knownSecrets
Credential values to redact from error messages and logs: the authentication token and the values of sensitive OTLP headers.- Returns:
- the secret values
-
url
Returns the REST/GraphQL base URL (port 12800, no trailing/graphql).- Returns:
- the URL
-
graphqlPath
Returns the GraphQL path (default/graphql).- Returns:
- the path
-
graphqlUrl
Returns the absolute GraphQL URL.- Returns:
url + graphqlPath
-
otlpEndpoint
Returns the OTLP endpoint ofSkyWalkingTracing.initTracing(codes.grow.packages.skywalking.tracing.TracingConfig)(defaulthttp://<url host>:11800).- Returns:
- the endpoint
-
otlpProtocol
Returns the OTLP protocol (defaultOtlpProtocol.GRPC).- Returns:
- the protocol
-
otlpHeaders
Returns the extra OTLP exporter headers (gRPC metadata), keys lower-case.- Returns:
- immutable map
-
zipkinUrl
Returns the Zipkin query API base (defaulthttp://<url host>:9412/zipkin).- Returns:
- the URL (ends with
/zipkinunless configured otherwise)
-
authentication
Returns the OAP gRPC token (SW_AUTHENTICATION), sent as theauthenticationmetadata on OTLP exports. OAP does not protect GraphQL or/v3with it.- Returns:
- the token, or empty
-
traceBackend
Returns the trace store read bySkyWalkingClient.traces()(defaultTraceBackend.AUTO).- Returns:
- the backend
-
connectTimeout
Returns the connect timeout.- Returns:
- the timeout
-
requestTimeout
Returns the per-attempt timeout.- Returns:
- the timeout
-
totalTimeout
Returns the total timeout per call including retries.- Returns:
- the timeout
-
retry
Returns the retry policy.- Returns:
- the policy
-
tls
Returns the TLS options.- Returns:
- the options
-
proxy
Returns the explicit proxy URL.- Returns:
- the proxy, or empty
-
headers
Returns the extra request headers.- Returns:
- immutable map
-
userAgentSuffix
Returns the user agent suffix.- Returns:
- the suffix, or empty
-
hooks
Returns the hooks.- Returns:
- the hooks
-
logger
Returns the logger.- Returns:
- the logger
-
toBuilder
Returns a builder holding these values.- Returns:
- builder copy
-
toString
-