Skip to content
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

Merged
merged 4 commits into from
Feb 11, 2020

Conversation

mauriciovasquezbernal
Copy link
Member

Fixes #400.

@mauriciovasquezbernal mauriciovasquezbernal requested a review from a team February 11, 2020 01:55
Copy link
Member

@c24t c24t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@c24t
Copy link
Member

c24t commented Feb 11, 2020

...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-io
Copy link

codecov-io commented Feb 11, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@1abe7ef). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #407   +/-   ##
=========================================
  Coverage          ?   85.86%           
=========================================
  Files             ?       41           
  Lines             ?     2080           
  Branches          ?      242           
=========================================
  Hits              ?     1786           
  Misses            ?      223           
  Partials          ?       71
Impacted Files Coverage Δ
...ntelemetry-api/src/opentelemetry/trace/__init__.py 84.56% <ø> (ø)
...emetry-sdk/src/opentelemetry/sdk/trace/__init__.py 90.8% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1abe7ef...daaecaf. Read the comment docs.

@mauriciovasquezbernal
Copy link
Member Author

@c24t done!

opentelemetry-api/src/opentelemetry/trace/__init__.py Outdated Show resolved Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py Outdated Show resolved Hide resolved
opentelemetry-sdk/tests/trace/test_trace.py Outdated Show resolved Hide resolved
@ocelotl
Copy link
Contributor

ocelotl commented Feb 11, 2020

LGTM 👍

@c24t c24t changed the title sdk: set sampled flag to true upon sampling decision SDK: set sampled flag on sampling trace Feb 11, 2020
@c24t
Copy link
Member

c24t commented Feb 11, 2020

FYI I reworded the commit because "upon sampling decision" could be interpreted as "on making any sampling decision".

@c24t c24t merged commit 2a54a93 into open-telemetry:master Feb 11, 2020
@@ -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)
Copy link
Member

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 @propertys in SpanContext.

toumorokoshi pushed a commit to toumorokoshi/opentelemetry-python that referenced this pull request Feb 17, 2020
@mauriciovasquezbernal mauriciovasquezbernal deleted the mauricio/set-sampled-flag branch April 14, 2020 21:50
srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 2020
* chore: add plugin request issue template

* Update .github/ISSUE_TEMPLATE/plugin_request.md

Co-Authored-By: dyladan <dyladan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sampled flag propagated doesn't correspond to actual sampling
5 participants