span

package
v0.1.99 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCanonicalField

func IsCanonicalField(name string) bool

IsCanonicalField reports whether a mapping target belongs to the canonical model.

func Unwrap added in v0.1.95

func Unwrap(document map[string]any, rules []UnwrapRule) error

Unwrap rewrites each rule's field in place. A field the document does not carry is skipped — on a scan, a span without it is ordinary — while a field holding something other than the declared shape is an error naming it.

func ValidMappingUnit

func ValidMappingUnit(unit string) bool

func ValidateUnwrap added in v0.1.95

func ValidateUnwrap(rules []UnwrapRule) error

ValidateUnwrap refuses a rule without a field or with a kind Unwrap does not know.

Types

type Options

type Options struct {
	Format                                              string
	DateField, TraceIDField, SpanIDField, ParentIDField string
	ServiceField, OperationField, ParentRefType         string
	StatusFields                                        []string
}

type PreviewStatus added in v0.1.95

type PreviewStatus string

PreviewStatus is what a rule did to its field in a sample.

const (
	// PreviewApplied: the field was unwrapped; Before and After hold both shapes.
	PreviewApplied PreviewStatus = "applied"
	// PreviewFailed: the field holds something other than the declared shape;
	// Before is that value and Error is exactly what Unwrap raised.
	PreviewFailed PreviewStatus = "failed"
	// PreviewMissing: no sampled document carries the field.
	PreviewMissing PreviewStatus = "missing"
	// PreviewInvalid: the rule itself is refused by ValidateUnwrap.
	PreviewInvalid PreviewStatus = "invalid"
)

type RulePreview added in v0.1.95

type RulePreview struct {
	Rule   UnwrapRule    `json:"rule"`
	Status PreviewStatus `json:"status"`
	// Row is the index of the document the preview was read from.
	Row    int    `json:"row"`
	Before any    `json:"before,omitempty"`
	After  any    `json:"after,omitempty"`
	Error  string `json:"error,omitempty"`
}

RulePreview is one rule's effect on the first sampled document that carries its field.

func PreviewUnwrap added in v0.1.95

func PreviewUnwrap(documents []map[string]any, rules []UnwrapRule) []RulePreview

PreviewUnwrap runs the rules over copies of the documents, in order and through Unwrap itself, and reports for each rule what it did where it first applied. A later rule therefore reads what an earlier one produced, as it does when the provider reads a document; a document a rule fails on stops there, as a scan would stop. The documents given are not modified.

type Span

type Span struct {
	TraceID    string          `json:"traceId"`
	SpanID     string          `json:"spanId"`
	ParentID   string          `json:"parentId,omitempty"`
	StartedAt  time.Time       `json:"startedAt"`
	DurationMs float64         `json:"durationMs"`
	Service    string          `json:"service"`
	Operation  string          `json:"operation"`
	Status     string          `json:"status"`
	Kind       string          `json:"kind,omitempty"`
	Attributes map[string]any  `json:"attributes,omitempty"`
	Resource   map[string]any  `json:"resource,omitempty"`
	OTLP       json.RawMessage `json:"otlp,omitempty"`
}

func Normalize

func Normalize(d map[string]any, o Options) (Span, error)

func NormalizeMapped

func NormalizeMapped(document map[string]any, values map[string]any, units map[string]string) (Span, error)

func (Span) Row

func (s Span) Row() map[string]any

type UnwrapKind added in v0.1.95

type UnwrapKind string

UnwrapKind is how a span document field is unwrapped before normalization.

const (
	// UnwrapKeyValues turns a list of {key, value} entries — Jaeger's tags, an
	// OTLP attribute list, either one JSON-encoded — into an object keyed by key.
	UnwrapKeyValues UnwrapKind = "key_values"
	// UnwrapJSON decodes a field holding JSON text into the value it encodes.
	UnwrapJSON UnwrapKind = "json"
)

type UnwrapRule added in v0.1.95

type UnwrapRule struct {
	Field string     `json:"field" yaml:"field"`
	As    UnwrapKind `json:"as" yaml:"as"`
}

UnwrapRule names one document field and how to unwrap it. Field is a top-level key, or a dotted path into nested objects.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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