otlp

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttributeMap

func AttributeMap(attrs []KeyValue) map[string]string

AttributeMap converts a slice of KeyValue pairs to a map[string]string.

func ResourceServiceName

func ResourceServiceName(r Resource) string

ResourceServiceName extracts the "service.name" attribute from a Resource. Returns "unknown" if not found.

Types

type AnyValue

type AnyValue struct {
	StringValue *string  `json:"stringValue,omitempty"`
	IntValue    *string  `json:"intValue,omitempty"` // JSON encodes int64 as string
	DoubleValue *float64 `json:"doubleValue,omitempty"`
	BoolValue   *bool    `json:"boolValue,omitempty"`
}

AnyValue is an OTLP polymorphic value.

func (AnyValue) StringVal

func (v AnyValue) StringVal() string

StringVal returns the string representation of the value.

type ExportLogsRequest

type ExportLogsRequest struct {
	ResourceLogs []ResourceLog `json:"resourceLogs"`
}

ExportLogsRequest is the top-level OTLP logs export payload.

type ExportMetricsRequest

type ExportMetricsRequest struct {
	ResourceMetrics []ResourceMetric `json:"resourceMetrics"`
}

ExportMetricsRequest is the top-level OTLP metrics export payload.

type ExportTraceRequest

type ExportTraceRequest struct {
	ResourceSpans []ResourceSpan `json:"resourceSpans"`
}

ExportTraceRequest is the top-level OTLP trace export payload.

type Gauge

type Gauge struct {
	DataPoints []NumberDataPoint `json:"dataPoints"`
}

Gauge represents a gauge metric.

type Histogram

type Histogram struct {
	DataPoints             []HistogramDataPoint `json:"dataPoints"`
	AggregationTemporality int                  `json:"aggregationTemporality"`
}

Histogram represents a histogram metric.

type HistogramDataPoint

type HistogramDataPoint struct {
	Attributes     []KeyValue `json:"attributes"`
	TimeUnixNano   string     `json:"timeUnixNano"`
	Count          uint64     `json:"count"`
	Sum            *float64   `json:"sum,omitempty"`
	BucketCounts   []uint64   `json:"bucketCounts"`
	ExplicitBounds []float64  `json:"explicitBounds"`
	Min            *float64   `json:"min,omitempty"`
	Max            *float64   `json:"max,omitempty"`
}

HistogramDataPoint is a single data point for histogram metrics.

type InstrumentationScope

type InstrumentationScope struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

InstrumentationScope identifies the instrumentation library.

type KeyValue

type KeyValue struct {
	Key   string   `json:"key"`
	Value AnyValue `json:"value"`
}

KeyValue is an OTLP attribute key-value pair.

type LogRecord

type LogRecord struct {
	TimeUnixNano         string     `json:"timeUnixNano"`
	ObservedTimeUnixNano string     `json:"observedTimeUnixNano"`
	SeverityNumber       int        `json:"severityNumber"`
	SeverityText         string     `json:"severityText"`
	Body                 AnyValue   `json:"body"`
	Attributes           []KeyValue `json:"attributes"`
	TraceID              string     `json:"traceId"`
	SpanID               string     `json:"spanId"`
}

LogRecord represents a single OTLP log record.

type Metric

type Metric struct {
	Name        string     `json:"name"`
	Description string     `json:"description"`
	Unit        string     `json:"unit"`
	Gauge       *Gauge     `json:"gauge,omitempty"`
	Sum         *Sum       `json:"sum,omitempty"`
	Histogram   *Histogram `json:"histogram,omitempty"`
}

Metric represents a single OTLP metric.

type NumberDataPoint

type NumberDataPoint struct {
	Attributes   []KeyValue `json:"attributes"`
	TimeUnixNano string     `json:"timeUnixNano"`
	AsDouble     *float64   `json:"asDouble,omitempty"`
	AsInt        *string    `json:"asInt,omitempty"` // OTLP JSON encodes int64 as string
}

NumberDataPoint is a single data point for gauge/sum metrics.

type Resource

type Resource struct {
	Attributes []KeyValue `json:"attributes"`
}

Resource describes the entity producing telemetry.

type ResourceLog

type ResourceLog struct {
	Resource  Resource   `json:"resource"`
	ScopeLogs []ScopeLog `json:"scopeLogs"`
}

ResourceLog groups log records by originating resource.

type ResourceMetric

type ResourceMetric struct {
	Resource     Resource      `json:"resource"`
	ScopeMetrics []ScopeMetric `json:"scopeMetrics"`
}

ResourceMetric groups metrics by originating resource.

type ResourceSpan

type ResourceSpan struct {
	Resource   Resource    `json:"resource"`
	ScopeSpans []ScopeSpan `json:"scopeSpans"`
}

ResourceSpan groups spans by originating resource.

type ScopeLog

type ScopeLog struct {
	Scope      InstrumentationScope `json:"scope"`
	LogRecords []LogRecord          `json:"logRecords"`
}

ScopeLog groups log records by instrumentation scope.

type ScopeMetric

type ScopeMetric struct {
	Scope   InstrumentationScope `json:"scope"`
	Metrics []Metric             `json:"metrics"`
}

ScopeMetric groups metrics by instrumentation scope.

type ScopeSpan

type ScopeSpan struct {
	Scope InstrumentationScope `json:"scope"`
	Spans []Span               `json:"spans"`
}

ScopeSpan groups spans by instrumentation scope.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server handles OTLP/HTTP ingestion for traces, metrics, and logs.

func NewServer

func NewServer(dp *dataplane.DataPlane, bus *eventbus.Bus, region, accountID string) *Server

NewServer creates a new OTLP HTTP server.

func (*Server) RegisterGRPC

func (s *Server) RegisterGRPC(gs *grpc.Server)

RegisterGRPC registers the OTLP Trace/Metrics/Logs collector services on the given gRPC server. They share the exact ingestion pipeline as the HTTP server: each proto request is rendered to OTLP-JSON via protojson, decoded into the server's existing request structs, and run through convertTraces / ingestMetrics / ingestLogs.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

type Span

type Span struct {
	TraceID           string      `json:"traceId"`
	SpanID            string      `json:"spanId"`
	ParentSpanID      string      `json:"parentSpanId"`
	Name              string      `json:"name"`
	Kind              int         `json:"kind"` // 0=unspecified,1=internal,2=server,3=client,4=producer,5=consumer
	StartTimeUnixNano string      `json:"startTimeUnixNano"`
	EndTimeUnixNano   string      `json:"endTimeUnixNano"`
	Attributes        []KeyValue  `json:"attributes"`
	Status            SpanStatus  `json:"status"`
	Events            []SpanEvent `json:"events"`
}

Span represents a single OTLP span.

type SpanEvent

type SpanEvent struct {
	TimeUnixNano string     `json:"timeUnixNano"`
	Name         string     `json:"name"`
	Attributes   []KeyValue `json:"attributes"`
}

SpanEvent represents a timed event within a span.

type SpanStatus

type SpanStatus struct {
	Code    int    `json:"code"` // 0=unset,1=ok,2=error
	Message string `json:"message"`
}

SpanStatus represents the status of a span.

type Sum

type Sum struct {
	DataPoints             []NumberDataPoint `json:"dataPoints"`
	AggregationTemporality int               `json:"aggregationTemporality"`
	IsMonotonic            bool              `json:"isMonotonic"`
}

Sum represents a sum (counter) metric.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL