-
Notifications
You must be signed in to change notification settings - Fork 402
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
feat(tracer): Support for external observability providers - Tracer #2342
Conversation
Drafted the first PR for tracer provider.
Questions:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2342 +/- ##
===========================================
- Coverage 96.38% 95.71% -0.67%
===========================================
Files 214 218 +4
Lines 10030 10488 +458
Branches 1846 1945 +99
===========================================
+ Hits 9667 10039 +372
- Misses 259 332 +73
- Partials 104 117 +13 ☔ View full report in Codecov by Sentry. |
…s-python into tracer
@rubenfonseca Thanks for the super detailed feedback. I've resolved all the comments now. Please help with a final review, thanks. |
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.
Super good progress! Just left some tiny picks and some questions on breaking changes. @leandrodamascena can you help implement the changes so we commit quickly?
@@ -11,7 +11,7 @@ def collect_payment(charge_id: str) -> str: | |||
@tracer.capture_lambda_handler | |||
def lambda_handler(event: dict, context: LambdaContext) -> str: | |||
charge_id = event.get("charge_id", "") | |||
with tracer.provider.in_subsegment("## collect_payment") as subsegment: | |||
with tracer.provider.in_subsegment("## collect_payment") as subsegment: # type: ignore |
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.
We should review this to make sure we don't have a typing breaking change
@@ -177,6 +178,36 @@ def __init__( | |||
if self._is_xray_provider(): | |||
self._disable_xray_trace_batching() | |||
|
|||
def set_attribute(self, key: str, value: Any, **kwargs): | |||
"""Set attribute on current active span with a key-value pair. |
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.
"""Set attribute on current active span with a key-value pair. | |
"""Set an attribute on current active span with a key-value pair. |
|
||
Parameters | ||
---------- | ||
key : str |
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.
key : str | |
key: str |
---------- | ||
key : str | ||
attribute key | ||
value : Any |
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.
value : Any | |
value: Any |
|
||
Example | ||
------- | ||
Set attribute for a pseudo service named payment |
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.
Set attribute for a pseudo service named payment | |
Set an attribute for a pseudo service named payment |
**kwargs, | ||
) -> None: | ||
""" | ||
Set attribute on the current active span with a key-value pair. |
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.
Set attribute on the current active span with a key-value pair. | |
Set an attribute on the current active span with a key-value pair. |
|
||
Parameters | ||
---------- | ||
key : str |
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.
key : str | |
key: str |
---------- | ||
key : str | ||
attribute key | ||
value : Any |
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.
value : Any | |
value: Any |
attribute key | ||
value : Any | ||
Value for attribute | ||
category : Literal["Annotation","Metadata","Auto"] = "Auto" |
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.
category : Literal["Annotation","Metadata","Auto"] = "Auto" | |
category: Literal["Annotation","Metadata","Auto"] = "Auto" |
class BaseSegment(abc.ABC): | ||
"""Holds common properties and methods on segment and subsegment.""" | ||
|
||
@abc.abstractmethod | ||
def close(self, end_time: Optional[int] = None): | ||
def close(self, end_time: Optional[float] = None): |
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.
Is this a breaking change? Or are we assuming that no one is inheriting from BaseSegment
today?
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.
We will deprecate this in Powertools v3. We're not using this class today, but we never know if customers are, so it's best to revert this change.
Reverted.
Quality Gate passedIssues Measures |
We can consider this PR completed, but we will not merge it now. We'll start conversations about Powertools V3 and add this refactor when we're ready for it: 1 - We will deprecate the BaseSegment in Powertools v3. I'm approving this PR and changing it to Draft state just so I don't mess up our stats. |
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 another stellar job @roger-zhangg! This refactor will open the opportunity to expand the Tracer utility and add more observability providers.
I left a comment explaining why we are approving but not merging this PR right now:
#2342 (comment)
Hi @roger-zhangg! I'm closing this PR in favor of #4902! It was really hard to fix the entire merge conflict here, so I've created a new one. Thank you for all the effort you've put in here, and I'll give you credit for this work when I release v3. |
Issue number:
2030
Summary
Support provider in tracer
Changes
Modify the provider with more genreral tracer feature, provide a new x-ray provider.
User experience
This change doesn't affect users who just use default x-ray provider.
This change allows users to bring their own tracer provider to use other solution provider other than X-ray
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.