MCPcopy Create free account
hub / github.com/PostHog/duckgres / classifyQuery

Function classifyQuery

server/querylog.go:539–558  ·  view source on GitHub ↗

classifyQuery maps a command type string to a query_kind value.

(cmdType string)

Source from the content-addressed store, hash-verified

537
538 clientAddr, clientPort := c.clientAddrPort()
539
540 pgScanMs := int64(profilingSummary.PostgresScanSeconds * 1000)
541
542 parentQueryID, statementIndex := "", 0
543 if scope != nil {
544 parentQueryID, statementIndex = scope.parentQueryID, scope.statementIndex
545 }
546 // The terminal event carries the same extraction as the start event. When
547 // the scope has none (a path that logs without one), fall back to the
548 // statement text this call was handed so the row still says what was
549 // touched.
550 meta := c.queryMetadata(scope)
551 if scope == nil && c.server != nil && c.server.cfg.QueryLog.Metadata {
552 meta = extractQueryMetadata(query)
553 }
554 encodedMeta, accessKinds, metaComplete := queryMetadataColumns(meta)
555 ql.Log(QueryLogEntry{
556 QueryID: c.currentQueryID(),
557 ParentQueryID: parentQueryID,
558 StatementIndex: statementIndex,
559 EventTime: start,
560 QueryDurationMs: time.Since(start).Milliseconds(),
561 Type: entryType,

Callers 2

logQueryMethod · 0.85
TestClassifyQueryFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestClassifyQueryFunction · 0.68