Browse Source

Add request ID to error reports

DarthSim 1 năm trước cách đây
mục cha
commit
01b053277d
2 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 1 1
      CHANGELOG.md
  2. 2 0
      server.go

+ 1 - 1
CHANGELOG.md

@@ -2,7 +2,7 @@
 
 ## [Unreleased]
 ### Add
-- Add processing/info options and source image URL to error reports.
+- Add request ID, processing/info options, and source image URL to error reports.
 
 ### Change
 - Support configuring OpenTelemetry with standard [general](https://opentelemetry.io/docs/languages/sdk-configuration/general/) and [OTLP Exporter](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/) environment variables.

+ 2 - 0
server.go

@@ -135,6 +135,8 @@ func withPanicHandler(h router.RouteHandler) router.RouteHandler {
 		ctx := errorreport.StartRequest(r)
 		r = r.WithContext(ctx)
 
+		errorreport.SetMetadata(r, "Request ID", reqID)
+
 		defer func() {
 			if rerr := recover(); rerr != nil {
 				if rerr == http.ErrAbortHandler {