Skip to content

Commit

Permalink
Enhancements to PR open-telemetry#86 Add minimal tracer example (open…
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit-bhargava authored Jun 19, 2020
1 parent 9048d45 commit c86794e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ include(CTest)
find_package(Threads)

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Options for Visual C++ compiler:
# /Zc:__cplusplus - report an updated value for recent C++ language standards.
# Without this option MSVC returns the value of __cplusplus="199711L"
# Options for Visual C++ compiler: /Zc:__cplusplus - report an updated value
# for recent C++ language standards. Without this option MSVC returns the
# value of __cplusplus="199711L"
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
endif()

Expand Down
10 changes: 10 additions & 0 deletions examples/simple/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

# 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.

See [CONTRIBUTING.md](../../CONTRIBUTING.md) for instructions on building and running the example.
4 changes: 2 additions & 2 deletions examples/simple/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ void initTracer()
auto processor = std::shared_ptr<sdktrace::SpanProcessor>(
new sdktrace::SimpleSpanProcessor(std::move(exporter)));
auto provider = nostd::shared_ptr<trace::TracerProvider>(new sdktrace::TracerProvider(processor));
// Set the global trace provider
trace::Provider::SetTracerProvider(provider);
}
} // namespace

int main()
{
// Removing this line will leave OT initialized with the default noop
// tracer, thus being effectively deactivated.
// Removing this line will leave the default noop TracerProvider in place.
initTracer();

foo_library();
Expand Down

0 comments on commit c86794e

Please sign in to comment.