diff --git a/database/gdb/gdb_core_tracing.go b/database/gdb/gdb_core_tracing.go index 74f818161..7139d3c64 100644 --- a/database/gdb/gdb_core_tracing.go +++ b/database/gdb/gdb_core_tracing.go @@ -14,6 +14,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" + semconv "go.opentelemetry.io/otel/semconv/v1.7.0" "go.opentelemetry.io/otel/trace" "github.com/gogf/gf/v2" @@ -54,6 +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), ) if c.db.GetConfig().Host != "" { labels = append(labels, attribute.String(tracingAttrDbHost, c.db.GetConfig().Host)) diff --git a/net/gtrace/gtrace.go b/net/gtrace/gtrace.go index 6b14ca8ac..afcc505d3 100644 --- a/net/gtrace/gtrace.go +++ b/net/gtrace/gtrace.go @@ -12,16 +12,17 @@ import ( "os" "strings" - "github.com/gogf/gf/v2/internal/command" - "github.com/gogf/gf/v2/util/gconv" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/propagation" + semconv "go.opentelemetry.io/otel/semconv/v1.7.0" "go.opentelemetry.io/otel/trace" "github.com/gogf/gf/v2/container/gmap" "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/util/gconv" ) const ( @@ -68,6 +69,7 @@ func CommonLabels() []attribute.KeyValue { return []attribute.KeyValue{ attribute.String(tracingCommonKeyIpHostname, hostname), attribute.String(tracingCommonKeyIpIntranet, intranetIpStr), + semconv.HostNameKey.String(hostname), } }