-
Notifications
You must be signed in to change notification settings - Fork 448
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
Enhancements to PR #86 Add minimal tracer example #94
Enhancements to PR #86 Add minimal tracer example #94
Conversation
/check-cla |
auto processor = std::shared_ptr<sdktrace::SpanProcessor>(new sdktrace::SimpleSpanProcessor( | ||
std::move(exporter))); // Create a Span Processor given the StdoutExporter defined earlier | ||
// Initialize a trace provider with the Span Processor instance defined above | ||
auto provider = nostd::shared_ptr<trace::TracerProvider>(new sdktrace::TracerProvider(processor)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be more sparse with inline comments and only use them to hint at things that cannot be inferred from the code itself. Otherwise they tend to make code harder to read instead of making it easier. There's no information in
// Initialize a trace provider with the Span Processor instance defined above
that cannot be inferred from
auto provider = nostd::shared_ptr<trace::TracerProvider>(new sdktrace::TracerProvider(processor));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminded me on one thing that I learned long time ago - make the code talk by itself.
examples/simple/README.md
Outdated
|
||
# Simple Trace Example | ||
|
||
This example sets up a tracer in the main application then makes several calls to a custom library instrumented with the <a href="https://github.com/open-telemetry/opentelemetry-cpp"> Open Telemetry SDK </a>. Specifically, it demonstrates the setup of fundamental Open Telemetry componenets such as Tracers, Tracer Providers and Spans. The example also illustrates context propogation from parent spans to children spans and events. All telemetry output is directed to stdout. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the idea of having a README for the example. I'd prefer being more concise here. The most important things to point out:
- There's a
foo_library
that is instrumented with the OpenTelemetry API. - There's an application in
main.cc
that initializes and registers a tracer provider from the OpenTelemetry SDK. Telemetry data is directed to stdout by using a custom exporter.
examples/simple/README.md
Outdated
bazel-bin/examples/simple/example_simple | ||
``` | ||
|
||
## Useful Links |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this section should be moved somewhere else. Those links aren't specific to this example but useful to the project as a whole (we wouldn't want to have the same information in all examples).
The same would apply to the Build and Run section. I think it would be better to have more general build instructions at a more central location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree the links aren't relevant. Where would you suggest I move the build/run instructions? I don't think it would hurt to leave them here as well as duplicate them somewhere else as many interns like myself have never used bazel before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move those instructions to the CONTRIBUTING doc. Java has instructions placed there.
I removed superfluous comments, polished the README, and moved instructions/links to CONTRIBUTING doc in PR #97 |
@ankit-bhargava #86 got merged, please rebase. Thanks. |
@reyang Rebased, thanks |
examples/simple/main.cc
Outdated
trace::Provider::SetTracerProvider(provider); | ||
} | ||
} // namespace | ||
|
||
int main() | ||
{ | ||
// Removing this line will leave OT initialized with the default noop | ||
// Removing this line will leave OTel SDK initialized with the default noop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has brought an interesting topic, neither the term OT
nor OTel
has been officially blessed https://github.com/open-telemetry/opentelemetry-specification/search?q=OTel&unscoped_q=OTel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll use "OpenTelemetry" to avoid confusion in that case.
examples/simple/README.md
Outdated
|
||
# Simple Trace Example | ||
|
||
In this example, an application in `main.cc` initializes and registers a tracer provider from the <a href="https://github.com/open-telemetry/opentelemetry-cpp"> Open Telemetry SDK </a>. The application then calls a `foo_library` which has been manually instrumented using the <a href="https://github.com/open-telemetry/opentelemetry-cpp/tree/master/api"> OpenTelemetry API </a>. Resulting telemetry is directed to stdout through a custom exporter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: consider using "the application" instead of "an application in main.cc
"?
examples/simple/README.md
Outdated
|
||
# Simple Trace Example | ||
|
||
In this example, an application in `main.cc` initializes and registers a tracer provider from the <a href="https://github.com/open-telemetry/opentelemetry-cpp"> Open Telemetry SDK </a>. The application then calls a `foo_library` which has been manually instrumented using the <a href="https://github.com/open-telemetry/opentelemetry-cpp/tree/master/api"> OpenTelemetry API </a>. Resulting telemetry is directed to stdout through a custom exporter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this example, an application in `main.cc` initializes and registers a tracer provider from the <a href="https://github.com/open-telemetry/opentelemetry-cpp"> Open Telemetry SDK </a>. The application then calls a `foo_library` which has been manually instrumented using the <a href="https://github.com/open-telemetry/opentelemetry-cpp/tree/master/api"> OpenTelemetry API </a>. Resulting telemetry is directed to stdout through a custom exporter. | |
In this example, an application in `main.cc` initializes and registers a tracer provider from the <a href="https://github.com/open-telemetry/opentelemetry-cpp"> OpenTelemetry SDK </a>. The application then calls a `foo_library` which has been manually instrumented using the <a href="https://github.com/open-telemetry/opentelemetry-cpp/tree/master/api"> OpenTelemetry API </a>. Resulting telemetry is directed to stdout through a custom exporter. |
examples/simple/README.md
Outdated
|
||
# Simple Trace Example | ||
|
||
In this example, an application in `main.cc` initializes and registers a tracer provider from the <a href="https://github.com/open-telemetry/opentelemetry-cpp"> Open Telemetry SDK </a>. The application then calls a `foo_library` which has been manually instrumented using the <a href="https://github.com/open-telemetry/opentelemetry-cpp/tree/master/api"> OpenTelemetry API </a>. Resulting telemetry is directed to stdout through a custom exporter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use markdown links.
[Open Telemetry SDK](https://github.com/open-telemetry/opentelemetry-cpp)
examples/simple/README.md
Outdated
|
||
In this example, an application in `main.cc` initializes and registers a tracer provider from the <a href="https://github.com/open-telemetry/opentelemetry-cpp"> Open Telemetry SDK </a>. The application then calls a `foo_library` which has been manually instrumented using the <a href="https://github.com/open-telemetry/opentelemetry-cpp/tree/master/api"> OpenTelemetry API </a>. Resulting telemetry is directed to stdout through a custom exporter. | ||
|
||
See <a href="https://github.com/open-telemetry/opentelemetry-cpp/blob/master/CONTRIBUTING.md"> CONTRIBUTING.md </a> for instructions on building and running the example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use relative link.
examples/simple/main.cc
Outdated
trace::Provider::SetTracerProvider(provider); | ||
} | ||
} // namespace | ||
|
||
int main() | ||
{ | ||
// Removing this line will leave OT initialized with the default noop | ||
// Removing this line will leave OpenTelemetry SDK initialized with the default noop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably "the SDK"? - I don't know - what do you think @pyohannes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to split some hairs, leaving out this line has the effect that no SDK is used at all. All the noop stuff is in the API.
Maybe:
Removing this line will leave the default noop TracerProvider in place.
examples/simple/main.cc
Outdated
// tracer, thus being effectively deactivated. | ||
initTracer(); | ||
|
||
// Call the instrumented library |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, seems unnecessary.
examples/simple/README.md
Outdated
|
||
# Simple Trace Example | ||
|
||
In this example, an application in `main.cc` initializes and registers a tracer provider from the <a href="https://github.com/open-telemetry/opentelemetry-cpp"> Open Telemetry SDK </a>. The application then calls a `foo_library` which has been manually instrumented using the <a href="https://github.com/open-telemetry/opentelemetry-cpp/tree/master/api"> OpenTelemetry API </a>. Resulting telemetry is directed to stdout through a custom exporter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this example, an application in `main.cc` initializes and registers a tracer provider from the <a href="https://github.com/open-telemetry/opentelemetry-cpp"> Open Telemetry SDK </a>. The application then calls a `foo_library` which has been manually instrumented using the <a href="https://github.com/open-telemetry/opentelemetry-cpp/tree/master/api"> OpenTelemetry API </a>. Resulting telemetry is directed to stdout through a custom exporter. | |
In this example, an application in `main.cc` initializes and registers a tracer provider from the <a href="https://github.com/open-telemetry/opentelemetry-cpp"> Open Telemetry SDK </a>. The application then calls a `foo_library` which has been instrumented using the <a href="https://github.com/open-telemetry/opentelemetry-cpp/tree/master/api"> OpenTelemetry API </a>. Resulting telemetry data is directed to stdout through a custom exporter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
manually instrumented doesn't really make sense, as we only support manual instrumentation. This might suggest we can do automatic instrumentation, but we don't.
examples/simple/README.md
Outdated
|
||
# Simple Trace Example | ||
|
||
In this example, the application in `main.cc` initializes and registers a tracer provider from the [OpenTelemetry SDK](https://github.com/open-telemetry/opentelemetry-cpp). The application then calls a `foo_library` which has been instrumented using the [OpenTelemetry API](https://github.com/open-telemetry/opentelemetry-cpp/tree/master/api). Resulting telemetry is directed to stdout through a custom exporter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you add line wrapping at column 80?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use one space instead of two for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed both :)
examples/simple/main.cc
Outdated
@@ -11,18 +11,19 @@ namespace | |||
{ | |||
void initTracer() | |||
{ | |||
auto exporter = std::unique_ptr<sdktrace::SpanExporter>(new StdoutExporter); | |||
auto exporter = std::unique_ptr<sdktrace::SpanExporter>(new StdoutExporter); | |||
// Specify the Span Processor: SimpleSpanProcessor forwards spans directly to the exporter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Span Processor -> SpanProcessor (remove the space)
I also wonder if this is self-explanatory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, removed the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This is ready to merge, @ankit-bhargava would you rebase? |
examples/simple/README.md
Outdated
# Simple Trace Example | ||
|
||
In this example, the application in `main.cc` initializes and registers a tracer | ||
provider from the [OpenTelemetry SDK](https://github.com/open-telemetry/opentelemetry-cpp). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the leading spaces be removed?
Co-authored-by: Reiley Yang <[email protected]>
Replacing the unofficial "OTel" shorthand with the "OpenTelemetry"
This PR adds build and run documentation in README.md as well as adds inline comments for the simple tracer example in PR #86 .