ciallo-otel

    W3C traceparent/tracestate propagation, TracingHttpClient decorator, and async batch OTLP/HTTP JSON exporter with Lifecycle flush for unmbt/ciallo

    opentelemetry
    otel
    otlp
    traceparent
    tracing
    ciallo
    Download zip
    Author
    Version
    0.1.1
    License
    MIT
    Last updated
    13 hours ago
    Downloads
    7

    #unmbt/ciallo-otel

    W3C traceparent/tracestate OpenTelemetry instrumentation, TracingHttpClient, and async batch OTLP/HTTP JSON exporter with Lifecycle::on_stop flushing for unmbt/ciallo.

    OtelBundle

    pub struct OtelBundle {
    exporter : OtlpBatchExporter
    clock : &
    Clock

    }

    CapabilityBundle recording server spans for every handled request and registering OtlpBatchExporter for graceful shutdown flushing.

    OtelBundle::OtelBundle

    OtelSpan

    pub(all) struct OtelSpan {
    trace_id : String
    span_id : String
    parent_span_id : String?
    name : String
    kind : SpanKind
    start_time_unix_nano : Int64
    end_time_unix_nano : Int64
    status : SpanStatus
    attributes : Map[String, String]
    } derive(Eq,
    Debug
    )

    OtelSpan::to_otlp_json

    OtlpBatchExporter

    pub struct OtlpBatchExporter {
    endpoint : String
    resource : ResourceInfo
    http_client : &
    HttpClient

    max_batch_size : Int
    headers : Map[String, String]
    pending : Array[OtelSpan]
    exported_count : Int64
    }

    Async batch OTLP/HTTP JSON exporter implementing @runtime.Lifecycle.

    OtlpBatchExporter::OtlpBatchExporter

    fn OtlpBatchExporter::OtlpBatchExporter(endpoint? : String, resource~ : ResourceInfo, http_client~ : &
    HttpClient
    , max_batch_size? : Int, headers? : Map[String, String]) -> OtlpBatchExporter

    OtlpBatchExporter::enqueue

    fn OtlpBatchExporter::enqueue(self : OtlpBatchExporter, span : OtelSpan) -> Unit

    OtlpBatchExporter::exported_count

    fn OtlpBatchExporter::exported_count(self : OtlpBatchExporter) -> Int64

    OtlpBatchExporter::flush

    async fn OtlpBatchExporter::flush(self : OtlpBatchExporter) -> Unit noraise

    OtlpBatchExporter::pending_count

    fn OtlpBatchExporter::pending_count(self : OtlpBatchExporter) -> Int

    OtlpBatchExporter::record

    async fn OtlpBatchExporter::record(self : OtlpBatchExporter, span : OtelSpan) -> Unit noraise

    ResourceInfo

    pub(all) struct ResourceInfo {
    service_name : String
    service_version : String
    environment : String
    } derive(Eq,
    Debug
    )

    ResourceInfo::ResourceInfo

    fn ResourceInfo::ResourceInfo(service_name~ : String, service_version? : String, environment? : String) -> ResourceInfo

    SpanKind

    pub(all) enum SpanKind {
    Internal
    Server
    Client
    Producer
    Consumer
    } derive(Eq,
    Debug
    )

    SpanKind::otlp_code

    fn SpanKind::otlp_code(self : SpanKind) -> Int

    SpanStatus

    pub(all) enum SpanStatus {
    Unset
    Ok
    Error(String)
    } derive(Eq,
    Debug
    )

    TracingHttpClient

    Outbound @runtime.HttpClient decorator that creates a W3C child span, injects traceparent / tracestate, and records the client span into OtlpBatchExporter.

    TracingHttpClient::TracingHttpClient

    encode_otlp_payload

    fn encode_otlp_payload(resource : ResourceInfo, spans : Array[OtelSpan]) ->
    Json

    Encodes a batch of spans into standard OTLP/HTTP JSON (resourceSpans).