Skip to content

Commit

Permalink
feat(go/adbc/driver/snowflake): add '[ADBC]' to snowflake application…
Browse files Browse the repository at this point in the history
… name (apache#1525)

To help Snowflake track adoption and usage of the ADBC driver, we can
explicitly add a prefix to any client application name to indicate the
ADBC driver is the source of the requests.

---------

Co-authored-by: David Li <[email protected]>
  • Loading branch information
zeroshade and lidavidm authored Feb 7, 2024
1 parent 0df5841 commit 21fba98
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions go/adbc/driver/snowflake/snowflake_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ func (d *databaseImpl) SetOptions(cnOptions map[string]string) error {
}
}

defaultAppName := "[ADBC][Go-" + infoDriverVersion + "]"
// set default application name to track
// unless user overrides it
d.cfg.Application = defaultAppName

var err error
for k, v := range cnOptions {
v := v // copy into loop scope
Expand Down Expand Up @@ -265,6 +270,9 @@ func (d *databaseImpl) SetOptions(cnOptions map[string]string) error {
}
d.cfg.ClientTimeout = dur
case OptionApplicationName:
if !strings.HasPrefix(v, "[ADBC]") {
v = defaultAppName + v
}
d.cfg.Application = v
case OptionSSLSkipVerify:
switch v {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ def connect(
kwargs = (db_kwargs or {}).copy()
if uri is not None:
kwargs["uri"] = uri
appname = kwargs.get(DatabaseOptions.APPLICATION_NAME.value, "")
kwargs[
DatabaseOptions.APPLICATION_NAME.value
] = f"[ADBC][Python-{__version__}]{appname}"
return adbc_driver_manager.AdbcDatabase(driver=_driver_path(), **kwargs)


Expand Down

0 comments on commit 21fba98

Please sign in to comment.