-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logID are duplicated #316
Comments
repro: go run -race ./example/...
curl -vkL "https://127.0.0.1:65081/health" -H "Host: badHost.com" {
"time": "2023-07-09T18:50:30.771492654Z",
"level": "ERROR",
"source": {
"function": "github.com/komuw/ong/middleware.logger.func1.1",
"file": "/home/ong/middleware/log.go",
"line": 74
},
"msg": "http_server",
"logID": "gTXenPA8mXCxQPqh",
"pid": 301538,
"logID": "KHxm2cKKfPjGqHDt",
"clientIP": "127.0.0.1",
"clientFingerPrint": "0d9kmhf55e80c",
"method": "GET",
"path": "/health",
"code": 400,
"status": "Bad Request",
"durationMS": 0,
"ongError": "ong/middleware: the HOST http header has an unexpected value: badHost.com",
"logID": "gTXenPA8mXCxQPqh"
} |
repro: package main
import (
"context"
"os"
"github.com/komuw/ong/log"
)
func main() {
l := log.New(os.Stdout, 100)(context.Background())
l.Error("my error")
} {
"time": "2009-11-10T23:00:00Z",
"level": "ERROR",
"source": {
"function": "main.main",
"file": "/tmp/sandbox4189155437/prog.go",
"line": 12
},
"msg": "my error",
"logID": "cEKmgxtQCeDw7t3G",
"logID": "cEKmgxtQCeDw7t3G"
} |
The following patch seems to fix it; diff --git a/log/log.go b/log/log.go
index d257025..1636d2a 100644
--- a/log/log.go
+++ b/log/log.go
@@ -149,7 +149,7 @@ func (h handler) Handle(ctx context.Context, r slog.Record) error {
ctx = context.WithValue(ctx, octx.LogCtxKey, id)
newAttrs := []slog.Attr{
- {Key: logIDFieldName, Value: slog.StringValue(id)},
+ // {Key: logIDFieldName, Value: slog.StringValue(id)},
}
r.Attrs(func(a slog.Attr) bool {
if e, ok := a.Value.Any().(error); ok { |
komuw
added a commit
that referenced
this issue
Jul 10, 2023
- Some logID's are still duplicated, but not all. See the testcase added. - Fixes: #316
komuw
added a commit
that referenced
this issue
Jul 10, 2023
- Some logID's are still duplicated, but not all. See the testcase added. It is kind of hard and non-perfomant[2] to try remove all duplicates. 1. Fixes: #316 2. golang/go#56345 (comment)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: