Skip to content

Commit 4ca3963

Browse files
Add missing scope field in the log formatter
1 parent 30dc196 commit 4ca3963

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

anaconda/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package:
22
name: snowflake-telemetry-python
3-
version: "0.7.0"
3+
version: "0.7.1.dev"
44

55
source:
66
path: {{ environ.get('SNOWFLAKE_TELEMETRY_DIR') }}

src/snowflake/telemetry/logs/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def get_severity_text(py_level_name):
7575

7676
def format(self, record: logging.LogRecord) -> str:
7777
log_items = {
78+
"scope": record.name,
7879
"body": record.getMessage(),
7980
"severity_text": self.get_severity_text(record.levelname),
8081
"code.lineno": record.lineno,

src/snowflake/telemetry/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
#
55

66
"""Update this for the versions."""
7-
VERSION = "0.7.0"
7+
VERSION = "0.7.1.dev"

tests/snowflake-telemetry-test-utils/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
install_requires=[
1818
"opentelemetry-exporter-otlp-proto-common == 1.26.0",
1919
"pytest >= 7.0.0",
20-
"snowflake-telemetry-python == 0.7.0",
20+
"snowflake-telemetry-python == 0.7.1.dev",
2121
"Jinja2 == 3.1.4",
2222
"grpcio-tools >= 1.62.3",
2323
"black >= 24.1.0",

tests/test_snowflake_log_formatter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def test_normal_log(self):
2020
""" Does the logger produce the correct output? """
2121
self.root_logger.warning('foo', extra={"test": 123, "code.lineno": 35})
2222
expected_log_message = {
23+
"scope": "test",
2324
"body": "foo",
2425
"severity_text": "WARN",
2526
"code.lineno": 21,
@@ -39,17 +40,18 @@ def test_exception_log(self):
3940
self.root_logger.exception("\"test exception\"")
4041

4142
expected_log_message = {
43+
"scope": "test",
4244
"body": "\"test exception\"",
4345
"severity_text": "ERROR",
44-
"code.lineno": 39,
46+
"code.lineno": 40,
4547
"code.function": "test_exception_log",
4648
"exception.type": "ZeroDivisionError",
4749
"exception.message": "division by zero",
4850
}
4951
actual_log_message = json.loads(self.stream.getvalue(), strict=False)
5052
actual_log_message.pop("code.filepath")
5153
actual_stacktrace = actual_log_message.pop("exception.stacktrace")
52-
self.assertIn("line 37, in test_exception_log\n", actual_stacktrace)
54+
self.assertIn("line 38, in test_exception_log\n", actual_stacktrace)
5355
self.assertIn("ZeroDivisionError: division by zero\n", actual_stacktrace)
5456
self.assertEqual(expected_log_message, actual_log_message)
5557

0 commit comments

Comments
 (0)