-
Notifications
You must be signed in to change notification settings - Fork 653
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
SDK: set sampled flag on sampling trace #407
SDK: set sampled flag on sampling trace #407
Conversation
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!
...after doing: diff --git a/opentelemetry-api/src/opentelemetry/trace/__init__.py b/opentelemetry-api/src/opentelemetry/trace/__init__.py
index 28c1bf40..3473361d 100644
--- a/opentelemetry-api/src/opentelemetry/trace/__init__.py
+++ b/opentelemetry-api/src/opentelemetry/trace/__init__.py
@@ -266,7 +266,9 @@ class TraceOptions(int):
return cls(cls.DEFAULT)
@classmethod
- def get_sampled(cls, other: "TraceOptions" = None) -> "TraceOptions":
+ def get_sampled(
+ cls, other: typing.Optional["TraceOptions"] = None
+ ) -> "TraceOptions":
if other is None:
return cls(cls.SAMPLED)
return cls(other | cls.SAMPLED)
( |
Codecov Report
@@ Coverage Diff @@
## master #407 +/- ##
=========================================
Coverage ? 85.86%
=========================================
Files ? 41
Lines ? 2080
Branches ? 242
=========================================
Hits ? 1786
Misses ? 223
Partials ? 71
Continue to review full report at Codecov.
|
@c24t done! |
LGTM 👍 |
FYI I reworded the commit because "upon sampling decision" could be interpreted as "on making any sampling decision". |
@@ -511,6 +511,8 @@ def start_span( # pylint: disable=too-many-locals | |||
) | |||
|
|||
if sampling_decision.sampled: | |||
options = context.trace_options | trace_api.TraceOptions.SAMPLED | |||
context.trace_options = trace_api.TraceOptions(options) |
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.
Technically, we are modifying a context here which is supposed to be immutable. Since we are the unique owner of the context here (we haven't let anyone else see it yet) that's fine, but I wonder if we should make use of __slots__
and @property
s in SpanContext.
* chore: add plugin request issue template * Update .github/ISSUE_TEMPLATE/plugin_request.md Co-Authored-By: dyladan <dyladan@users.noreply.github.com>
Fixes #400.