mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
[feature] upgrade opentelemetry version v1.0.0 map to string
This commit is contained in:
@ -12,7 +12,6 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gogf/gf"
|
||||
"github.com/gogf/gf/encoding/gjson"
|
||||
"github.com/gogf/gf/internal/utils"
|
||||
"github.com/gogf/gf/net/ghttp/internal/client"
|
||||
"github.com/gogf/gf/net/ghttp/internal/httputil"
|
||||
@ -85,7 +84,7 @@ func MiddlewareServerTracing(r *Request) {
|
||||
)
|
||||
|
||||
span.AddEvent(tracingEventHttpResponse, trace.WithAttributes(
|
||||
attribute.String(tracingEventHttpResponseHeaders, gjson.New(httputil.HeaderToMap(r.Response.Header())).MustToJsonString()),
|
||||
attribute.String(tracingEventHttpResponseHeaders, gconv.String(httputil.HeaderToMap(r.Response.Header()))),
|
||||
attribute.String(tracingEventHttpResponseBody, resBodyContent),
|
||||
))
|
||||
return
|
||||
|
||||
@ -14,12 +14,12 @@ import (
|
||||
// Carrier is the storage medium used by a TextMapPropagator.
|
||||
type Carrier map[string]interface{}
|
||||
|
||||
// NewCarrier .
|
||||
func NewCarrier(data ...map[string]interface{}) Carrier {
|
||||
if len(data) > 0 && data[0] != nil {
|
||||
return data[0]
|
||||
} else {
|
||||
return make(map[string]interface{})
|
||||
}
|
||||
return make(map[string]interface{})
|
||||
}
|
||||
|
||||
// Get returns the value associated with the passed key.
|
||||
@ -41,6 +41,7 @@ func (c Carrier) Keys() []string {
|
||||
return keys
|
||||
}
|
||||
|
||||
// MustMarshal .returns the JSON encoding of c
|
||||
func (c Carrier) MustMarshal() []byte {
|
||||
b, err := json.Marshal(c)
|
||||
if err != nil {
|
||||
@ -49,10 +50,12 @@ func (c Carrier) MustMarshal() []byte {
|
||||
return b
|
||||
}
|
||||
|
||||
// String .
|
||||
func (c Carrier) String() string {
|
||||
return string(c.MustMarshal())
|
||||
}
|
||||
|
||||
// UnmarshalJSON .
|
||||
func (c Carrier) UnmarshalJSON(b []byte) error {
|
||||
carrier := NewCarrier(nil)
|
||||
return json.UnmarshalUseNumber(b, carrier)
|
||||
|
||||
@ -11,6 +11,7 @@ import (
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
// Tracer .
|
||||
type Tracer struct {
|
||||
trace.Tracer
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user