Class Tracing
java.lang.Object
codes.grow.packages.skywalking.tracing.Tracing
Sets up the OpenTelemetry SDK from a
TracingConfig. A service package wraps initWith(codes.grow.packages.skywalking.tracing.TracingConfig, codes.grow.packages.skywalking.tracing.SpanExporterFactory) in its initTracing(config) with its own exporter defaults.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringInstrumentation scope name used by the helpers in this package. -
Method Summary
Modifier and TypeMethodDescriptionstatic TracingHandleinitWith(TracingConfig config, SpanExporterFactory exporterFactory) Builds and starts the tracer provider: resource from the config, sampler, batch span processor and propagators; registers it globally whensetGlobalis true.static TracingHandleinitWith(TracingConfig config, SpanExporterFactory exporterFactory, Map<String, io.opentelemetry.context.propagation.TextMapPropagator> extraPropagators) LikeinitWith(TracingConfig, SpanExporterFactory)with propagators the service package provides (for example"datadog"or"sw8").static TracingHandleinitWith(TracingConfig config, SpanExporterFactory exporterFactory, Map<String, io.opentelemetry.context.propagation.TextMapPropagator> extraPropagators, io.opentelemetry.sdk.trace.samplers.Sampler sampler, List<? extends io.opentelemetry.sdk.trace.SpanProcessor> extraProcessors) LikeinitWith(TracingConfig, SpanExporterFactory, Map)with a sampler override (for example a remote sampler) and extra span processors.static io.opentelemetry.api.OpenTelemetryThe OpenTelemetry instance the helpers use: the most recently initialised, not yet shut down handle, else the global instance (no-op when none is registered).static io.opentelemetry.context.propagation.ContextPropagatorspropagators(List<String> names, Map<String, io.opentelemetry.context.propagation.TextMapPropagator> extra) Resolves propagator names.static io.opentelemetry.sdk.resources.Resourceresource(TracingConfig config) Builds the resource: SDK defaults plusservice.name,service.version,deployment.environment.name(current semantic conventions) together with the legacydeployment.environment, and the extra resource attributes.static io.opentelemetry.sdk.trace.samplers.Samplersampler(TracingConfig config) Builds the sampler.
-
Field Details
-
INSTRUMENTATION_NAME
Instrumentation scope name used by the helpers in this package.- See Also:
-
-
Method Details
-
initWith
Builds and starts the tracer provider: resource from the config, sampler, batch span processor and propagators; registers it globally whensetGlobalis true.- Parameters:
config- tracing configexporterFactory- creates the span exporter- Returns:
- handle
- Throws:
ConfigException- for unknown propagators or when a global OpenTelemetry already exists
-
initWith
public static TracingHandle initWith(TracingConfig config, SpanExporterFactory exporterFactory, Map<String, io.opentelemetry.context.propagation.TextMapPropagator> extraPropagators) LikeinitWith(TracingConfig, SpanExporterFactory)with propagators the service package provides (for example"datadog"or"sw8").- Parameters:
config- tracing configexporterFactory- creates the span exporterextraPropagators- propagators by name- Returns:
- handle
-
initWith
public static TracingHandle initWith(TracingConfig config, SpanExporterFactory exporterFactory, Map<String, io.opentelemetry.context.propagation.TextMapPropagator> extraPropagators, io.opentelemetry.sdk.trace.samplers.Sampler sampler, List<? extends io.opentelemetry.sdk.trace.SpanProcessor> extraProcessors) LikeinitWith(TracingConfig, SpanExporterFactory, Map)with a sampler override (for example a remote sampler) and extra span processors. The extra processors run before the batch export processor and are shut down with the provider.- Parameters:
config- tracing configexporterFactory- creates the span exporterextraPropagators- propagators by name (empty ornullfor none)sampler- sampler to use instead ofsampler(TracingConfig), ornullextraProcessors- additional span processors (empty ornullfor none)- Returns:
- handle
- Throws:
ConfigException- for unknown propagators or when a global OpenTelemetry already exists
-
openTelemetry
public static io.opentelemetry.api.OpenTelemetry openTelemetry()The OpenTelemetry instance the helpers use: the most recently initialised, not yet shut down handle, else the global instance (no-op when none is registered).- Returns:
- OpenTelemetry
-
resource
Builds the resource: SDK defaults plusservice.name,service.version,deployment.environment.name(current semantic conventions) together with the legacydeployment.environment, and the extra resource attributes.- Parameters:
config- tracing config- Returns:
- resource
-
sampler
Builds the sampler.- Parameters:
config- tracing config- Returns:
- sampler
-
propagators
public static io.opentelemetry.context.propagation.ContextPropagators propagators(List<String> names, Map<String, io.opentelemetry.context.propagation.TextMapPropagator> extra) Resolves propagator names.- Parameters:
names-tracecontext,baggage,b3(single header),b3multi,noneor a key ofextraextra- service-provided propagators- Returns:
- composite propagators
- Throws:
ConfigException- for an unknown name
-