Skip to content

Commit

Permalink
Also log the traceid alongside the request id (owncloud#8023)
Browse files Browse the repository at this point in the history
* Also log the traceid alongside the request id

* Add changelog
  • Loading branch information
aduffeck authored and 2403905 committed Jan 24, 2024
1 parent 07dc6e3 commit 7917fa7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/unreleased/fix-empty-traceids.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Bugfix: Fix empty trace ids

We changed the default tracing to produce non-empty traceids.

https://github.com/owncloud/ocis/pull/8023
https://github.com/owncloud/ocis/pull/8017
3 changes: 3 additions & 0 deletions services/proxy/pkg/middleware/accesslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/go-chi/chi/v5/middleware"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"go.opentelemetry.io/otel/trace"
)

// AccessLog is a middleware to log http requests at info level logging.
Expand All @@ -19,9 +20,11 @@ func AccessLog(logger log.Logger) func(http.Handler) http.Handler {
wrap := middleware.NewWrapResponseWriter(w, r.ProtoMajor)
next.ServeHTTP(wrap, r)

spanContext := trace.SpanContextFromContext(r.Context())
logger.Info().
Str("proto", r.Proto).
Str(log.RequestIDString, requestID).
Str("traceid", spanContext.TraceID().String()).
Str("remote-addr", r.RemoteAddr).
Str("method", r.Method).
Int("status", wrap.Status()).
Expand Down

0 comments on commit 7917fa7

Please sign in to comment.