diff --git a/v2/metadata.go b/v2/metadata.go index b1b778f..68335b2 100644 --- a/v2/metadata.go +++ b/v2/metadata.go @@ -99,7 +99,7 @@ func (s sanitizer) Sanitize(data interface{}) interface{} { } } - // Handle certain well known interfaces and types + // Handle certain well known interfaces and types, in preferred order switch dataT := data.(type) { case error: return dataT.Error() @@ -120,6 +120,9 @@ func (s sanitizer) Sanitize(data interface{}) interface{} { if b, err := dataT.MarshalJSON(); err == nil { return string(b) } + + case []byte: + return string(dataT) } switch t.Kind() { diff --git a/v2/metadata_test.go b/v2/metadata_test.go index 383a13c..51bd1f6 100644 --- a/v2/metadata_test.go +++ b/v2/metadata_test.go @@ -216,7 +216,8 @@ func TestMetaDataSanitize(t *testing.T) { "time": time.Date(2023, 12, 5, 23, 59, 59, 123456789, time.UTC), "duration": 105567462 * time.Millisecond, "text": _textMarshaller{}, - "json": json.RawMessage(`{"hello": "world"}`), + "json": json.RawMessage(`{"json_property": "json_value"}`), + "bytes": []byte(`lots of bytes`), "array": []hash{{ "creditcard": "1234567812345678", "broken": broken, @@ -242,7 +243,8 @@ func TestMetaDataSanitize(t *testing.T) { "time": "2023-12-05T23:59:59.123456789Z", "duration": "29h19m27.462s", "text": "marshalled text", - "json": `{"hello": "world"}`, + "json": `{"json_property": "json_value"}`, + "bytes": "lots of bytes", "array": []interface{}{map[string]interface{}{ "creditcard": "[FILTERED]", "broken": map[string]interface{}{