OpenTelemetryTracer

Overview

Config yaml format becomes like below. And the resource specific spec is defined in in the proto format shown in the Resource Definition.

apiVersion: app/v1
kind: OpenTelemetryTracer
metadata:
  name: "default"
  namespace: "default"
spec: {}

Resource Definition

OpenTelemetryTracer is defined in the proto/app/v1/o11y/oteltracer.proto

syntax = "proto3";
package app.v1;

import "buf/validate/validate.proto";
import "kernel/network.proto";
import "kernel/resource.proto";

option go_package = "github.com/aileron-gateway/aileron-gateway/apis/app/v1";

// OpenTelemetryTracer resource definition.
// apiVersion="app/v1", kind="OpenTelemetryTracer".
message OpenTelemetryTracer {
    string                  APIVersion = 1 [json_name = "apiVersion"];
    string                  Kind       = 2 [json_name = "kind"];
    kernel.Metadata         Metadata   = 3 [json_name = "metadata"];
    OpenTelemetryTracerSpec Spec       = 4 [json_name = "spec"];
}

// OpenTelemetryTracerSpec is the specifications for the OpenTelemetryTracer object.
message OpenTelemetryTracerSpec {
    // [OPTIONAL]
    // ServiceName is the value for "service.name" semantic conventions.
    // If not set or empty, a default value is used.
    // Default is ["gateway"].
    string ServiceName = 1 [json_name = "serviceName"];

    // [OPTIONAL]
    // LibraryName is the value for "otel.library.name" in span tags.
    // If empty or not set, go package name is used.
    string LibraryName = 2 [json_name = "libraryName"];

    // [OPTIONAL]
    // PropagationTypes are the types of trace context propagators.
    // If not set, default values are used.
    // Default list is [W3CTraceContext, W3CBaggage].
    repeated PropagationType PropagationTypes = 3 [json_name = "propagationTypes"];

    // [OPTIONAL]
    // TraceIDRatioBased samples a given fraction of traces.
    // Fractions >= 1 will always sample.
    // Fractions < 0 are treated as zero.
    // Default is [1.0], or sample all.
    float TraceIDRatioBased = 4 [json_name = "traceIDRatioBased"];

    // [OPTIONAL]
    // TracerProviderBatch is the batch configuration for span processors.
    // Default configuration is used if not set.
    TracerProviderBatchSpec TracerProviderBatch = 5 [json_name = "tracerProviderBatch"];

    // [OPTIONAL]
    // TracerProviderLimit is the limit configuration for span processors.
    // Default configuration is used if not set.
    TracerProviderLimitSpec TracerProviderLimit = 6 [json_name = "tracerProviderLimit"];

    // [OPTIONAL]
    // Headers are the http header names that are added to the span attributes.
    // Default is not set.
    repeated string Headers = 7 [json_name = "headers"];

    oneof Exporters {
        HTTPTraceExporterSpec   HTTPExporterSpec   = 10 [json_name = "httpExporter"];
        GRPCTraceExporterSpec   GRPCExporterSpec   = 11 [json_name = "grpcExporter"];
        StdoutTraceExporterSpec StdoutExporterSpec = 12 [json_name = "stdoutExporter"];
        ZipkinTraceExporterSpec ZipkinExporterSpec = 13 [json_name = "zipkinExporter"];
    }
}

enum PropagationType {
    W3CTraceContext = 0;  // W3C Trace Context format
    W3CBaggage      = 1;  // W3C Baggage format
    B3              = 2;  // B3 format
    Jaeger          = 3;  // Jaeger format
    XRay            = 4;  // AWS X-Ray format
    OpenCensus      = 5;  // OpenCensus Binary format
    OpenTracing     = 6;  // OpenTracing format
}

