Repository navigation
fix(telemetry): report execution_result and statement_type on Thrift statements - #550
Conversation
There was a problem hiding this comment.
Verdict: 1 Low
Looks good, with 1 low concern. The format mapping, where it is reported (Rows.Close before OnClose, and ExecContext from direct-results or staging-check metadata) and the promise of no extra RPC all check out against rows.go and operation.go. The one gap: an ExecContext statement whose staging step fails still reports a format, which doesn't match the description's "failed statements report no format".
There was a problem hiding this comment.
Verdict: 1 Low
Looks good, with one low concern. The tagging and mapping are correct and covered end-to-end through the real exporter, and no metadata RPC is added. The exception is the result-setup failure path, which drops a format the driver already received, unlike the fetch and staging failure cases.
There was a problem hiding this comment.
Verdict: 1 Critical
The telemetry wiring looks correct. The format is gated on execution success, reported once per statement before OnClose, and no RPC is added. The blocker is that the new conn-level test file imports Arrow v12, but this branch now depends only on arrow-go v18, so the root package's tests won't compile.
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/apache/arrow/go/v12/arrow" |
There was a problem hiding this comment.
🔴 Critical — The new test file imports github.com/apache/arrow/go/v12/arrow, .../array, .../ipc and .../memory. This branch has moved to Arrow Go v18: go.mod only requires github.com/apache/arrow-go/v18, and the CHANGELOG entry just above this PR's line describes that upgrade. With no v12 module in go.mod/go.sum, go test / go vet on the root dbsql package fails with "no required module provides package". That breaks make test and make lint for the whole package, not only these tests.
Fix: switch the imports to github.com/apache/arrow-go/v18/arrow, /arrow/array, /arrow/ipc and /arrow/memory. Then re-check the builder API: in v18, RecordBuilder.NewRecord is deprecated in favor of NewRecordBatch, and staticcheck may flag it. The "Arrow v12 caches the shared Timestamp_us zone" warm-up comment in TestConn_QueryContextTelemetryExecutionResult should also be rechecked against v18.
|
@bot update v12 to v18 arrow |
|
Pushed Started from 5ba5485. The module already depends on github.com/apache/arrow-go/v18 v18.8.0. The only v12 imports left were in connection_telemetry_test.go, which this PR adds. I switched its four imports (arrow, array, ipc, memory) from github.com/apache/arrow/go/v12 to github.com/apache/arrow-go/v18. I also changed the deprecated b.NewRecord() to b.NewRecordBatch(), which is what the rest of the repo uses with v18. go.mod and go.sum are unchanged. |
Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
|
@bot Could we preserve the format from fetched-page metadata for both public Arrow APIs? Without direct results, their iterators bypass rows.resultSetMetadata, so this accessor returns empty after successful consumption. Capturing it at the shared page-fetch boundary would avoid another RPC. |
a446dad to
9705ccc
Compare
Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com> Signed-off-by: Vu Anh Phung <[email protected]>
|
Pushed Started from a446dad. Without direct results, GetArrowBatches and GetArrowIPCStreams now report the result format. The page iterator keeps the first ResultSetMetadata a FetchResults page returns (resultPageIterator.go). If the rows hold no format, rows.ResultFormat uses that one (rows.go), with no extra RPC. New tests in connection_telemetry_test.go cover both APIs: INLINE_ARROW, no errors, zero metadata RPCs. Tests, make test (5 E2E skipped, no credentials) and make lint pass. gofmt -l -s lists only three generated internal/cli_service files I didn't touch. Not run here: live E2E and kernel-tagged tests. |
Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: 1 Nit
Looks good. I found no correctness issues. The format is taken from metadata the driver already holds, with no new RPC, and it is reported before the statement metric is finalized. The nil, typed-nil and failure paths in QueryContext and ExecContext are handled, and the tests cover each path, including the single-event check. One nit: a test comment still refers to Arrow v12 after the v18 upgrade.
Other findings
- ⚪ Nit —
connection_telemetry_test.go: the warm-up comment says "Arrow v12 caches the shared Timestamp_us zone", but this branch is on arrow-go v18 (see CHANGELOG). Either update the comment or check that the warm-up is still needed.
Thrift statement telemetry never set sql_operation.execution_result, so the backend could not tell inline Arrow results from CloudFetch delivery. Map the result format declared by the Thrift result-set metadata the driver already holds (JDBC's mapping: ARROW_BASED_SET -> INLINE_ARROW, URL_BASED_SET -> EXTERNAL_LINKS, COLUMN_BASED_SET -> COLUMNAR_INLINE) onto the existing result.format tag. Queries report it from Rows.Close before the statement metric is finalized; ExecContext reports it from the direct-results metadata or the metadata the staging check fetched. No metadata RPC is added, and failed statements report no format. Addresses #454. Co-authored-by: Isaac <[email protected]> Signed-off-by: Vu Anh Phung <[email protected]>
… cases Running TestConn_QueryContextTelemetryExecutionResult alone under -race hit Arrow v12's unsynchronized Timestamp_us zone cache from two parallel subtests (the production race is tracked in #465). Warm it while tests still run serially. Co-authored-by: Isaac <[email protected]> Signed-off-by: Vu Anh Phung <[email protected]>
A staging or fetch failure happens after the server returned the result metadata, so the format is still reported. This matches JDBC, which records the format before building the volume-operation handler. Only execution failures omit it. Co-authored-by: Isaac <[email protected]> Signed-off-by: Vu Anh Phung <[email protected]>
Thrift statement telemetry never set sql_operation.statement_type, so the backend could not classify Go Thrift statements. Report SQL for every Thrift statement, as the kernel does for user SQL, so both Go backends report the same value. The tag is set when the statement metric starts, so direct results, staging operations and failed statements all carry it on their single EXECUTE_STATEMENT event. Fixes #454. Co-authored-by: Isaac <[email protected]> Signed-off-by: Vu Anh Phung <[email protected]>
When QueryContext's Results fails after the server returned direct-results metadata (e.g. a malformed Arrow schema), the discarded Rows never reported its format, so the EXECUTE_STATEMENT event had no execution_result. Report the format the operation already holds through ResultFormatReporter, with no RPC, as JDBC does by recording the format before building the result. The success path is unchanged: only Rows.Close reports it there. Fixes #454. Co-authored-by: Isaac <[email protected]> Signed-off-by: Vu Anh Phung <[email protected]>
When direct results omit the result-set metadata, NewRows fetches it itself. If Arrow setup then failed, that metadata stayed on the discarded Rows and the EXECUTE_STATEMENT event had no execution_result. The QueryContext error branch now asks the discarded Rows for its format first (inline or fetched metadata), then the operation. No RPC is added, and the success path still reports the format only from Rows.Close. Fixes #454. Co-authored-by: Isaac <[email protected]> Signed-off-by: Vu Anh Phung <[email protected]>
Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com> Signed-off-by: Vu Anh Phung <[email protected]>
Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com> Signed-off-by: Vu Anh Phung <[email protected]>
2719e36 to
91d6bfd
Compare
Thrift statement telemetry never set
sql_operation.execution_resultorsql_operation.statement_type.SQLExecutionEvent.ExecutionResultwas filled only from theresult.formattag, and nothing produced that tag, so the backend could not tell inline Arrow results from CloudFetch (external links) delivery or classify the statement.This maps the result format declared by the Thrift result-set metadata to the telemetry enum, using JDBC's mapping:
ARROW_BASED_SET→INLINE_ARROW,URL_BASED_SET→EXTERNAL_LINKS,COLUMN_BASED_SET→COLUMNAR_INLINE. The value is written to the existing tag. Queries report it fromRows.Close, before the statement metric is finalized. The metadata comes from direct results or from the first row fetch.ExecContextreports it from the direct-results metadata or the metadata the staging check already fetched. The driver never adds a metadata RPC for telemetry, so a query closed before its first fetch, with no metadata in its direct results, omits the field (Node.js behaves the same way). Statements whose execution fails report no format. A failure after the metadata has arrived keeps the format, as JDBC does. That covers a fetch or staging error, and a result-setup error whereQueryContextdiscards itsRowsand reports the format itself. That format comes from the metadata those rows received inline or fetched. The format is still reported once per statement.Decision: every Thrift statement reports
statement_type=SQL. That covers queries,ExecContext, staging and failed statements. This matches the kernel, which hardcodesSQLfor user SQL, so both Go backends report the same value. The tag is set when the statement metric starts, so it rides on the singleEXECUTE_STATEMENTevent. The kernel backend is unaffected because driver telemetry is off whenever the opened backend isn't Thrift, including after Reyden recovery.Verified with:
httptest/telemetry-extendpoint. They cover inline Arrow, CloudFetch, a format known only after the first fetch, an unknown format, execution failure, failures after the metadata arrived (a fetch, staging or result-setup error), and ExecContext with direct-results metadata and with metadata from the staging check. Paired cases run the same metadata, inline or fetched, through a successfulResultsand a failing one. Each reportsINLINE_ARROWon a single event. Each test asserts exactly oneEXECUTE_STATEMENTevent withstatement_type=SQL, plus the metadata RPC count. Without this PR every case fails.make test(1338 tests pass),make lint(0 issues) andgo test -raceon the touched packages all pass. The kernel-tagged suite passes too, exceptTestKernelCloudFetchDisabledPreservesUnsupportedServerError, which also fails onmainwith the prebuilt v1.4.0 bindings.TestE2ETelemetryReportsExecutionResultpassed 3 of 3 runs. It reportsstatement_type=SQL, withINLINE_ARROWforSELECT 1andEXTERNAL_LINKSfor a 2M-row CloudFetch result. Onmainboth fields are empty. All 5 ThriftTestE2E*tests pass. On the kernel backend, 24 e2e tests pass.TestE2EKernelCloudFetchDisabledLargeResultsandTestKernelE2EErrorTelemetryCategoryfail the same way onmain.TestSuccessfulStatementExecutionEmitsTerminalOperationEvent(TELEMETRY-001) andTestTelemetryReportsExternalLinksDeliveryAndCompression(TELEMETRY-005) both go from XFAIL-skip to pass.TestFailedStatementEmitsSanitizedErrorTelemetryWithoutSQLText(TELEMETRY-002) still passes.Performance: the driver writes both tags once per statement, from a constant and from metadata it already holds. No RPC and no per-batch work is added.
Cross-driver state
execution_resultstatement_typeTelemetryCollector.getResultFormat(TelemetryCollector.java:202-213 @0cb8c24). Thestatement_typefield exists, butsetDriverStatementTypehas no caller (TelemetryHelper.java:115-121).FORMAT_UNSPECIFIED.executereportsQUERY, staging handlersSQL, metadata callsMETADATA(client.py:1381-1836).sql_operationhas nostatement_type(DatabricksTelemetryExporter.ts:77-81).telemetry_result_format(sea.rs:763-778 @db23442).StatementType::Sqlfor user SQL (statement/mutable.rs:692), set on failures too (telemetry/runtime.rs:252).SQLfor every statement. An unknown format is omitted, which is the same asFORMAT_UNSPECIFIEDin proto3 JSON. The kernel backend emits its own telemetry.Adversarial review: both passes converged in round 1 with no high findings. Two mediums were fixed: an Arrow timestamp-cache race in the new tests (#465), and a result-setup failure losing metadata the rows had fetched themselves. Coverage-test issues were recorded for the driver-test owners.
Fixes #454
This pull request and its description were written by Isaac.