[#146] node: Add trace_id to logs #697

Merged
dstepanov-yadro merged 1 commit from achuprov/frostfs-node:traceid into master 2023-09-27 14:17:21 +00:00
Member

Before

s04               | 2023-09-20T13:06:33.112Z    debug   shard/get.go:146        object is missing in write-cache        {"shard_id": "WzaheUh8uepi9vNVnPAs8J", "addr": "HwMFhycJ12HqndHrruqpmkZ4oTxc3sUv4mY2GNzLBQDM/JBza6jozAUS17L84gAZqJ5hVJjqJohndYsuGvwxroBYV", "skip_meta": false}

After

s04               | 2023-09-20T13:06:33.112Z    debug   shard/get.go:146        object is missing in write-cache        {"shard_id": "WzaheUh8uepi9vNVnPAs8J", "addr": "HwMFhycJ12HqndHrruqpmkZ4oTxc3sUv4mY2GNzLBQDM/JBza6jozAUS17L84gAZqJ5hVJjqJohndYsuGvwxroBYV", "skip_meta": false, "trace_id": "2decab8c944dc20f6bd8acd97bf21e82"}

Signed-off-by: Alexander Chuprov a.chuprov@yadro.com

Before ```log s04 | 2023-09-20T13:06:33.112Z debug shard/get.go:146 object is missing in write-cache {"shard_id": "WzaheUh8uepi9vNVnPAs8J", "addr": "HwMFhycJ12HqndHrruqpmkZ4oTxc3sUv4mY2GNzLBQDM/JBza6jozAUS17L84gAZqJ5hVJjqJohndYsuGvwxroBYV", "skip_meta": false} ``` After ```log s04 | 2023-09-20T13:06:33.112Z debug shard/get.go:146 object is missing in write-cache {"shard_id": "WzaheUh8uepi9vNVnPAs8J", "addr": "HwMFhycJ12HqndHrruqpmkZ4oTxc3sUv4mY2GNzLBQDM/JBza6jozAUS17L84gAZqJ5hVJjqJohndYsuGvwxroBYV", "skip_meta": false, "trace_id": "2decab8c944dc20f6bd8acd97bf21e82"} ``` Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
achuprov force-pushed traceid from 32fca98a91 to f668c0142c 2023-09-20 13:18:40 +00:00 Compare
achuprov changed title from WIP: [#146] node: Add trace_id to logs to [#146] node: Add trace_id to logs 2023-09-20 13:24:49 +00:00
achuprov changed title from [#146] node: Add trace_id to logs to WIP: [#146] node: Add trace_id to logs 2023-09-20 13:24:55 +00:00
achuprov changed title from WIP: [#146] node: Add trace_id to logs to [#146] node: Add trace_id to logs 2023-09-20 13:24:59 +00:00
achuprov requested review from storage-core-committers 2023-09-20 13:25:54 +00:00
achuprov requested review from storage-core-developers 2023-09-20 13:26:09 +00:00
dstepanov-yadro requested changes 2023-09-20 14:07:22 +00:00
@ -4,6 +4,7 @@ import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
traceUtils "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/trace"

I suggest changing the package name: git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/trace -> git.frostfs.info/TrueCloudLab/frostfs-node/pkg/trace

Everything can be util, so in some time we will drop this package i hope.

I suggest changing the package name: `git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/trace` -> `git.frostfs.info/TrueCloudLab/frostfs-node/pkg/trace` Everything can be `util`, so in some time we will drop this package i hope.
Member

How about ExtractTraceIDFromContext -> GetTraceID

How about `ExtractTraceIDFromContext` -> `GetTraceID`

I missed that in frostfs-observability the package is called tracing.
So tracingPkg "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/tracing" i think is better.

I missed that in frostfs-observability the package is called tracing. So `tracingPkg "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/tracing"` i think is better.

Not resolved: git.frostfs.info/TrueCloudLab/frostfs-node/pkg/trace -> git.frostfs.info/TrueCloudLab/frostfs-node/pkg/tracing

Not resolved: git.frostfs.info/TrueCloudLab/frostfs-node/pkg/trace -> git.frostfs.info/TrueCloudLab/frostfs-node/pkg/tracing
Author
Member

Misunderstood the essence of the correction). Fixed

Misunderstood the essence of the correction). Fixed
achuprov force-pushed traceid from f668c0142c to 14fd729ed6 2023-09-20 14:20:12 +00:00 Compare
acid-ant reviewed 2023-09-20 14:26:53 +00:00
acid-ant reviewed 2023-09-20 14:28:51 +00:00
@ -0,0 +15,4 @@
}
spanContext := span.SpanContext()
traceID := spanContext.TraceID()
return traceID.String()
Member

Is it possible to squash three lines in one?

Is it possible to squash three lines in one?
acid-ant marked this conversation as resolved
achuprov force-pushed traceid from 14fd729ed6 to 861d48e6e4 2023-09-20 14:33:17 +00:00 Compare
achuprov force-pushed traceid from 861d48e6e4 to 180a6737da 2023-09-20 14:38:36 +00:00 Compare

Before

s04               | 2023-09-20T13:06:33.112Z    debug   shard/get.go:146        object is missing in write-cache        {"shard_id": "WzaheUh8uepi9vNVnPAs8J", "addr": "HwMFhycJ12HqndHrruqpmkZ4oTxc3sUv4mY2GNzLBQDM/JBza6jozAUS17L84gAZqJ5hVJjqJohndYsuGvwxroBYV", "skip_meta": false, "trace_id": "2decab8c944dc20f6bd8acd97bf21e82"}

After

s04               | 2023-09-20T13:06:33.112Z    debug   shard/get.go:146        object is missing in write-cache        {"shard_id": "WzaheUh8uepi9vNVnPAs8J", "addr": "HwMFhycJ12HqndHrruqpmkZ4oTxc3sUv4mY2GNzLBQDM/JBza6jozAUS17L84gAZqJ5hVJjqJohndYsuGvwxroBYV", "skip_meta": false, "trace_id": "2decab8c944dc20f6bd8acd97bf21e82"}

And what is the difference?

> Before > ```log > s04 | 2023-09-20T13:06:33.112Z debug shard/get.go:146 object is missing in write-cache {"shard_id": "WzaheUh8uepi9vNVnPAs8J", "addr": "HwMFhycJ12HqndHrruqpmkZ4oTxc3sUv4mY2GNzLBQDM/JBza6jozAUS17L84gAZqJ5hVJjqJohndYsuGvwxroBYV", "skip_meta": false, "trace_id": "2decab8c944dc20f6bd8acd97bf21e82"} > ``` > After > ```log > s04 | 2023-09-20T13:06:33.112Z debug shard/get.go:146 object is missing in write-cache {"shard_id": "WzaheUh8uepi9vNVnPAs8J", "addr": "HwMFhycJ12HqndHrruqpmkZ4oTxc3sUv4mY2GNzLBQDM/JBza6jozAUS17L84gAZqJ5hVJjqJohndYsuGvwxroBYV", "skip_meta": false, "trace_id": "2decab8c944dc20f6bd8acd97bf21e82"} > ``` And what is the difference?
achuprov force-pushed traceid from 180a6737da to cc6f42f704 2023-09-20 14:49:10 +00:00 Compare

From test logs:

2023-09-20T14:42:18.777Z	DEBUG	shard/get.go:146	object is missing in write-cache	{"addr": "9rV5LLfo48dSMRNkZXYWp5CzFmktWCAvGKshSeaJtqMf/22rYAikFDG1XfTJXQXn241G25xPrec3uZNkDrSmS8Jdv", "skip_meta": false, "trace_id": "00000000000000000000000000000000"}
2023-09-20T14:42:18.778Z	DEBUG	shard/get.go:146	object is missing in write-cache	{"addr": "Ew3qi2ryML5azZEYwhNdEZXsxMhdiFAzg4WgM7EjwJLu/2hR8c78ZQTNZdymQVFkKAW5eKrfEKeMMTsYmyZNKsJvp", "skip_meta": false, "trace_id": "00000000000000000000000000000000"}

Why there are zeros?
Can we replace zeros with empty string?

From test logs: ``` 2023-09-20T14:42:18.777Z DEBUG shard/get.go:146 object is missing in write-cache {"addr": "9rV5LLfo48dSMRNkZXYWp5CzFmktWCAvGKshSeaJtqMf/22rYAikFDG1XfTJXQXn241G25xPrec3uZNkDrSmS8Jdv", "skip_meta": false, "trace_id": "00000000000000000000000000000000"} 2023-09-20T14:42:18.778Z DEBUG shard/get.go:146 object is missing in write-cache {"addr": "Ew3qi2ryML5azZEYwhNdEZXsxMhdiFAzg4WgM7EjwJLu/2hR8c78ZQTNZdymQVFkKAW5eKrfEKeMMTsYmyZNKsJvp", "skip_meta": false, "trace_id": "00000000000000000000000000000000"} ``` Why there are zeros? Can we replace zeros with empty string?
achuprov force-pushed traceid from cc6f42f704 to 9dc489e8f5 2023-09-22 12:15:15 +00:00 Compare
achuprov requested review from dstepanov-yadro 2023-09-25 07:13:04 +00:00
dstepanov-yadro requested changes 2023-09-26 14:29:19 +00:00
dstepanov-yadro left a comment
Member

Not resolved git.frostfs.info/TrueCloudLab/frostfs-node/pkg/trace -> git.frostfs.info/TrueCloudLab/frostfs-node/pkg/tracing

Not resolved git.frostfs.info/TrueCloudLab/frostfs-node/pkg/trace -> git.frostfs.info/TrueCloudLab/frostfs-node/pkg/tracing
achuprov force-pushed traceid from 9dc489e8f5 to 2958bf6880 2023-09-26 16:21:47 +00:00 Compare
acid-ant reviewed 2023-09-27 06:19:27 +00:00
@ -0,0 +10,4 @@
// It returns an empty string if no trace ID is found.
func GetTraceID(ctx context.Context) string {
span := trace.SpanFromContext(ctx)
if span == nil || span.SpanContext().TraceID() == [16]byte{} {
Member

Should we move [16]byte{} to const?

Should we move `[16]byte{}` to const?
acid-ant marked this conversation as resolved
dstepanov-yadro requested changes 2023-09-27 07:02:07 +00:00
@ -376,1 +387,3 @@
zap.String("tree", treeID))
zap.String("tree", treeID),
zap.String("trace_id", tracingPkg.GetTraceID(ctx)),
zap.String("trace_id", tracingPkg.GetTraceID(ctx)))

Remove second

Remove second
achuprov force-pushed traceid from 2958bf6880 to dc6ae885f2 2023-09-27 08:03:27 +00:00 Compare
achuprov force-pushed traceid from dc6ae885f2 to c1e4130020 2023-09-27 08:09:13 +00:00 Compare
achuprov requested review from dstepanov-yadro 2023-09-27 08:26:17 +00:00
acid-ant approved these changes 2023-09-27 10:51:29 +00:00
dstepanov-yadro approved these changes 2023-09-27 14:17:08 +00:00
dstepanov-yadro merged commit c1e4130020 into master 2023-09-27 14:17:21 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#697
No description provided.