Skip to content

Commit 2228456

Browse files
SNOW-2039989 include app path within client environment (#2412)
1 parent dee074c commit 2228456

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

DESCRIPTION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
99
# Release Notes
1010
- v3.16.1(TBD)
1111
- Added in-band OCSP exception telemetry.
12+
- Added `APPLICATION_PATH` within `CLIENT_ENVIRONMENT` to distinguish between multiple scripts using the PythonConnector in the same environment.
1213
- Disabled token caching for OAuth Client Credentials authentication
1314
- Added in-band HTTP exception telemetry.
1415
- Fixed a bug where timezoned timestamps fetched as pandas.DataFrame or pyarrow.Table would overflow for the sake of unnecessary precision. In the case where an overflow cannot be prevented a clear error will be raised now.

src/snowflake/connector/_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import string
44
from enum import Enum
5+
from inspect import stack
56
from random import choice
67
from threading import Timer
78
from uuid import UUID
@@ -86,3 +87,12 @@ def __init__(self, interval, function, args=None, kwargs=None):
8687
def run(self):
8788
super().run()
8889
self.executed = True
90+
91+
92+
def get_application_path() -> str:
93+
"""Get the path of the application script using the connector."""
94+
try:
95+
outermost_frame = stack()[-1]
96+
return outermost_frame.filename
97+
except Exception:
98+
return "unknown"

src/snowflake/connector/auth/_auth.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
load_pem_private_key,
1818
)
1919

20+
from .._utils import get_application_path
2021
from ..compat import urlencode
2122
from ..constants import (
2223
DAY_IN_SECONDS,
@@ -110,6 +111,7 @@ def base_auth_data(
110111
"LOGIN_NAME": user,
111112
"CLIENT_ENVIRONMENT": {
112113
"APPLICATION": application,
114+
"APPLICATION_PATH": get_application_path(),
113115
"OS": OPERATING_SYSTEM,
114116
"OS_VERSION": PLATFORM,
115117
"PYTHON_VERSION": PYTHON_VERSION,

0 commit comments

Comments
 (0)