Skip to content

Commit

Permalink
Add invocation env to user agent string (#367)
Browse files Browse the repository at this point in the history
* Add invocation env to user agent string

* Consistency + fixups

* Changelog entry

* Try diff pattern
  • Loading branch information
jtcohen6 authored Jun 8, 2022
1 parent bc9fc0b commit ca1b5b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
### Fixes
- `adapter.get_columns_in_relation` (method) and `get_columns_in_relation` (macro) now return identical responses. The previous behavior of `get_columns_in_relation` (macro) is now represented by a new macro, `get_columns_in_relation_raw` ([#354](https://github.com/dbt-labs/dbt-spark/issues/354), [#355](https://github.com/dbt-labs/dbt-spark/pull/355))

### Under the hood
- Add `DBT_INVOCATION_ENV` environment variable to ODBC user agent string ([#366](https://github.com/dbt-labs/dbt-spark/pull/366))

## dbt-spark 1.1.0 (April 28, 2022)

### Features
Expand Down
8 changes: 5 additions & 3 deletions dbt/adapters/spark/connections.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from contextlib import contextmanager

import dbt.exceptions
Expand All @@ -7,6 +9,7 @@
from dbt.events import AdapterLogger
from dbt.utils import DECIMALS
from dbt.adapters.spark import __version__
from dbt.tracking import DBT_INVOCATION_ENV

try:
from TCLIService.ttypes import TOperationState as ThriftState
Expand Down Expand Up @@ -409,9 +412,8 @@ def open(cls, connection):
cls.validate_creds(creds, required_fields)

dbt_spark_version = __version__.version
user_agent_entry = (
f"dbt-labs-dbt-spark/{dbt_spark_version} (Databricks)" # noqa
)
dbt_invocation_env = os.getenv(DBT_INVOCATION_ENV) or "manual"
user_agent_entry = f"dbt-labs-dbt-spark/{dbt_spark_version} (Databricks, {dbt_invocation_env})" # noqa

# http://simba.wpengine.com/products/Spark/doc/ODBC_InstallGuide/unix/content/odbc/hi/configuring/serverside.htm
ssp = {f"SSP_{k}": f"{{{v}}}" for k, v in creds.server_side_parameters.items()}
Expand Down

0 comments on commit ca1b5b6

Please sign in to comment.