java.lang.Object
codes.grow.packages.skywalking.tracing.Tracing

public final class Tracing extends Object
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 Details

    • INSTRUMENTATION_NAME

      public static final String INSTRUMENTATION_NAME
      Instrumentation scope name used by the helpers in this package.
      See Also:
  • Method Details

    • initWith

      public static TracingHandle initWith(TracingConfig config, SpanExporterFactory exporterFactory)
      Builds and starts the tracer provider: resource from the config, sampler, batch span processor and propagators; registers it globally when setGlobal is true.
      Parameters:
      config - tracing config
      exporterFactory - 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)
      Like initWith(TracingConfig, SpanExporterFactory) with propagators the service package provides (for example "datadog" or "sw8").
      Parameters:
      config - tracing config
      exporterFactory - creates the span exporter
      extraPropagators - 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)
      Like initWith(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 config
      exporterFactory - creates the span exporter
      extraPropagators - propagators by name (empty or null for none)
      sampler - sampler to use instead of sampler(TracingConfig), or null
      extraProcessors - additional span processors (empty or null for 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

      public static io.opentelemetry.sdk.resources.Resource resource(TracingConfig config)
      Builds the resource: SDK defaults plus service.name, service.version, deployment.environment.name (current semantic conventions) together with the legacy deployment.environment, and the extra resource attributes.
      Parameters:
      config - tracing config
      Returns:
      resource
    • sampler

      public static io.opentelemetry.sdk.trace.samplers.Sampler sampler(TracingConfig config)
      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, none or a key of extra
      extra - service-provided propagators
      Returns:
      composite propagators
      Throws:
      ConfigException - for an unknown name