File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
src/snowflake/telemetry/logs Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 34
34
"threadName" ,
35
35
"taskName" ,
36
36
# Params that Snowflake will populate and don't want users of this API to overwrite.
37
+ "body" ,
37
38
"code.lineno" ,
38
39
"code.function" ,
39
40
"code.filepath" ,
40
41
"exception.type" ,
41
42
"exception.message" ,
42
43
"exception.stacktrace" ,
44
+ "scope" ,
45
+ "severity_text" ,
43
46
)
44
47
)
45
48
@@ -75,6 +78,7 @@ def get_severity_text(py_level_name):
75
78
76
79
def format (self , record : logging .LogRecord ) -> str :
77
80
log_items = {
81
+ "scope" : record .name ,
78
82
"body" : record .getMessage (),
79
83
"severity_text" : self .get_severity_text (record .levelname ),
80
84
"code.lineno" : record .lineno ,
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ def test_normal_log(self):
20
20
""" Does the logger produce the correct output? """
21
21
self .root_logger .warning ('foo' , extra = {"test" : 123 , "code.lineno" : 35 })
22
22
expected_log_message = {
23
+ "scope" : "test" ,
23
24
"body" : "foo" ,
24
25
"severity_text" : "WARN" ,
25
26
"code.lineno" : 21 ,
@@ -39,17 +40,18 @@ def test_exception_log(self):
39
40
self .root_logger .exception ("\" test exception\" " )
40
41
41
42
expected_log_message = {
43
+ "scope" : "test" ,
42
44
"body" : "\" test exception\" " ,
43
45
"severity_text" : "ERROR" ,
44
- "code.lineno" : 39 ,
46
+ "code.lineno" : 40 ,
45
47
"code.function" : "test_exception_log" ,
46
48
"exception.type" : "ZeroDivisionError" ,
47
49
"exception.message" : "division by zero" ,
48
50
}
49
51
actual_log_message = json .loads (self .stream .getvalue (), strict = False )
50
52
actual_log_message .pop ("code.filepath" )
51
53
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 )
53
55
self .assertIn ("ZeroDivisionError: division by zero\n " , actual_stacktrace )
54
56
self .assertEqual (expected_log_message , actual_log_message )
55
57
You can’t perform that action at this time.
0 commit comments