Skip to main content
Version: In development — v0.2.3

Observability

colibri.InitializeApp() enables OpenTelemetry when OTEL_EXPORTER_OTLP_ENDPOINT is configured.

Configure export

OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
OTEL_SERVICE_NAME=school-module

Provide the base URL without /v1/traces or /v1/metrics; the SDK appends the signal paths.

Create a manual trace

import (
"github.com/colibriproject-dev/colibri-sdk-go/pkg/base/monitoring"
monitoringbase "github.com/colibriproject-dev/colibri-sdk-go/pkg/base/monitoring/colibri-monitoring-base"
)

transaction, traceCtx := monitoring.StartTransaction(
ctx,
"ProcessOrder",
monitoringbase.SpanKindInternal,
)
defer monitoring.EndTransaction(transaction)

segment := monitoring.StartTransactionSegment(
traceCtx,
"LoadCustomer",
map[string]string{"customer.type": "business"},
)
defer monitoring.EndTransactionSegment(segment)

Use the context returned by StartTransaction for segments and instrumented operations.

Record errors and metrics

if err != nil {
monitoring.NoticeError(transaction, err)
return err
}

Declare counters, histograms, and gauges once, then record values:

orders := monitoring.Counter("orders.processed", "Processed orders", "{order}")
orders.Add(ctx, 1, map[string]string{"status": "success"})

Avoid high-cardinality attributes such as unique IDs, and never export secrets or personal data.