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

Removing create_span from the api #290

Merged
merged 9 commits into from
Nov 25, 2019

Conversation

codeboten
Copy link
Contributor

Simplifying the API by removing create_span. Updated the WSGI integration and docs.

Resolves #152

Signed-off-by: Alex Boten aboten@lightstep.com

Alex Boten added 2 commits November 14, 2019 11:05
Signed-off-by: Alex Boten <aboten@lightstep.com>
Signed-off-by: Alex Boten <aboten@lightstep.com>
Signed-off-by: Alex Boten <aboten@lightstep.com>
@codecov-io
Copy link

codecov-io commented Nov 14, 2019

Codecov Report

Merging #290 into master will decrease coverage by 0.11%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #290      +/-   ##
==========================================
- Coverage   85.66%   85.55%   -0.12%     
==========================================
  Files          33       33              
  Lines        1612     1599      -13     
  Branches      180      178       -2     
==========================================
- Hits         1381     1368      -13     
  Misses        185      185              
  Partials       46       46
Impacted Files Coverage Δ
...ntelemetry-api/src/opentelemetry/trace/__init__.py 85.95% <ø> (-0.34%) ⬇️
...emetry-sdk/src/opentelemetry/sdk/trace/__init__.py 88.94% <100%> (-0.18%) ⬇️
...ry-ext-wsgi/src/opentelemetry/ext/wsgi/__init__.py 90.54% <100%> (-0.37%) ⬇️
...src/opentelemetry/ext/opentracing_shim/__init__.py 95.83% <100%> (-0.14%) ⬇️

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 da8b8d9...371fa89. Read the comment docs.

@Oberon00
Copy link
Member

From #206 (comment):

This PR must not remove the capability of specifying explicit start times for the span. This is both in the spec and was explicitly requested, see #134. I guess the parameter should be added to start_span at least.

Comment on lines 380 to 381
Applications that need to create spans detached from the tracer's
context should use this method.
Copy link
Member

Choose a reason for hiding this comment

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

I would remove this paragraph, and maybe also rename the method to _create_span. Or we could commit to having this method be a "semi-public" interface of the SDK, to be overriden by any vendor-SDKs that need their own Span type but nevertheless want to reuse functionality from vendor SDKs.

In any case, applications (or any instrumentation use case really) must not use this method.

@Oberon00
Copy link
Member

We should also remove span.start() from the public API. We can either move the code to Tracer.start_span or just remove the method from the API but keep it in the SDK (preferably renaming it to _start).

Alex Boten added 4 commits November 19, 2019 08:24
This preserves the ability to set the `start_time` of a span that is currently available through calling `.start`

Signed-off-by: Alex Boten <aboten@lightstep.com>
Signed-off-by: Alex Boten <aboten@lightstep.com>
Signed-off-by: Alex Boten <aboten@lightstep.com>
return trace_api.DefaultSpan(context=context)
span.start(start_time=start_time)
else:
span = trace_api.DefaultSpan(context=context)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would love some feedback on whether or not this is the right thing to do here, since a DefaultSpan no longer has a start() method, I'm just returning it after creation

Copy link
Member

Choose a reason for hiding this comment

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

I think this is fine, a DefaultSpan doesn't even know whether it was started anyway.

@Oberon00
Copy link
Member

@open-telemetry/python-approvers: We need more reviews for this one!

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.

Changes LGTM, FYI I pushed some conflict fixes after merging #206.

@c24t
Copy link
Member

c24t commented Nov 23, 2019

In 371fa89 I changed some tests that relied on the fact that start_span and others called create_span and start under the hood. These changes make the tests more brittle since they're checking for a specific call now (start_span) instead of checking that the span was created.

Also note that because start has been moved to the SDK, there's no way to tell that a span has been started if it's an API object mock.

@Oberon00
Copy link
Member

Oberon00 commented Nov 25, 2019

@c24t about the test issues: I think we should switch all ext tests to use the SDK and the in-memory exporter instead of unittest.mock. That way the tests should be both easier to write & understand and test something that is closer to reality.

I created #303 to track this, I think we should do this in a separate PR, and I still think this one is fine.

@Oberon00 Oberon00 added the PR:please merge This PR is ready to be merged by a Maintainer (has enough valid approvals, successful build, etc.) label Nov 25, 2019
@c24t c24t merged commit 033bcdc into open-telemetry:master Nov 25, 2019
@c24t c24t removed the PR:please merge This PR is ready to be merged by a Maintainer (has enough valid approvals, successful build, etc.) label Dec 11, 2019
@codeboten codeboten deleted the remove-create-span branch October 9, 2020 18:50
srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 2020
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.

API: Consider removing Tracer.create_span()
5 participants