Skip to content

Commit

Permalink
add cannary info to access log.
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Mar 27, 2020
1 parent 9bb94a7 commit d67f681
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/middlewares/canary/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/containous/traefik/v2/pkg/config/dynamic"
"github.com/containous/traefik/v2/pkg/log"
"github.com/containous/traefik/v2/pkg/middlewares"
"github.com/containous/traefik/v2/pkg/middlewares/accesslog"
"github.com/containous/traefik/v2/pkg/tracing"
"github.com/opentracing/opentracing-go/ext"
)
Expand Down Expand Up @@ -81,6 +82,15 @@ func (c *Canary) GetTracingInformation() (string, ext.SpanKindEnum) {
func (c *Canary) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
c.processRequestID(rw, req)
c.processCanary(rw, req)

if logData := accesslog.GetLogData(req); logData != nil {
if requestID := req.Header.Get(headerXRequestID); requestID != "" {
logData.Core["XRequestID"] = requestID
}
if xCanary := req.Header.Values(headerXCanary); len(xCanary) > 0 {
logData.Core["XCanary"] = xCanary
}
}
c.next.ServeHTTP(rw, req)
}

Expand Down

0 comments on commit d67f681

Please sign in to comment.