SDK: set sampled flag on sampling trace#407
Conversation
|
...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". |
|
|
||
| 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.
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 @propertys 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.