-
Notifications
You must be signed in to change notification settings - Fork 657
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
Removing add_link and add_lazy_link from api/sdk #259
Removing add_link and add_lazy_link from api/sdk #259
Conversation
Signed-off-by: Alex Boten <[email protected]>
@@ -1,6 +1,6 @@ | |||
import time | |||
|
|||
from opentelemetry import trace | |||
from opentelemetry import trace, trace_api |
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.
trace_api
doesn't exist on opentelemetry, just trace
will work fine.
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 see, in other places it gets imported as trace_api. Fixed.
Signed-off-by: Alex Boten <[email protected]>
Signed-off-by: Alex Boten <[email protected]>
Signed-off-by: Alex Boten <[email protected]>
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.
LGTM besides the mutable default. This makes the API for span creation a bit uglier, but there's no obvious nicer solution following the OTEP.
@@ -76,11 +76,15 @@ | |||
class Link: | |||
"""A link to a `Span`.""" | |||
|
|||
empty_attributes = {} # type: typing.Dict[str, types.AttributeValue] |
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.
This can't be mutable since we expose it below, changing one (initially empty-attributed) link's attributes would affect others'.
Signed-off-by: Alex Boten <[email protected]>
Signed-off-by: Alex Boten <[email protected]>
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.
LGTM!
Signed-off-by: Alex Boten <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #259 +/- ##
==========================================
- Coverage 85.74% 85.65% -0.09%
==========================================
Files 33 33
Lines 1620 1610 -10
Branches 183 180 -3
==========================================
- Hits 1389 1379 -10
- Misses 184 185 +1
+ Partials 47 46 -1
Continue to review full report at Codecov.
|
Signed-off-by: Alex Boten <[email protected]>
@@ -444,6 +431,7 @@ def start_span( | |||
parent: The span's parent. Defaults to the current span. | |||
kind: The span's kind (relationship to parent). Note that is | |||
meaningful even if there is no parent. | |||
links: The span's links, to be used in sampling decisions |
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 don't think we should call out sampling here. This is merely a detail, mostly the links will be used to, well, have the span linked to other spans, not to influence sampling.
@@ -130,7 +130,7 @@ def __init__( | |||
resource: None = None, # TODO | |||
attributes: types.Attributes = None, # TODO | |||
events: Sequence[trace_api.Event] = None, # TODO | |||
links: Sequence[trace_api.Link] = None, # TODO | |||
links: Sequence[trace_api.Link] = 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.
Since start_span
uses ()
as a default instead of None
, maybe use ()
here too? Also we have a Sequence
not an Optional[Sequence]
anyway.
|
||
links = 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.
links = None | |
links = () |
An empty tuple should be a singleton constant, so no performance overhead over using None
here.
- updating comments - updating default value of links for Span constructor Signed-off-by: Alex Boten <[email protected]>
- adding `attributes` as optional parameter to `create_span`, `start_as_current_span`, `start_span` - adding `attributes` as optional parameter to Sampler's `should_sample` to allow them to be considered during sampling decision Signed-off-by: Alex Boten <[email protected]>
…ation Signed-off-by: Alex Boten <[email protected]>
Added |
Signed-off-by: Alex Boten <[email protected]>
if references: | ||
links = [] |
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.
Curious, is there a strong reason to create links
as a tuple and then change to list upon modification?
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.
There is not. Cleaned it up
@@ -416,6 +402,8 @@ def start_span( | |||
name: str, | |||
parent: ParentSpan = CURRENT_SPAN, | |||
kind: SpanKind = SpanKind.INTERNAL, | |||
attributes: typing.Optional[types.Attributes] = None, | |||
links: typing.Sequence[Link] = (), |
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.
Do we intend to support iterator (delayed expansion)? This might give perf gain if the span is not sampled (so we don't have to evaluate the iterator at all).
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 think someone should read up on the motivation behind lazy links. I think lazily evaluated iterables may be a good fit for Python.
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.
This is a good point. If we're not using __getitem__
-- and especially if we might not read the sequence at all, -- we should generally prefer Iterator
over Sequence
.
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.
LGTM, I've left some non-blocking suggestions.
Closes #132 |
Signed-off-by: Alex Boten <[email protected]>
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.
LGTM, but FWIW the API changes only really make sense in the context of the new sampling API. It's not clear why we'd prevent users from adding links after the span is created unless links were involved in the sampling decision, which they're not right now.
* feat: metrics API revision based on specs and rfcs * fix: document default values
Definitely still a work in progress. Removing
add_link
andadd_lazy_link
from api/sdk. From the open-telemetry/oteps#28, it appeared the only place where it made sense to add links was in thestart_span
,create_span
andstart_as_current_span
if we want to be able to add them to the Span before it's constructed. Would love some feedback on this.Still need to address the other part of the OTEP regarding Attributes
Signed-off-by: Alex Boten [email protected]