Skip to content

Allow to start_as_current_span with end_on_exit=False#1519

Merged
lzchen merged 5 commits intoopen-telemetry:masterfrom
anton-ryzhov:start-span-no-end-on-exit
Jan 21, 2021
Merged

Allow to start_as_current_span with end_on_exit=False#1519
lzchen merged 5 commits intoopen-telemetry:masterfrom
anton-ryzhov:start-span-no-end-on-exit

Conversation

@anton-ryzhov
Copy link
Copy Markdown
Contributor

Description

start_as_current_span is just a helper that combines start_span and use_span methods. But it doesn't allow to change end_on_exit attribute. When it's required user have to call two underlying methods explicitly. Wrapper should expose all attributes to cover all cases.

Example use case:

def demo():
    with tracer.start_as_current_span('task', end_on_exit=False) as span:
        # Do some synchronous task preparation 
        # that must be part of the span
        task_data = ...

        # Contunue asynchronously
        executor.submit(
            tracer.use_span(span, use_span=True)(task_handler),
            task_data,
        )

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Unit tests updated respectively

Does This PR Require a Contrib Repo Change?

Answer the following question based on these examples of changes that would require a Contrib Repo Change:

  • The OTel specification has changed which prompted this PR to update the method interfaces of opentelemetry-api/ or opentelemetry-sdk/

  • The method interfaces of opentelemetry-instrumentation/ have changed

  • The method interfaces of test/util have changed

  • Scripts in scripts/ that were copied over to the Contrib repo have changed

  • Configuration files that were copied over to the Contrib repo have changed (when consistency between repositories is applicable) such as in

    • pyproject.toml
    • isort.cfg
    • .flake8
  • When a new .github/CODEOWNER is added

  • Major changes to project information, such as in:

    • README.md
    • CONTRIBUTING.md
  • Yes. - Link to PR:

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@anton-ryzhov anton-ryzhov marked this pull request as ready for review January 11, 2021 13:59
@anton-ryzhov anton-ryzhov requested review from a team, lzchen and owais and removed request for a team January 11, 2021 13:59
@lzchen lzchen merged commit b32365b into open-telemetry:master Jan 21, 2021
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.

3 participants