sdk-go icon indicating copy to clipboard operation
sdk-go copied to clipboard

Cosmetic bug in logger

Open billrich2001 opened this issue 2 months ago • 3 comments

Issue

The logger in lines 225-228 has a bug where the TraceID and SpanID are not converted to string which is causing a cosmetic bug when log gets printed, we see the byte array instead

example:

{
"time": "2025-11-03T12:43:20.743360843Z",
"level": "WARN",
"msg": "RecordActivityHeartbeat with error",
"Namespace": "bluesteel-test2.bm3o6",
"TaskQueue": "bluesteel-sync",
"WorkerID": "syncWorker",
"ActivityID": "11",
"ActivityType": "rlCheckIsWorkflowFinished",
"Attempt": "1",
"WorkflowType": "rlResourceLock",
"WorkflowID": "sync-service:019a496b-4aa7-77b2-8c46-524efaeb7b1d",
"RunID": "507113fe-60ba-44c0-ad1e-c15d8ef4f45b",
"TraceID": "[52, 93, 200, 50, 90, 70, 237, 164, 31, 63, 215, 229, 177, 194, 174, 221]",
"SpanID": "[96, 239, 131, 244, 197, 70, 240, 14]",
"Error": "workflow execution already completed"
}

Specifications

Bug is cosmetic, byte array isn't human readable

billrich2001 avatar Nov 07 '25 19:11 billrich2001

Mentioned internally, but will also mention here, most loggers, including Go's built-in log package (which our default logger uses), are expected to use String() on values that implement GoStringer. Which logger is being used in this case? I have not checked slog expectations compared to fmt and log.

cretz avatar Nov 07 '25 20:11 cretz

Added note.

Was able to recreate using slog and otel traceid on Go 1.21

billrich2001 avatar Nov 19 '25 22:11 billrich2001

For otel + slog a user should be using https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/bridges/otelslog

Quinn-With-Two-Ns avatar Nov 19 '25 23:11 Quinn-With-Two-Ns