Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

625 B
Raw Blame
package telemetrystore

import (
	"strings"
	"time"
	"unicode"
)

type QueryEvent struct {
	Query     string
	QueryArgs []any
	StartTime time.Time
	Operation string
	Err       error
}

func NewQueryEvent(query string, args []any) *QueryEvent {
	return &QueryEvent{
		Query:     query,
		QueryArgs: args,
		StartTime: time.Now(),
		Operation: queryOperation(query),
	}
}

func queryOperation(query string) string {
	queryOp := strings.TrimLeftFunc(query, unicode.IsSpace)

	if idx := strings.IndexByte(queryOp, ' '); idx > 0 {
		queryOp = queryOp[:idx]
	}
	if len(queryOp) > 16 {
		queryOp = queryOp[:16]
	}
	return queryOp
}