mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
tracing baggage
This commit is contained in:
@ -26,6 +26,7 @@ const (
|
||||
tracingMaxContentLogSize = 512 * 1024 // Max log size for request and response body.
|
||||
tracingEventHttpRequest = "http.request"
|
||||
tracingEventHttpRequestHeaders = "http.request.headers"
|
||||
tracingEventHttpRequestBaggage = "http.request.baggage"
|
||||
tracingEventHttpRequestBody = "http.request.body"
|
||||
tracingEventHttpResponse = "http.response"
|
||||
tracingEventHttpResponseHeaders = "http.response.headers"
|
||||
@ -71,6 +72,7 @@ func MiddlewareServerTracing(r *Request) {
|
||||
}
|
||||
span.AddEvent(tracingEventHttpRequest, trace.WithAttributes(
|
||||
label.Any(tracingEventHttpRequestHeaders, httputil.HeaderToMap(r.Header)),
|
||||
label.Any(tracingEventHttpRequestBaggage, gtrace.GetBaggageMap(ctx).Map()),
|
||||
label.String(tracingEventHttpRequestBody, reqBodyContent),
|
||||
))
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@ const (
|
||||
tracingAttrHttpConnectDone = "http.connect.done"
|
||||
tracingEventHttpRequest = "http.request"
|
||||
tracingEventHttpRequestHeaders = "http.request.headers"
|
||||
tracingEventHttpRequestBaggage = "http.request.baggage"
|
||||
tracingEventHttpRequestBody = "http.request.body"
|
||||
tracingEventHttpResponse = "http.response"
|
||||
tracingEventHttpResponseHeaders = "http.response.headers"
|
||||
|
||||
@ -11,6 +11,7 @@ import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/internal/utils"
|
||||
"github.com/gogf/gf/net/gtrace"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/label"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
@ -154,6 +155,7 @@ func (ct *clientTracer) wroteRequest(info httptrace.WroteRequestInfo) {
|
||||
}
|
||||
ct.span.AddEvent(tracingEventHttpRequest, trace.WithAttributes(
|
||||
label.Any(tracingEventHttpRequestHeaders, ct.headers),
|
||||
label.Any(tracingEventHttpRequestBaggage, gtrace.GetBaggageMap(ct.Context).Map()),
|
||||
label.String(tracingEventHttpRequestBody, bodyContent),
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user