-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc3d892
commit 2674eee
Showing
3 changed files
with
54 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package http | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/labstack/echo/v4" | ||
"go.opentelemetry.io/otel/trace" | ||
) | ||
|
||
// Span returns the current span from the context. | ||
func Span(c echo.Context) (context.Context, trace.Span) { | ||
ctx := c.Request().Context() | ||
span := trace.SpanFromContext(ctx) | ||
return ctx, span | ||
} | ||
|
||
// RecordSpanError records an error ( if any ) for the span. | ||
func RecordSpanError(ctx context.Context, span trace.Span, err error) { | ||
if err != nil { | ||
span.RecordError(err) | ||
} | ||
// Note: we do not end the span here as it is ended in the middleware. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters