-
Notifications
You must be signed in to change notification settings - Fork 40
Added MetricsLogger.add_stack_trace() #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Note |
I chose to make the values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! And apologies for the delay in reviewing it. A few comments/questions:
-
Given how Insights currently handles arrays, I wonder if stack_trace would make more sense as a single string. Even when we do improve array query support, I’m not sure what the benefit of having it as an array would be over storing it as a string (other than speculative UX enhancements for arrays, e.g. collapsibility).
-
What’s the purpose of the value property? Having a concrete example would help my understand its use case. Also, doc comments might be helpful.
-
We’ll need to update the README, but we can punt that until the release PR. No need to block this PR.
@@ -73,6 +75,35 @@ def put_metric(self, key: str, value: float, unit: str = "None") -> "MetricsLogg | |||
self.context.put_metric(key, value, unit) | |||
return self | |||
|
|||
def add_stack_trace(self, key: str, value: Any = None, exc_info: Tuple = None) -> "MetricsLogger": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What’s the use case for allowing a user provided exc_info?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've ended up in situations before where my context changes and the right thing isn't in sys.exc_info() anymore. More generally,I usually default to allowing the user to fully specify the behavior if they want.
I'm fine with that, especially as each string in the array is multiline anyway (which I wasn't thinking about when I originally thought about the traceback as an array).
The idea was to provide some extra user-specified context if needed, and I went for a key, value method API like |
Maybe “description” would be more appropriate? I think that other context data that I would include should likely be a top-level property (although there may be use cases I can’t think of). |
In that case, maybe we just have an optional |
23133be
to
8054c06
Compare
JFYI in case you aren't familiar with our release process, this will bake for a couple days in a test environment and then will be released as part of 1.0.3. |
PR Code Suggestions ✨
|
Implements #38
Description of changes: Added the
MetricsLogger.add_stack_trace()
method, which takes a key, an optional value, and an optionalexc_info
tuple (if not given, it usessys.exc_info()
). It adds a property using that key, with the following value:By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.