This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 60e010c06 feat(go/adbc): align default trace path with ADBC config
layout (#4527)
60e010c06 is described below
commit 60e010c06b85aeb0b84e8a0e0ffbb4fad0a38a9f
Author: Mandukhai Alimaa <[email protected]>
AuthorDate: Mon Jul 20 15:55:34 2026 -0700
feat(go/adbc): align default trace path with ADBC config layout (#4527)
Update the Go driverbase adbcfile trace writer to use the ADBC
config-directory layout
Use temp directories for the existing rotating-file tests
Closes #4501
---
docs/source/driver/flight_sql.rst | 17 ++++-----
go/adbc/adbc.go | 5 ++-
.../internal/driverbase/rotating_file_writer.go | 29 +++++++++++++---
.../driverbase/rotating_file_writer_test.go | 40 ++++++++++++++++++++++
4 files changed, 74 insertions(+), 17 deletions(-)
diff --git a/docs/source/driver/flight_sql.rst
b/docs/source/driver/flight_sql.rst
index a53c833da..31de1e3c2 100644
--- a/docs/source/driver/flight_sql.rst
+++ b/docs/source/driver/flight_sql.rst
@@ -265,18 +265,13 @@ Database options
Overrides the output folder used by the ``adbcfile`` exporter.
This option is ignored for other exporters.
- If unset, the ``adbcfile`` exporter writes traces under the user's
- configuration directory in:
+ If unset, the ``adbcfile`` exporter writes traces under a
+ platform-specific directory:
- - Windows: ``%APPDATA%\.adbc\traces``
- - macOS: ``~/Library/Application Support/.adbc/traces``
- - Linux: ``$XDG_CONFIG_HOME/.adbc/traces`` or ``~/.config/.adbc/traces``
-
- .. note::
-
- These default paths reflect the current implementation. See
- `issue #4501 <https://github.com/apache/arrow-adbc/issues/4501>`_
- for the planned config-path redesign.
+ - Windows: ``%LOCALAPPDATA%\ADBC\Traces``
+ - macOS: ``~/Library/Application Support/ADBC/Traces``
+ - Linux: ``$XDG_STATE_HOME/adbc/traces`` or ``~/.local/state/adbc/traces``
+ if ``$XDG_STATE_HOME`` is not set
``adbc.telemetry.trace_parent``
Sets the W3C Trace Context ``traceparent`` value used as the parent
diff --git a/go/adbc/adbc.go b/go/adbc/adbc.go
index 7e85352b8..c33a1408e 100644
--- a/go/adbc/adbc.go
+++ b/go/adbc/adbc.go
@@ -280,7 +280,10 @@ const (
// traces exporter. When the exporter is "adbcfile" and this option
// is set, rotated trace files are written to the supplied folder
// (which is created if it does not exist) instead of the default
- // "<user-config-dir>/.adbc/traces" path. The option is ignored for
+ // platform-specific ADBC traces path (for example,
+ // "<user-config-dir>/ADBC/Traces" on macOS,
+ // "<local-app-data-dir>/ADBC/Traces" on Windows, or
+ // "<xdg-state-dir>/adbc/traces" on Linux). The option is ignored for
// other exporters; it exists so an operator can route trace files
// to a location their support workflow already collects (e.g. a
// shared diagnostics folder) via the ADBC driver-manager / TOML
diff --git a/go/adbc/driver/internal/driverbase/rotating_file_writer.go
b/go/adbc/driver/internal/driverbase/rotating_file_writer.go
index 5ce301bc8..9b375d5b1 100644
--- a/go/adbc/driver/internal/driverbase/rotating_file_writer.go
+++ b/go/adbc/driver/internal/driverbase/rotating_file_writer.go
@@ -22,6 +22,7 @@ import (
"io/fs"
"os"
"path/filepath"
+ "runtime"
"strings"
"time"
)
@@ -152,12 +153,30 @@ func NewRotatingFileWriter(options
...rotatingFileWriterOption) (*rotatingFileWr
}
func getDefaultTracingFolderPath() (string, error) {
- userConfigDir, err := os.UserConfigDir()
- if err != nil {
- return "", err
+ switch runtime.GOOS {
+ case "darwin":
+ userConfigDir, err := os.UserConfigDir()
+ if err != nil {
+ return "", err
+ }
+ return filepath.Join(userConfigDir, "ADBC", "Traces"), nil
+ case "windows":
+ userCacheDir, err := os.UserCacheDir()
+ if err != nil {
+ return "", err
+ }
+ return filepath.Join(userCacheDir, "ADBC", "Traces"), nil
+ default:
+ stateDir := os.Getenv("XDG_STATE_HOME")
+ if strings.TrimSpace(stateDir) == "" {
+ home, err := os.UserHomeDir()
+ if err != nil {
+ return "", err
+ }
+ stateDir = filepath.Join(home, ".local", "state")
+ }
+ return filepath.Join(stateDir, "adbc", "traces"), nil
}
- fullPath := filepath.Join(userConfigDir, ".adbc", "traces")
- return fullPath, nil
}
// Closes the rotating file write
diff --git a/go/adbc/driver/internal/driverbase/rotating_file_writer_test.go
b/go/adbc/driver/internal/driverbase/rotating_file_writer_test.go
index 4df48666c..70a0547bb 100644
--- a/go/adbc/driver/internal/driverbase/rotating_file_writer_test.go
+++ b/go/adbc/driver/internal/driverbase/rotating_file_writer_test.go
@@ -18,15 +18,51 @@
package driverbase_test
import (
+ "os"
+ "path/filepath"
+ "runtime"
"testing"
"github.com/apache/arrow-adbc/go/adbc/driver/internal/driverbase"
"github.com/stretchr/testify/require"
)
+func TestDefaultTracingFolderPath(t *testing.T) {
+ tempDir := t.TempDir()
+
+ var expected string
+ switch runtime.GOOS {
+ case "windows":
+ localAppDataDir := filepath.Join(tempDir, "AppData", "Local")
+ t.Setenv("LocalAppData", localAppDataDir)
+ expected = filepath.Join(localAppDataDir, "ADBC", "Traces")
+ case "darwin":
+ t.Setenv("HOME", tempDir)
+ expected = filepath.Join(tempDir, "Library", "Application
Support", "ADBC", "Traces")
+ default:
+ stateDir := filepath.Join(tempDir, ".local", "state")
+ t.Setenv("XDG_STATE_HOME", stateDir)
+ t.Setenv("HOME", tempDir)
+ expected = filepath.Join(stateDir, "adbc", "traces")
+ }
+
+ fw, err := driverbase.NewRotatingFileWriter()
+ require.NoError(t, err)
+ defer func() {
+ err := fw.Clear()
+ require.NoError(t, err)
+ }()
+
+ require.Equal(t, expected, fw.GetTracingFolderPath())
+ _, err = os.Stat(expected)
+ require.NoError(t, err)
+}
+
func TestRotatingFileWriter(t *testing.T) {
+ traceDir := t.TempDir()
fw, err := driverbase.NewRotatingFileWriter(
+ driverbase.WithTracingFolderPath(traceDir),
driverbase.WithFileSizeMaxKb(1),
driverbase.WithFileCountMax(10),
)
@@ -49,7 +85,10 @@ func TestRotatingFileWriter(t *testing.T) {
}
func TestFileResuse(t *testing.T) {
+ traceDir := t.TempDir()
+
fw1, err := driverbase.NewRotatingFileWriter(
+ driverbase.WithTracingFolderPath(traceDir),
driverbase.WithFileSizeMaxKb(1000),
driverbase.WithFileCountMax(10),
)
@@ -70,6 +109,7 @@ func TestFileResuse(t *testing.T) {
require.NoError(t, err)
fw2, err := driverbase.NewRotatingFileWriter(
+ driverbase.WithTracingFolderPath(traceDir),
driverbase.WithFileSizeMaxKb(1000),
driverbase.WithFileCountMax(10),
)