Documentation
¶
Overview ¶
The package span provides common utils for working with OpenTelemetry spans.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractTrace ¶
ExtractTrace extracts the trace and span IDs from the current span in the context.
This function retrieves the trace ID and span ID from the active OpenTelemetry span associated with the provided context. If a valid trace or span ID is not present, or if the span is not currently recording, it returns false, indicating that tracing information was not found. When found, it returns the trace ID, span ID, and a boolean indicating success.
Returns:
- traceID: A string representation of the trace ID.
- spanID: A string representation of the span ID.
- found: A boolean indicating whether trace and span IDs were successfully extracted.
Types ¶
type Span ¶
Span is a wrapper around oteltrace.Span
It is used to provide a more convenient API with extra functionality
func GetSpanFromContext ¶
GetSpanFromContext retrieves the current OpenTelemetry span from the context.
This allows access to tracing information within that context. If no span is associated with the context, it returns a non-recording span, which is a placeholder that performs no operations. This is useful for tracing operations where span context is required.
Returns the custom Span type.
func (*Span) EndSuccessfully ¶
func (s *Span) EndSuccessfully()
EndSuccessfully ends the span by updating the status to Ok
func (*Span) EndWithError ¶
EndWithError ends the span by updating the status to Error and recording the error