Merge pull request #1524 from houseme/master

feat:improve tracing
This commit is contained in:
John Guo
2021-12-22 22:26:15 +08:00
committed by GitHub
4 changed files with 6 additions and 5 deletions

View File

@ -55,7 +55,7 @@ func (c *Core) addSqlToTracing(ctx context.Context, sql *Sql) {
labels = append(labels, gtrace.CommonLabels()...)
labels = append(labels,
attribute.String(tracingAttrDbType, c.db.GetConfig().Type),
attribute.String(string(semconv.DBStatementKey), sql.Format),
semconv.DBStatementKey.String(sql.Format),
)
if c.db.GetConfig().Host != "" {
labels = append(labels, attribute.String(tracingAttrDbHost, c.db.GetConfig().Host))

View File

@ -12,12 +12,13 @@ import (
"reflect"
"time"
"github.com/gorilla/websocket"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/container/gtype"
"github.com/gogf/gf/v2/os/gcache"
"github.com/gogf/gf/v2/os/gsession"
"github.com/gogf/gf/v2/protocol/goai"
"github.com/gorilla/websocket"
)
type (
@ -132,7 +133,7 @@ const (
contentTypeHtml = "text/html"
contentTypeJson = "application/json"
swaggerUIPackedPath = "/goframe/swaggerui"
responseTraceIdHeader = "Trace-Id"
responseTraceIDHeader = "Trace-ID"
)
var (

View File

@ -143,7 +143,7 @@ func (r *Response) ClearBuffer() {
// Flush outputs the buffer content to the client and clears the buffer.
func (r *Response) Flush() {
r.Header().Set(responseTraceIdHeader, gtrace.GetTraceID(r.Request.Context()))
r.Header().Set(responseTraceIDHeader, gtrace.GetTraceID(r.Request.Context()))
if r.Server.config.ServerAgent != "" {
r.Header().Set("Server", r.Server.config.ServerAgent)
}

View File

@ -12,7 +12,6 @@ import (
"os"
"strings"
"github.com/gogf/gf/v2/net/gtrace/internal/provider"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/propagation"
@ -23,6 +22,7 @@ import (
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/internal/command"
"github.com/gogf/gf/v2/net/gipv4"
"github.com/gogf/gf/v2/net/gtrace/internal/provider"
"github.com/gogf/gf/v2/util/gconv"
)