Open george-maroun opened 1 year ago
// Example: func LogErrorCallback(ctx context.Context, w http.ResponseWriter, r *http.Request, err error) { log := zapr.NewLogger(zap.L()) log = log.WithValues("githubHookID", r.Header.Get("X-GitHub-Hook-ID")) log = log.WithValues("eventType", r.Header.Get("X-GitHub-Event")) log = log.WithValues("deliverID", r.Header.Get("X-GitHub-Delivery")) log.Error(err, "Failed to handle GitHub webhook") }
// Should become: // in imports add go.opentelemetry.io/otel/trace
func LogErrorCallback(ctx context.Context, w http.ResponseWriter, r *http.Request, err error) { span := trace.SpanFromContext(ctx) log := zapr.NewLogger(zap.L()).WithValues("traceId", traceId, "spanId", spanId) log = log.WithValues("githubHookID", r.Header.Get("X-GitHub-Hook-ID")) log = log.WithValues("eventType", r.Header.Get("X-GitHub-Event")) log = log.WithValues("deliverID", r.Header.Get("X-GitHub-Delivery")) log.Error(err, "Failed to handle GitHub webhook") }
@george-maroun In the call above where are you getting the context from?
@george-maroun In the call above where are you getting the context from?
Right. I’m changing the example and opening another issue to check for functions that take ctx as input.
We'd like to check if NewLogger is invoked, then check if WithValues is called on the NewLogger:
Separately, check if WithValues has even number of args