Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 删除对attribute.Any的引用 #1680

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions net/ghttp/ghttp_middleware_tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/gogf/gf/net/ghttp/internal/httputil"
"github.com/gogf/gf/net/gtrace"
"github.com/gogf/gf/text/gstr"
"github.com/gogf/gf/util/gconv"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
Expand Down Expand Up @@ -56,8 +57,8 @@ func MiddlewareServerTracing(r *Request) {
r.Body = utils.NewReadCloser(reqBodyContentBytes, false)

span.AddEvent(tracingEventHttpRequest, trace.WithAttributes(
attribute.Any(tracingEventHttpRequestHeaders, httputil.HeaderToMap(r.Header)),
attribute.Any(tracingEventHttpRequestBaggage, gtrace.GetBaggageMap(ctx)),
attribute.String(tracingEventHttpRequestHeaders, gconv.String(httputil.HeaderToMap(r.Header))),
attribute.String(tracingEventHttpRequestBaggage, gconv.String(gtrace.GetBaggageMap(ctx))),
attribute.String(tracingEventHttpRequestBody, gstr.StrLimit(
string(reqBodyContentBytes),
gtrace.MaxContentLogSize(),
Expand All @@ -82,8 +83,8 @@ func MiddlewareServerTracing(r *Request) {
)

span.AddEvent(tracingEventHttpResponse, trace.WithAttributes(
attribute.Any(tracingEventHttpResponseHeaders, httputil.HeaderToMap(r.Response.Header())),
attribute.String(tracingEventHttpResponseHeaders, gconv.String(httputil.HeaderToMap(r.Response.Header()))),
attribute.String(tracingEventHttpResponseBody, resBodyContent),
))
return

}
3 changes: 2 additions & 1 deletion net/ghttp/internal/client/client_tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/gogf/gf/net/ghttp/internal/httputil"
"github.com/gogf/gf/net/gtrace"
"github.com/gogf/gf/text/gstr"
"github.com/gogf/gf/util/gconv"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
Expand Down Expand Up @@ -70,7 +71,7 @@ func MiddlewareTracing(c *Client, r *http.Request) (response *Response, err erro
response.Body = utils.NewReadCloser(reqBodyContentBytes, false)

span.AddEvent(tracingEventHttpResponse, trace.WithAttributes(
attribute.Any(tracingEventHttpResponseHeaders, httputil.HeaderToMap(response.Header)),
attribute.String(tracingEventHttpResponseHeaders, gconv.String(httputil.HeaderToMap(response.Header))),
attribute.String(tracingEventHttpResponseBody, gstr.StrLimit(
string(reqBodyContentBytes),
gtrace.MaxContentLogSize(),
Expand Down
5 changes: 3 additions & 2 deletions net/ghttp/internal/client/client_tracing_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/gogf/gf/internal/utils"
"github.com/gogf/gf/net/gtrace"
"github.com/gogf/gf/text/gstr"
"github.com/gogf/gf/util/gconv"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -147,8 +148,8 @@ func (ct *clientTracer) wroteRequest(info httptrace.WroteRequestInfo) {
}

ct.span.AddEvent(tracingEventHttpRequest, trace.WithAttributes(
attribute.Any(tracingEventHttpRequestHeaders, ct.headers),
attribute.Any(tracingEventHttpRequestBaggage, gtrace.GetBaggageMap(ct.Context)),
attribute.String(tracingEventHttpRequestHeaders, gconv.String(ct.headers)),
attribute.String(tracingEventHttpRequestBaggage, gconv.String(gtrace.GetBaggageMap(ct.Context))),
attribute.String(tracingEventHttpRequestBody, gstr.StrLimit(
string(ct.requestBody),
gtrace.MaxContentLogSize(),
Expand Down