Use spans to measure the timing of specific operations within a transaction. Each span represents a unit of work such as a database query, HTTP call, or custom processing.

Required Imports

1. StartSpan

Use StartSpan() to create a custom span. You must call End() to complete the span.

Syntax

Parameter

Example

2. CaptureSpan

Use CaptureSpan() to create a span with automatic lifecycle management. The span ends automatically when the callback completes.

Syntax

Parameter

Example

3. CurrentSpan

Use CurrentSpan to access the active span within the current execution context.

Syntax

Example

See also