Add a minimal tracer example#86
Merged
Merged
Conversation
g-easy
reviewed
May 20, 2020
| auto exporter = std::unique_ptr<sdktrace::SpanExporter>(new StdoutExporter); | ||
| auto processor = std::shared_ptr<sdktrace::SpanProcessor>( | ||
| new sdktrace::SimpleSpanProcessor(std::move(exporter))); | ||
| auto provider = nostd::shared_ptr<trace::TracerProvider>(new sdktrace::TracerProvider(processor)); |
| auto processor = std::shared_ptr<sdktrace::SpanProcessor>( | ||
| new sdktrace::SimpleSpanProcessor(std::move(exporter))); | ||
| auto provider = nostd::shared_ptr<trace::TracerProvider>(new sdktrace::TracerProvider(processor)); | ||
| trace::Provider::SetTracerProvider(provider); |
Contributor
There was a problem hiding this comment.
Can/should this also be std::moved?
| return std::unique_ptr<sdktrace::Recordable>(new sdktrace::SpanData); | ||
| } | ||
|
|
||
| sdktrace::ExportResult Export(nostd::span<std::unique_ptr<sdktrace::Recordable>> &spans) noexcept |
Contributor
There was a problem hiding this comment.
How come none of this is const?
Contributor
Author
There was a problem hiding this comment.
I changed the span to const (although I think it wouldn't matter much, as the processor sees the content of the span as invalidated anyway after the call to Export).
Was this the intent of your question? Or do you also think the recordable itself should be const?
This was referenced May 27, 2020
0158c24 to
8251da7
Compare
reyang
pushed a commit
that referenced
this pull request
Jun 19, 2020
Merged
Merged
GerHobbelt
pushed a commit
to GerHobbelt/opentelemetry-cpp
that referenced
this pull request
Jun 17, 2025
Merged from upstream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a trivial example, which sets up a tracer in the main application and uses a library that is instrumented with OT. The example tries to be as minimal as possible (the biggest chunk being a stdout exporter).
I had to move some other bits to make the example work:
simple_processor.hneeds to be moved to the public include directory to be available for application developers to use.shared_ptrinstead of anostd::shared_ptr, otherwise we run into problems withshared_from_this.Some things still need to be done: timestamps, durations and ids are not initialized for spans. I'll probably look into this in a separate PR.