message TracerProviderBatchSpec {
    // [OPTIONAL]
    // MaxQueueSize the maximum queue size allowed for a BatchSpanProcessor.
    // Default is [2048].
    int32 MaxQueueSize = 1 [json_name = "maxQueueSize"];

    // [OPTIONAL]
    // BatchTimeout is the maximum delay in seconds allowed for a BatchSpanProcessor
    // before it will export any held span (whether the queue is full or not).
    // Default is [5] seconds.
    int32 BatchTimeout = 2 [json_name = "batchTimeout"];

    // [OPTIONAL]
    // ExportTimeout is the amount of time a BatchSpanProcessor waits for an exporter
    // to export before abandoning the export.
    // Default is [30] seconds.
    int32 ExportTimeout = 3 [json_name = "exportTimeout"];

    // [OPTIONAL]
    // MaxExportBatchSize is the maximum export batch size allowed for a BatchSpanProcessor.
    // Default is [512].
    int32 MaxExportBatchSize = 4 [json_name = "maxExportBatchSize"];

    // [OPTIONAL]
    // Blocking, if true, wait for enqueue operations to succeed
    // instead of dropping data when the queue is full.
    // Default is [false].
    bool Blocking = 5 [json_name = "blocking"];
}

message TracerProviderLimitSpec {
    // [OPTIONAL]
    // AttributeValueLengthLimit is the maximum allowed attribute value length.
    // This limit only applies to string and string slice attribute values.
    // Any string longer than this value will be truncated to this length.
    // Setting this to a negative value means no limit is applied.
    // Zero is the same with default value.
    // Default is [-1].
    int32 AttributeValueLengthLimit = 1 [json_name = "attributeValueLengthLimit"];

    // [OPTIONAL]
    // AttributeCountLimit is the maximum allowed span attribute count.
    // Any attribute added to a span once this limit is reached will be dropped.
    // Setting this to a negative value means no limit is applied.
    // Zero is the same with default value.
    // Default is [-1].
    int32 AttributeCountLimit = 2 [json_name = "attributeCountLimit"];

    // [OPTIONAL]
    // EventCountLimit is the maximum allowed span event count.
    // Any event added to a span once this limit is reached means it will be added but the oldest event will be dropped.
    // Setting this to a negative value means no limit is applied.
    // Zero is the same with default value.
    // Default is [-1].
    int32 EventCountLimit = 3 [json_name = "eventCountLimit"];

    // [OPTIONAL]
    // LinkCountLimit is the maximum allowed span link count.
    // Any link added to a span once this limit is reached means it will be added but the oldest link will be dropped.
    // Setting this to a negative value means no limit is applied.
    // Zero is the same with default value.
    // Default is [-1].
    int32 LinkCountLimit = 4 [json_name = "linkCountLimit"];

    // [OPTIONAL]
    // AttributePerEventCountLimit is the maximum number of attributes allowed per span event.
    // Any attribute added after this limit reached will be dropped.
    // Setting this to a negative value means no limit is applied.
    // Zero is the same with default value.
    // Default is [-1].
    int32 AttributePerEventCountLimit = 5 [json_name = "attributePerEventCountLimit"];

    // [OPTIONAL]
    // AttributePerLinkCountLimit is the maximum number of attributes allowed per span link.
    // Any attribute added after this limit reached will be dropped.
    // Setting this to a negative value means no limit is applied.
    // Zero is the same with default value.
    // Default is [-1].
    int32 AttributePerLinkCountLimit = 6 [json_name = "attributePerLinkCountLimit"];
}

message HTTPTraceExporterSpec {
    // [OPTIONAL]
    // EndpointURL is the target endpoint URL (scheme, host, port, path)
    // the Exporter will connect to.
    // If the OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_TRACES_ENDPOINT environment variable is set,
    // and this option is not passed, that variable value will be used.
    // If both environment variables are set, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT will take precedence.
    // If an environment variable is set, and this option is passed, this option will take precedence.
    // if an environment variable is not set, and this option is not passed, "localhost:4318" will be used.
    // Default is not set.
    string EndpointURL = 1 [json_name = "endpointURL"];

    // [OPTIONAL]
    // Headers is the additional HTTP headers sent with payloads.
    // Default is not set.
    map<string, string> Headers = 2 [json_name = "headers"];

    // [OPTIONAL]
    // Compress is the flag to compress data when sending to collectors.
    // Default is [false.]
    bool Compress = 3 [json_name = "compress"];

    // [OPTIONAL]
    // Insecure is the flag use HTTP instead of HTTPS.
    // Default is [false].
    bool Insecure = 4 [json_name = "insecure"];

    // [OPTIONAL]
    // TLSConfig is the TLS configuration to use when connecting backend using HTTPS.
    // Default is not set.
    kernel.TLSConfig TLSConfig = 5 [json_name = "tlsConfig"];

    // [OPTIONAL]
    // Timeout is the timeout seconds of the driver's the max waiting time for
    // the backend to process each spans batch.
    // If zero or negative, or not set, the default will be 10 seconds.
    // Default is not set.
    int32 Timeout = 6 [json_name = "timeout"];

    // [OPTIONAL]
    // OTLPRetry is the retry policy for transient retryable errors that may be returned
    // by the target endpoint when exporting a batch of spans.
    // If not set, the default retry policy will be used.
    // It will retry the export 5 seconds after receiving a retryable error and
    // increase exponentially after each error for no more than a total time of 1 minute.
    // Default is not set.
    OTLPTraceRetrySpec OTLPRetry = 7 [json_name = "otlpRetry"];
}

