SQL Expressions: Add internal GMS traces (#104836)
get trace from inside GMS
This commit is contained in:
+8
-2
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/dolthub/go-mysql-server/sql/analyzer"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
)
|
||||
|
||||
// DB is a database that can execute SQL queries against a set of Frames.
|
||||
@@ -56,7 +57,7 @@ func isFunctionNotFoundError(err error) bool {
|
||||
// The RefID of each frame becomes a table in the database.
|
||||
// It is expected that there is only one frame per RefID.
|
||||
// The name becomes the name and RefID of the returned frame.
|
||||
func (db *DB) QueryFrames(ctx context.Context, name string, query string, frames []*data.Frame) (*data.Frame, error) {
|
||||
func (db *DB) QueryFrames(ctx context.Context, tracer tracing.Tracer, name string, query string, frames []*data.Frame) (*data.Frame, error) {
|
||||
// We are parsing twice due to TablesList, but don't care fow now. We can save the parsed query and reuse it later if we want.
|
||||
if allow, err := AllowQuery(query); err != nil || !allow {
|
||||
if err != nil {
|
||||
@@ -65,9 +66,14 @@ func (db *DB) QueryFrames(ctx context.Context, name string, query string, frames
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, span := tracer.Start(ctx, "SSE.ExecuteGMSQuery")
|
||||
defer span.End()
|
||||
|
||||
pro := NewFramesDBProvider(frames)
|
||||
session := mysql.NewBaseSession()
|
||||
mCtx := mysql.NewContext(ctx, mysql.WithSession(session))
|
||||
|
||||
// Create a new context with the session and tracer
|
||||
mCtx := mysql.NewContext(ctx, mysql.WithSession(session), mysql.WithTracer(tracer))
|
||||
|
||||
// Select the database in the context
|
||||
mCtx.SetCurrentDatabase(dbName)
|
||||
|
||||
Reference in New Issue
Block a user