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

Update readthedocs api guide: nested spans and context propagator #792

Merged
merged 5 commits into from
May 25, 2021

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented May 24, 2021

Added Nested spans and Context Propagation in API Getting started guide.

Here is how it looks like:

https://labhas-opentelemetry-cpp.readthedocs.io/en/latest/GettingStarted.html

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@lalitb lalitb requested a review from a team May 24, 2021 14:59
@lalitb lalitb changed the title Update readthedocs api docs: nested spans and context propagator Update readthedocs api guide: nested spans and context propagator May 24, 2021
@codecov
Copy link

codecov bot commented May 24, 2021

Codecov Report

Merging #792 (b954649) into main (b1ff408) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #792   +/-   ##
=======================================
  Coverage   96.00%   96.00%           
=======================================
  Files         176      176           
  Lines        7186     7186           
=======================================
  Hits         6899     6899           
  Misses        287      287           

@@ -48,5 +48,57 @@ related span is ended.

The concept of an active span is important, as any span that is created
without explicitly specifying a parent is parented to the currently
active span.
active span. A span without a parent is called root span.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
active span. A span without a parent is called root span.
active span. A span with a null parent is called root span.

auto inner_span = tracer->StartSpan("Inner operation");
auto inner_scope = tracer->WithActiveSpan(inner_span);
// ... perform inner operation
inner_span->End();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this call to ->End() optional? The destruction of inner_span would call End().

Copy link
Member Author

@lalitb lalitb May 24, 2021

Choose a reason for hiding this comment

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

It's optional, as ~Span destructor calls it anyway. But the Span object returned by Tracer::StartSpan is shared_ptr and in case instrumentation code is referring to this object at some other places, the ~Span destructor will be called when all the references are cleaned up. It's always good ( and no harm ) to call it explicitly to export the Span when it is complete. And later when the destructor is called, it won't perform this again.

@lalitb lalitb merged commit 02f9efc into open-telemetry:main May 25, 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.

2 participants