Skip to content

Commit

Permalink
feat: span, span everywhere
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Oct 9, 2022
1 parent b4113d6 commit f86c0f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pkg/crud/browse.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ import (
"github.com/ViBiOh/httputils/v4/pkg/concurrent"
"github.com/ViBiOh/httputils/v4/pkg/logger"
"github.com/ViBiOh/httputils/v4/pkg/renderer"
"github.com/ViBiOh/httputils/v4/pkg/tracer"
"go.opentelemetry.io/otel/trace"
)

func (a App) browse(ctx context.Context, request provider.Request, item absto.Item, message renderer.Message) (renderer.Page, error) {
ctx, end := tracer.StartSpan(ctx, a.tracer, "browse", trace.WithSpanKind(trace.SpanKindInternal))
defer end()

var (
previous provider.RenderItem
next provider.RenderItem
Expand Down Expand Up @@ -63,6 +68,9 @@ func (a App) browse(ctx context.Context, request provider.Request, item absto.It
}

func (a App) getFilesPreviousAndNext(ctx context.Context, item absto.Item, request provider.Request) (items []absto.Item, previous provider.RenderItem, next provider.RenderItem) {
ctx, end := tracer.StartSpan(ctx, a.tracer, "get_previous_next", trace.WithSpanKind(trace.SpanKindInternal))
defer end()

var err error
items, err = a.storageApp.List(ctx, item.Dir())
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion pkg/crud/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func (a App) handleFile(w http.ResponseWriter, r *http.Request, request provider
}

func (a App) serveFile(w http.ResponseWriter, r *http.Request, item absto.Item) error {
_, end := tracer.StartSpan(r.Context(), a.tracer, "file", trace.WithSpanKind(trace.SpanKindInternal))
defer end()

etag, ok := provider.EtagMatch(w, r, sha.New(item))
if ok {
return nil
Expand Down Expand Up @@ -178,7 +181,7 @@ func (a App) serveGeoJSON(w http.ResponseWriter, r *http.Request, request provid
return
}

ctx, end := tracer.StartSpan(r.Context(), a.tracer, "geojson")
ctx, end := tracer.StartSpan(r.Context(), a.tracer, "geojson", trace.WithSpanKind(trace.SpanKindInternal))
defer end()

var hash string
Expand Down

0 comments on commit f86c0f4

Please sign in to comment.