traceparent

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package traceparent contains a lightweight implementation of W3C traceparent parsing, loading from files and environment, and the reverse.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Traceparent

type Traceparent struct {
	Version     int
	TraceId     []byte
	SpanId      []byte
	Sampling    bool
	Initialized bool
}

Traceparent represents a parsed W3C traceparent.

func LoadFromEnv

func LoadFromEnv() (Traceparent, error)

LoadFromEnv loads the traceparent from the environment variable TRACEPARENT and sets it in the returned Go context.

func LoadFromFile

func LoadFromFile(filename string) (Traceparent, error)

LoadFromFile reads a traceparent from filename and returns a context with the traceparent set. The format for the file as written is just a bare traceparent string. Whitespace, "export " and "TRACEPARENT=" are stripped automatically so the file can also be a valid shell snippet.

func Parse

func Parse(tp string) (Traceparent, error)

Parse parses a string traceparent and returns the struct.

func (Traceparent) Encode

func (tp Traceparent) Encode() string

Encode returns the traceparent as a W3C formatted string.

func (Traceparent) Fprint

func (tp Traceparent) Fprint(target io.Writer, export bool) error

Fprint formats a traceparent into otel-cli's shell-compatible text format. If the second/export param is true, the statement will be prepended with "export " so it can be easily sourced in a shell script.

func (Traceparent) SaveToFile

func (tp Traceparent) SaveToFile(carrierFile string, export bool) error

SaveToFile takes a context and filename and writes the tp from that context into the specified file.

func (Traceparent) SpanIdString

func (tp Traceparent) SpanIdString() string

SpanIdString returns the span id in string form.

func (Traceparent) TraceIdString

func (tp Traceparent) TraceIdString() string

TraceIdString returns the trace id in string form.

Jump to

Keyboard shortcuts

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