get.porter.sh/porter@v1.3.0/pkg/tracing/attributes.go (about)

     1  package tracing
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	"go.opentelemetry.io/otel/attribute"
     7  )
     8  
     9  // ObjectAttribute writes the specified value as a json encoded value.
    10  func ObjectAttribute(key string, value interface{}) attribute.KeyValue {
    11  	data, err := json.Marshal(value)
    12  	if err != nil {
    13  		data = []byte("unable to marshal object to an otel attribute")
    14  	}
    15  
    16  	return attribute.Key(key).String(string(data))
    17  }