Class OtelCollectorTelemetry

java.lang.Object
codes.grow.packages.otelcollector.OtelCollectorTelemetry

public final class OtelCollectorTelemetry extends Object
One-call OpenTelemetry bootstrap for every Grow stack (the platform deploys the collector with each stack): traces (OtelCollectorTracing), logs (an OpenTelemetry LoggerProvider for log appenders plus a BatchingLogClient) and metrics (MeterProvider with a periodic reader) with one shared resource and the official OTLP exporters.
  • Method Details

    • initTelemetry

      public static TelemetryHandle initTelemetry()
      Starts telemetry from the environment (OtelCollectorConfig.fromEnv()).
      Returns:
      the handle
    • initTelemetry

      public static TelemetryHandle initTelemetry(OtelCollectorConfig config)
      Starts telemetry for a config with the default options.
      Parameters:
      config - collector config
      Returns:
      the handle
    • resourceAttributes

      public static Map<String,Object> resourceAttributes(OtelCollectorConfig config, ResourceDetector detector)
      Resource attributes for a config: detected < configured attributes < service fields (service.name, service.version, deployment.environment.name and the older deployment.environment).
      Parameters:
      config - collector config
      detector - resource detector
      Returns:
      a new map
    • initTelemetry

      public static TelemetryHandle initTelemetry(OtelCollectorConfig config, TelemetryOptions options)
      Starts telemetry. Signals follow the config (traces / logs / metrics, OTEL_SDK_DISABLED, OTEL_<SIGNAL>_EXPORTER=none) unless the options turn them on or off. Exporter failures never throw at the caller.
      Parameters:
      config - collector config
      options - options
      Returns:
      the handle
      Throws:
      ConfigException - for invalid settings or when a global OpenTelemetry already exists