Documentation
¶
Index ¶
Constants ¶
const MsgSpanBatch uint16 = 1
MsgSpanBatch is the ZAP MsgType that carries a SpanBatch payload.
Stable wire ID for the trace transport on the ZAP bus. Append-only — renumbering breaks every deployed collector in lockstep.
Variables ¶
This section is empty.
Functions ¶
func NewZAPExporter ¶ added in v1.4.0
func NewZAPExporter(cfg ExporterConfig, appName, version string) (sdktrace.SpanExporter, error)
NewZAPExporter returns the ZAP span exporter on its own, for a caller that builds its own TracerProvider.
New() is the usual entry point and returns a whole Tracer. A service that needs its own resource attributes on the provider — o11y reads columns off them — wants only the exporter, and this is that seam. Same wire either way: a JSON SpanBatch inside a ZAP envelope, no OTLP, no protobuf, no gRPC.
func ResolveCollectorAddr ¶ added in v1.0.0
ResolveCollectorAddr is a small DX helper for callers that want to set Endpoint by environment variable. It returns the first non-empty value among the env vars listed in fallback order. Empty string if none set — callers should treat that as "use the default 127.0.0.1:4317".
Types ¶
type Config ¶
type Config struct {
ExporterConfig `json:"exporterConfig"`
// The fraction of traces to sample.
// If >= 1 always samples.
// If <= 0 never samples.
TraceSampleRate float64 `json:"traceSampleRate"`
AppName string `json:"appName"`
Version string `json:"version"`
}
type ExporterConfig ¶
type ExporterConfig struct {
Type ExporterType `json:"type"`
// Endpoint to send traces to. If empty, the default endpoint will be used.
Endpoint string `json:"endpoint"`
// Headers to send with traces
Headers map[string]string `json:"headers"`
// If true, don't use TLS
Insecure bool `json:"insecure"`
}
type ExporterType ¶
type ExporterType byte
const ( Disabled ExporterType = iota ZAP )
Exporters this package can construct. ZAP is the transport; there is no other. gRPC, HTTP/protobuf and OTLP are not options here — a build of this package pulls none of them.
func ExporterTypeFromString ¶
func ExporterTypeFromString(exporterTypeStr string) (ExporterType, error)
func (ExporterType) MarshalJSON ¶
func (t ExporterType) MarshalJSON() ([]byte, error)
func (ExporterType) String ¶
func (t ExporterType) String() string
func (*ExporterType) UnmarshalJSON ¶
func (t *ExporterType) UnmarshalJSON(b []byte) error
type Span ¶ added in v1.0.0
type Span struct {
TraceID string `json:"traceId"`
SpanID string `json:"spanId"`
ParentSpanID string `json:"parentSpanId,omitempty"`
Name string `json:"name"`
Kind string `json:"kind,omitempty"`
StartUnixNs int64 `json:"startUnixNs"`
EndUnixNs int64 `json:"endUnixNs"`
Attributes map[string]any `json:"attributes,omitempty"`
Events []SpanEvent `json:"events,omitempty"`
StatusCode string `json:"statusCode,omitempty"`
StatusMsg string `json:"statusMessage,omitempty"`
}
Span is the wire shape for a single OTel ReadOnlySpan.
type SpanBatch ¶ added in v1.0.0
type SpanBatch struct {
AppName string `json:"appName,omitempty"`
Version string `json:"version,omitempty"`
Resource map[string]string `json:"resource,omitempty"`
Spans []Span `json:"spans"`
}
SpanBatch is the JSON shape that rides inside the ZAP envelope's payload field. One batch per ExportSpans call.
type Tracer ¶
var Noop Tracer = noOpTracer{}
func New ¶
New returns a Tracer configured per config.
ExporterConfig.Type semantics:
- Disabled → Noop tracer, zero allocations on span ops.
- ZAP → ZAP-native exporter — the only real export path. Ships spans as JSON inside ZAP envelopes to a collector at config.Endpoint (default 127.0.0.1:4317). No protobuf, no OTLP, no grpc.
- anything else → removed. Returns an error directing callers to ZAP.