message GRPCTraceExporterSpec {
    // [OPTIONAL]
    // EndpointURL is the target endpoint URL (scheme, host, port, path)
    // the Exporter will connect to.
    // If the OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_TRACES_ENDPOINT environment variable is set,
    // and this option is not passed, that variable value will be used.
    // If both environment variables are set, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT will take precedence.
    // If an environment variable is set, and this option is passed, this option will take precedence.
    // if an environment variable is not set, and this option is not passed, "localhost:4317" will be used.
    // Default is not set.
    string EndpointURL = 1 [json_name = "endpointURL"];

    // [OPTIONAL]
    // Headers is the additional HTTP headers sent with payloads.
    // Default is not set.
    map<string, string> Headers = 2 [json_name = "headers"];

    // [OPTIONAL]
    // Compress is the flag to compress data when sending to collectors.
    // Default is [false.]
    bool Compress = 3 [json_name = "compress"];

    // [OPTIONAL]
    // Insecure is the flag use HTTP instead of HTTPS.
    // Default is [false].
    bool Insecure = 4 [json_name = "insecure"];

    // [OPTIONAL]
    // TLSConfig is the TLS configuration to use
    // when connecting backend using HTTPS.
    // Default is not set.
    kernel.TLSConfig TLSConfig = 5 [json_name = "tlsConfig"];

    // [OPTIONAL]
    // Timeout is the timeout seconds of the driver's the max waiting time for
    // the backend to process each spans batch.
    // If zero or negative, or not set, the default will be 10 seconds.
    // Default is not set.
    int32 Timeout = 6 [json_name = "timeout"];

    // [OPTIONAL]
    // OTLPRetry is the retry policy for transient retryable errors that may be returned
    // by the target endpoint when exporting a batch of spans.
    // If the target endpoint responds with not only a retryable error,
    // but explicitly returns a backoff time in the response.
    // That time will take precedence over these settings.
    // These settings do not define any network retry strategy.
    // That is entirely handled by the gRPC ClientConn.
    // If not set, the default retry policy will be used.
    // It will retry the export 5 seconds after receiving a retryable error and
    // increase exponentially after each error for no more than a total time of 1 minute.
    // Default is not set.
    OTLPTraceRetrySpec OTLPRetry = 7 [json_name = "otlpRetry"];

    // [OPTIONAL]
    // ReconnectionPeriod is the minimum amount of time in seconds
    // between connection attempts to the target endpoint.
    // If zero or negative, or not set, this option has no effect.
    // Default is not set.
    int32 ReconnectionPeriod = 8 [json_name = "reconnectionPeriod"];

    // [OPTIONAL]
    // ServiceConfig is the gRPC service config string.
    // See https://github.com/grpc/grpc/blob/master/doc/service_config.md
    // Default is not set.
    string ServiceConfig = 9 [json_name = "serviceConfig"];
}

message StdoutTraceExporterSpec {
    // [OPTIONAL]
    // PrettyPrint is the flag to prettifies the emitted output.
    // Default is [false].
    bool PrettyPrint = 1 [json_name = "prettyPrint"];

    // [OPTIONAL]
    // WithoutTimestamps is the flag to make the export stream not include timestamps.
    // Default is [false].
    bool WithoutTimestamps = 2 [json_name = "withoutTimestamps"];
}

