Skip to content

Commit

Permalink
feat(metrics): Add source context to code locations (#2539)
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-auer committed Nov 29, 2023
1 parent 044ce0a commit bd68a3e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sentry_sdk/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_code_location(stacklevel):
return None

return serialize_frame(
frm, include_local_variables=False, include_source_context=False
frm, include_local_variables=False, include_source_context=True
)


Expand Down
21 changes: 21 additions & 0 deletions tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def test_incr(sentry_init, capture_envelopes):
"function": sys._getframe().f_code.co_name,
"module": __name__,
"lineno": mock.ANY,
"pre_context": mock.ANY,
"context_line": mock.ANY,
"post_context": mock.ANY,
}
]
},
Expand Down Expand Up @@ -133,6 +136,9 @@ def test_timing(sentry_init, capture_envelopes):
"function": sys._getframe().f_code.co_name,
"module": __name__,
"lineno": mock.ANY,
"pre_context": mock.ANY,
"context_line": mock.ANY,
"post_context": mock.ANY,
}
]
},
Expand Down Expand Up @@ -200,6 +206,9 @@ def amazing_nano():
"function": sys._getframe().f_code.co_name,
"module": __name__,
"lineno": mock.ANY,
"pre_context": mock.ANY,
"context_line": mock.ANY,
"post_context": mock.ANY,
}
],
"d:whatever-2@nanosecond": [
Expand All @@ -210,6 +219,9 @@ def amazing_nano():
"function": sys._getframe().f_code.co_name,
"module": __name__,
"lineno": mock.ANY,
"pre_context": mock.ANY,
"context_line": mock.ANY,
"post_context": mock.ANY,
}
],
},
Expand Down Expand Up @@ -261,6 +273,9 @@ def test_timing_basic(sentry_init, capture_envelopes):
"function": sys._getframe().f_code.co_name,
"module": __name__,
"lineno": mock.ANY,
"pre_context": mock.ANY,
"context_line": mock.ANY,
"post_context": mock.ANY,
}
]
},
Expand Down Expand Up @@ -311,6 +326,9 @@ def test_distribution(sentry_init, capture_envelopes):
"function": sys._getframe().f_code.co_name,
"module": __name__,
"lineno": mock.ANY,
"pre_context": mock.ANY,
"context_line": mock.ANY,
"post_context": mock.ANY,
}
]
},
Expand Down Expand Up @@ -360,6 +378,9 @@ def test_set(sentry_init, capture_envelopes):
"function": sys._getframe().f_code.co_name,
"module": __name__,
"lineno": mock.ANY,
"pre_context": mock.ANY,
"context_line": mock.ANY,
"post_context": mock.ANY,
}
]
},
Expand Down

0 comments on commit bd68a3e

Please sign in to comment.