Skip to content

Commit bd68a3e

Browse files
authored
feat(metrics): Add source context to code locations (#2539)
1 parent 044ce0a commit bd68a3e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

sentry_sdk/metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def get_code_location(stacklevel):
7676
return None
7777

7878
return serialize_frame(
79-
frm, include_local_variables=False, include_source_context=False
79+
frm, include_local_variables=False, include_source_context=True
8080
)
8181

8282

tests/test_metrics.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ def test_incr(sentry_init, capture_envelopes):
8585
"function": sys._getframe().f_code.co_name,
8686
"module": __name__,
8787
"lineno": mock.ANY,
88+
"pre_context": mock.ANY,
89+
"context_line": mock.ANY,
90+
"post_context": mock.ANY,
8891
}
8992
]
9093
},
@@ -133,6 +136,9 @@ def test_timing(sentry_init, capture_envelopes):
133136
"function": sys._getframe().f_code.co_name,
134137
"module": __name__,
135138
"lineno": mock.ANY,
139+
"pre_context": mock.ANY,
140+
"context_line": mock.ANY,
141+
"post_context": mock.ANY,
136142
}
137143
]
138144
},
@@ -200,6 +206,9 @@ def amazing_nano():
200206
"function": sys._getframe().f_code.co_name,
201207
"module": __name__,
202208
"lineno": mock.ANY,
209+
"pre_context": mock.ANY,
210+
"context_line": mock.ANY,
211+
"post_context": mock.ANY,
203212
}
204213
],
205214
"d:whatever-2@nanosecond": [
@@ -210,6 +219,9 @@ def amazing_nano():
210219
"function": sys._getframe().f_code.co_name,
211220
"module": __name__,
212221
"lineno": mock.ANY,
222+
"pre_context": mock.ANY,
223+
"context_line": mock.ANY,
224+
"post_context": mock.ANY,
213225
}
214226
],
215227
},
@@ -261,6 +273,9 @@ def test_timing_basic(sentry_init, capture_envelopes):
261273
"function": sys._getframe().f_code.co_name,
262274
"module": __name__,
263275
"lineno": mock.ANY,
276+
"pre_context": mock.ANY,
277+
"context_line": mock.ANY,
278+
"post_context": mock.ANY,
264279
}
265280
]
266281
},
@@ -311,6 +326,9 @@ def test_distribution(sentry_init, capture_envelopes):
311326
"function": sys._getframe().f_code.co_name,
312327
"module": __name__,
313328
"lineno": mock.ANY,
329+
"pre_context": mock.ANY,
330+
"context_line": mock.ANY,
331+
"post_context": mock.ANY,
314332
}
315333
]
316334
},
@@ -360,6 +378,9 @@ def test_set(sentry_init, capture_envelopes):
360378
"function": sys._getframe().f_code.co_name,
361379
"module": __name__,
362380
"lineno": mock.ANY,
381+
"pre_context": mock.ANY,
382+
"context_line": mock.ANY,
383+
"post_context": mock.ANY,
363384
}
364385
]
365386
},

0 commit comments

Comments
 (0)