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

Method Log

server/querylog.go:213–227  ·  view source on GitHub ↗

Log sends an entry to the query log. Non-blocking; drops if channel is full.

(entry QueryLogEntry)

Source from the content-addressed store, hash-verified

211 ctx := ql.context()
212 var err error
213 if ql.prepareBatch != nil {
214 err = ql.prepareBatch(ctx, ql.db, batch)
215 }
216 if err == nil {
217 err = insertQueryLogEntries(ctx, ql.db, ql.table, batch)
218 }
219 observe.ObserveQueryLogFlushDuration(time.Since(start))
220 if err != nil {
221 observe.IncQueryLogFlushErrors()
222 observe.AddQueryLogDroppedEntries("flush_error", len(batch))
223 slog.Error("querylog: flush failed.", "error", err, "batch_size", len(batch))
224 return
225 }
226 observe.AddQueryLogFlushedEntries(len(batch))
227}
228
229func insertQueryLogEntries(ctx context.Context, db *sql.DB, table string, batch []QueryLogEntry) error {
230 if len(batch) == 0 {

Callers 1

TestQueryLogNonBlockingFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestQueryLogNonBlockingFunction · 0.76