Skip to content

Commit b772587

Browse files
authored
SNOW-897148: fix oob telemetry tags generation (#1708)
1 parent 20f1efb commit b772587

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

DESCRIPTION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
1313
- Fixed a bug in retry logic for okta authentication to refresh token.
1414
- Support `RSAPublicKey` when constructing `AuthByKeyPair` in addition to raw bytes.
1515
- Fixed a bug when connecting through SOCKS5 proxy, the attribute `proxy_header` is missing on `SOCKSProxyManager`.
16+
- Fixed a bug in tag generation of OOB telemetry event.
1617

1718
- v3.1.0(July 31,2023)
1819

src/snowflake/connector/telemetry_oob.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ def generate_tags(self):
124124

125125
telemetry = TelemetryService.get_instance()
126126
# Add telemetry service generated tags
127-
tags[TelemetryField.KEY_OOB_DRIVER] = CLIENT_NAME
128-
tags[TelemetryField.KEY_OOB_VERSION] = str(SNOWFLAKE_CONNECTOR_VERSION)
127+
tags[TelemetryField.KEY_OOB_DRIVER.value] = CLIENT_NAME
128+
tags[TelemetryField.KEY_OOB_VERSION.value] = str(SNOWFLAKE_CONNECTOR_VERSION)
129129
tags[
130-
TelemetryField.KEY_OOB_TELEMETRY_SERVER_DEPLOYMENT
130+
TelemetryField.KEY_OOB_TELEMETRY_SERVER_DEPLOYMENT.value
131131
] = telemetry.deployment.name
132132
tags[
133-
TelemetryField.KEY_OOB_CONNECTION_STRING
133+
TelemetryField.KEY_OOB_CONNECTION_STRING.value
134134
] = telemetry.get_connection_string()
135135
if telemetry.context and len(telemetry.context) > 0:
136136
for k, v in telemetry.context.items():

test/unit/test_telemetry_oob.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from __future__ import annotations
77

8+
import logging
9+
810
import pytest
911

1012
import snowflake.connector.errorcode
@@ -49,15 +51,20 @@ def telemetry_setup(request):
4951
telemetry.flush()
5052

5153

52-
def test_telemetry_oob_simple_flush(telemetry_setup):
54+
def test_telemetry_oob_simple_flush(telemetry_setup, caplog):
5355
"""Tests capturing and sending a simple OCSP Exception message."""
5456
telemetry = TelemetryService.get_instance()
5557

5658
telemetry.log_ocsp_exception(
5759
event_type, telemetry_data, exception=exception, stack_trace=stack_trace
5860
)
5961
assert telemetry.size() == 1
62+
caplog.set_level(logging.DEBUG, "snowflake.connector.telemetry_oob")
6063
telemetry.flush()
64+
assert (
65+
"Failed to generate a JSON dump from the passed in telemetry OOB events"
66+
not in caplog.text
67+
)
6168
assert telemetry.size() == 0
6269

6370

0 commit comments

Comments
 (0)