From 39bf8b83567a6b8601efaec2e10689a638534f4d Mon Sep 17 00:00:00 2001 From: Natalia Goc Date: Wed, 25 Sep 2024 16:11:08 +0200 Subject: [PATCH] feat: loosen the type restrictions on `attr.Json` Just like `json.Marshal` takes arguments of `any` type, the `attr.Json` should have similarly loose restrictions on input type. --- pkg/attr/attr.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/attr/attr.go b/pkg/attr/attr.go index e0137c5..2773e7a 100644 --- a/pkg/attr/attr.go +++ b/pkg/attr/attr.go @@ -142,7 +142,7 @@ func JsonAttr(key string, jsonEl map[string]interface{}) attribute.KeyValue { // Create an arbitrary attribute with value marshalled to json. // In case of marshalling error, it is returned in place of value. -func Json[M json.Marshaler](key string, val M) attribute.KeyValue { +func Json(key string, val any) attribute.KeyValue { data, err := json.Marshal(val) if err != nil { return attribute.KeyValue{Key: attribute.Key(key), Value: attribute.StringValue(err.Error())}