Log sends an entry to the query log. Non-blocking; drops if channel is full.
(entry QueryLogEntry)
| 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 | |
| 229 | func insertQueryLogEntries(ctx context.Context, db *sql.DB, table string, batch []QueryLogEntry) error { |
| 230 | if len(batch) == 0 { |
no outgoing calls