public static class OpenTelemetryConfiguration.Builder
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
OpenTelemetryConfiguration.Builder |
addResourceAttribute(java.lang.String key,
boolean value)
Add a boolean attribute as a resource attribute.
|
OpenTelemetryConfiguration.Builder |
addResourceAttribute(java.lang.String key,
double value)
Add a double attribute as a resource attribute.
|
OpenTelemetryConfiguration.Builder |
addResourceAttribute(java.lang.String key,
long value)
Add a long attribute as a resource attribute.
|
OpenTelemetryConfiguration.Builder |
addResourceAttribute(java.lang.String key,
java.lang.String... value)
Add a String array attribute as a resource attribute.
|
OpenTelemetryConfiguration.Builder |
addResourceAttribute(java.lang.String key,
java.lang.String value)
Add a string attribute as a resource attribute.
|
OpenTelemetryConfiguration.Builder |
addSpanProcessor(io.opentelemetry.sdk.trace.SpanProcessor spanProcessor)
Configures additional
SpanProcessor. |
io.opentelemetry.api.OpenTelemetry |
build()
Returns a new
OpenTelemetry built with the configuration of this OpenTelemetryConfiguration.Builder. |
io.opentelemetry.api.OpenTelemetry |
buildAndRegisterGlobal()
Returns a new
OpenTelemetry built with the configuration of this OpenTelemetryConfiguration.Builder and registers it as the global OpenTelemetry. |
OpenTelemetryConfiguration.Builder |
enableDebug(boolean enabled)
Enables debug mode.
|
OpenTelemetryConfiguration.Builder |
setApiKey(java.lang.String apiKey)
Sets the Honeycomb API Key to use.
|
OpenTelemetryConfiguration.Builder |
setDataset(java.lang.String dataset)
Sets the Honeycomb dataset to use.
|
OpenTelemetryConfiguration.Builder |
setEndpoint(java.lang.String endpoint)
Sets the Honeycomb endpoint to use.
|
OpenTelemetryConfiguration.Builder |
setOtlpProtocol(java.lang.String protocol)
Sets the OTLP procotol used to export trace spans.
|
OpenTelemetryConfiguration.Builder |
setPropagators(io.opentelemetry.context.propagation.ContextPropagators propagators)
Sets the
ContextPropagators to use. |
OpenTelemetryConfiguration.Builder |
setSampler(io.opentelemetry.sdk.trace.samplers.Sampler sampler)
Sets the
Sampler to use. |
OpenTelemetryConfiguration.Builder |
setServiceName(java.lang.String serviceName)
Sets the service name as a resource attribute.
|
OpenTelemetryConfiguration.Builder |
setTracesApiKey(java.lang.String apiKey)
Sets the Honeycomb API key to send trace data.
|
OpenTelemetryConfiguration.Builder |
setTracesDataset(java.lang.String dataset)
Sets the Honeycomb dataset to store trace data.
|
OpenTelemetryConfiguration.Builder |
setTracesEndpoint(java.lang.String endpoint)
Sets the Honeycomb endpoint to send trace data.
|
public OpenTelemetryConfiguration.Builder setApiKey(java.lang.String apiKey)
This value is sent to Honeycomb on every request and is used to identify the team making a request.
apiKey - a String to use as the API key. See team settings in Honeycomb.public OpenTelemetryConfiguration.Builder setTracesApiKey(java.lang.String apiKey)
This value is sent to Honeycomb on every request and is used to identify the team making a request.
apiKey - a String to use as the API key. See team settings in Honeycomb.public OpenTelemetryConfiguration.Builder setDataset(java.lang.String dataset)
This value is sent to Honeycomb on every request and is used to identify the dataset that trace data is being written to.
dataset - a String to use as the dataset name.public OpenTelemetryConfiguration.Builder setTracesDataset(java.lang.String dataset)
This value is sent to Honeycomb on every request and is used to identify the dataset that metrics data is being written to.
dataset - a String to use as the metrics dataset name.public OpenTelemetryConfiguration.Builder setEndpoint(java.lang.String endpoint)
endpoint - a String to use as the endpoint URI. Must begin with https or http.public OpenTelemetryConfiguration.Builder setTracesEndpoint(java.lang.String endpoint)
endpoint - a String to use as the endpoint URI. Must begin with https or http.public OpenTelemetryConfiguration.Builder setServiceName(java.lang.String serviceName)
serviceName - a String to use as the service namepublic OpenTelemetryConfiguration.Builder setPropagators(io.opentelemetry.context.propagation.ContextPropagators propagators)
ContextPropagators to use.
Note that if none are specified, W3CTraceContextPropagator and W3CBaggagePropagator
will be used by default.
propagators - ContextPropagators to use for context propagationpublic OpenTelemetryConfiguration.Builder setSampler(io.opentelemetry.sdk.trace.samplers.Sampler sampler)
Sampler to use.
Note that if no sampler is specified, a DeterministicTraceSampler with a
sample rate of 1 (always sample) will be used by default.
sampler - Sampler instancepublic OpenTelemetryConfiguration.Builder addSpanProcessor(io.opentelemetry.sdk.trace.SpanProcessor spanProcessor)
SpanProcessor.
BaggageSpanProcessor and BatchSpanProcessor are always configured by default.spanProcessor - Instance of a SpanProcessor.public OpenTelemetryConfiguration.Builder enableDebug(boolean enabled)
true a LoggingSpanExporter is added to the export pipeline
that will output traces and metrics data.enabled - defaults to falsepublic OpenTelemetryConfiguration.Builder addResourceAttribute(java.lang.String key, java.lang.String value)
key - The key to associate a value withvalue - The value to store as an attributepublic OpenTelemetryConfiguration.Builder addResourceAttribute(java.lang.String key, long value)
key - The key to associate a value withvalue - The value to store as an attributepublic OpenTelemetryConfiguration.Builder addResourceAttribute(java.lang.String key, double value)
key - The key to associate a value withvalue - The value to store as an attributepublic OpenTelemetryConfiguration.Builder addResourceAttribute(java.lang.String key, boolean value)
key - The key to associate a value withvalue - The value to store as an attributepublic OpenTelemetryConfiguration.Builder addResourceAttribute(java.lang.String key, java.lang.String... value)
key - The key to associate a value withvalue - The value to store as an attributepublic OpenTelemetryConfiguration.Builder setOtlpProtocol(java.lang.String protocol)
protocol - The protocol to use to export spans withpublic io.opentelemetry.api.OpenTelemetry buildAndRegisterGlobal()
OpenTelemetry built with the configuration of this OpenTelemetryConfiguration.Builder and registers it as the global OpenTelemetry. An exception will be thrown if this method is attempted to
be called multiple times in the lifecycle of an application - ensure you have only one SDK for
use as the global instance. If you need to configure multiple SDKs for tests, use GlobalOpenTelemetry.resetForTest() between them.OpenTelemetry instanceGlobalOpenTelemetrypublic io.opentelemetry.api.OpenTelemetry build()
OpenTelemetry built with the configuration of this OpenTelemetryConfiguration.Builder. This SDK is not registered as the global OpenTelemetry. It is recommended that you register one SDK using buildAndRegisterGlobal() for use by instrumentation that requires
access to a global instance of OpenTelemetry.
Note that the OpenTelemetryConfiguration.Builder automatically assigns a
SdkTracerProvider with a BatchSpanProcessor that has an
OtlpGrpcSpanExporter configured.
OpenTelemetry instanceGlobalOpenTelemetry