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

Method StopQueryLogging

server/exports.go:330–348  ·  view source on GitHub ↗

StopQueryLogging drains and stops the active query-log sink, if any.

(ctx context.Context)

Source from the content-addressed store, hash-verified

328
329// ConnectionBilling returns the data needed to meter one connection's
330// compute-usage at teardown: the org, the authenticated username (used to
331// resolve the informational team id stamped onto the bucket — the user's own
332// team when it has one, else the org's oldest team), the session's query
333// source (the `duckgres.query_source` GUC — "standard" unless the client set
334// it), the provisioned worker size in milli-units, and the connection's
335// elapsed lifetime. millicores == 0 means metering should be skipped (unknown
336// worker size). Call at the same teardown point as CloseConnectionMetrics. A
337// mid-connection GUC change is not split: the whole connection is metered
338// under the final value (documented in docs/design/billing-pull-api.md).
339//
340// The query source is clamped to the closed {standard, endpoints} set as
341// defense in depth: every set path already validates (22023 at SET / startup
342// time), so a non-canonical value here means a validation bypass — degrade it
343// to the default rather than writing unbounded-cardinality client input into
344// the billing bucket key (and onward into billing exports).
345func ConnectionBilling(cc *clientConn) (orgID, username, querySource string, millicores, mib int64, dur time.Duration) {
346 if cc == nil {
347 return "", "", "", 0, 0, 0
348 }
349 qs := cc.QuerySource()
350 if qs != transform.QuerySourceStandard && qs != transform.QuerySourceEndpoints {
351 // Should be unreachable. Log the length, not the value — it is

Callers 3

CloseMethod · 0.95
ShutdownMethod · 0.95
stopQueryLoggerMethod · 0.80

Calls 2

queryLogStopContextFunction · 0.85
StopContextMethod · 0.65

Tested by

no test coverage detected