Documentation
¶
Index ¶
- Variables
- type AppInfo
- type Config
- type OpenTelemetry
- type Options
- type Span
- func (s *Span) AddEvent(name string, attrs ...map[string]interface{})
- func (s *Span) End(enableStackTrace ...bool)
- func (s *Span) RecordError(err error, attrs ...map[string]interface{})
- func (s *Span) SetAttribute(key, value string)
- func (s *Span) SetAttributes(attrs map[string]interface{})
- func (s *Span) SetName(name string)
- func (s *Span) SetStatus(code uint32, description string)
Constants ¶
This section is empty.
Variables ¶
var ErrOTLPEndpointRequired = errors.New("endpoint must be provided")
var ErrUnsupportedEndpoint = errors.New("unsupported: Endpoint must contain port 4318 (HTTP) or 4317 (gRPC)")
Functions ¶
This section is empty.
Types ¶
type OpenTelemetry ¶
type OpenTelemetry struct {
// contains filtered or unexported fields
}
OpenTelemetry encapsulates the OpenTelemetry components required for distributed tracing. It provides a tracer instance for span creation and a tracer provider for managing lifecycle and configurations. This struct facilitates the seamless integration of OpenTelemetry into applications.
func New ¶
func New(ops Options) *OpenTelemetry
New creates a new instance of OpenTelemetry with the provided configuration.
func (*OpenTelemetry) Configure ¶
func (o *OpenTelemetry) Configure() error
Configure initializes the OpenTelemetry by setting up the tracer provider and exporter.
type Span ¶
type Span struct {
// contains filtered or unexported fields
}
Span wraps a trace.Span and provides additional utility methods to manage and enrich the span with attributes, events, and errors.
func (*Span) AddEvent ¶
AddEvent adds an event to the span, optionally with attributes. Attributes can be provided as one or more maps of key-value pairs. If no attributes are provided, only the event name is added.
func (*Span) End ¶
End ends the span, optionally enabling stack trace capture. If no argument is provided, stack trace capture is disabled by default.
func (*Span) RecordError ¶
RecordError records an error on the span, optionally with attributes. Attributes can be provided as one or more maps of key-value pairs. This is useful for adding context to the error being recorded.
func (*Span) SetAttribute ¶
SetAttribute set attribute on the span. Attribute are passed as key-value pair and converted into OpenTelemetry-compatible attribute.
func (*Span) SetAttributes ¶
SetAttributes sets multiple attributes on the span. Attributes are passed as a map of key-value pairs and are converted into OpenTelemetry-compatible attributes.