message ZipkinTraceExporterSpec {
    // [OPTIONAL]
    // Headers configures the exporter to use the configured HTTP request headers.
    // Default is not set.
    map<string, string> Headers = 1 [json_name = "headers"];

    // [OPTIONAL]
    // EndpointURL is the url of a collector.
    // Environmental variable OTEL_EXPORTER_ZIPKIN_ENDPOINT overrides this value.
    // If not set or empty, following default value is used.
    // "http://localhost:9411/api/v2/spans".
    // Default is not set.
    string EndpointURL = 2 [json_name = "endpointURL"];
}

message OTLPTraceRetrySpec {
    // [OPTIONAL]
    // Enabled indicates whether to not retry sending batches in case of export failure.
    // Default is [false].
    bool Enabled = 1 [json_name = "enabled"];

    // [OPTIONAL]
    // InitialInterval is the time to wait after the first failure before retrying.
    // Value is in seconds.
    // If zero or not set, default value is used.
    // Default is not set.
    int32 InitialInterval = 2 [json_name = "initialInterval", (buf.validate.field).int32 = {gte : 0, lte : 600}];

    // [OPTIONAL]
    // MaxInterval is the upper bound on backoff interval.
    // Once this value is reached the delay between consecutive retries will always be `MaxInterval`.
    // Value is in seconds.
    // If zero or not set, default value is used.
    // Default is not set.
    int32 MaxInterval = 3 [json_name = "maxInterval", (buf.validate.field).int32 = {gte : 0, lte : 600}];

    // [OPTIONAL]
    // MaxElapsedTime is the maximum amount of time (including retries) spent trying to send a request/batch.
    // Once this value is reached, the data is discarded.
    // Value is in seconds.
    // If zero or not set, default value is used.
    // Default is not set.
    int32 MaxElapsedTime = 4 [json_name = "maxElapsedTime", (buf.validate.field).int32 = {gte : 0, lte : 1800}];
}

message K8sAttributesSpec {
    string ClusterName           = 1 [json_name = "clusterName"];
    string ContainerName         = 2 [json_name = "containerName"];
    string ContainerRestartCount = 3 [json_name = "containerRestartCount"];
    string CronJobName           = 4 [json_name = "cronJobName"];
    string CronJobUID            = 5 [json_name = "cronJobUID"];
    string DaemonSetName         = 6 [json_name = "daemonSetName"];
    string DaemonSetUID          = 7 [json_name = "daemonSetUID"];
    string DeploymentName        = 8 [json_name = "deploymentName"];
    string DeploymentUID         = 9 [json_name = "deploymentUID"];
    string JobName               = 10 [json_name = "jobName"];
    string JobUID                = 11 [json_name = "jobUID"];
    string NamespaceName         = 12 [json_name = "namespaceName"];
    string NodeName              = 13 [json_name = "nodeName"];
    string NodeUID               = 14 [json_name = "nodeUID"];
    string PodName               = 15 [json_name = "podName"];
    string PodUID                = 16 [json_name = "podUID"];
    string ReplicaSetName        = 17 [json_name = "replicaSetName"];
    string ReplicaSetUID         = 18 [json_name = "replicaSetUID"];
    string StatefulSetName       = 19 [json_name = "statefulSetName"];
    string StatefulSetUID        = 20 [json_name = "statefulSetUID"];
}

message ContainerAttributesSpec {
    string ID        = 1 [json_name = "id"];
    string ImageName = 2 [json_name = "imageName"];
    string ImageTag  = 3 [json_name = "imageTag"];
    string Name      = 4 [json_name = "name"];
    string Runtime   = 5 [json_name = "runtime"];
}

message HostAttributesSpec {
    string ID           = 1 [json_name = "id"];
    string ImageID      = 2 [json_name = "imageID"];
    string ImageName    = 3 [json_name = "imageName"];
    string ImageVersion = 4 [json_name = "imageVersion"];
    string Name         = 5 [json_name = "name"];
    string Type         = 6 [json_name = "type"];
}

Last modified June 2, 2025: update docs (df954a4)