Getting Started
Welcome to the OpenTelemetry C++ getting started guide! This guide will walk you through the basic steps in installing, instrumenting with, configuring, and exporting data from OpenTelemetry.
You can use CMake or Bazel for building OpenTelemetry C++. The following getting started guide will make use of CMake and only provide you the most essential steps to have a working example application (a HTTP server & HTTP client). For more details read these instructions.
Prerequisites¶
You can build OpenTelemetry C++ on Windows, macOS or Linux. First you need to install some dependencies:
{{< tabpane lang=shell persistLang=false >}}
{{< tab "Linux (apt)" >}} sudo apt-get install git cmake g++ libcurl4-openssl-dev {{< /tab >}}
{{< tab "Linux (yum)" >}} sudo yum install git cmake g++ libcurl-devel {{< /tab >}}
{{< tab "Linux (alpine)" >}} sudo apk add git cmake g++ make curl-dev {{< /tab >}}
{{< tab "MacOS (homebrew)" >}} xcode-select —install /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install git cmake {{< /tab >}}
{{< /tabpane >}}
Building¶
Get the opentelemetry-cpp
source:
Navigate to the repository cloned above, and create the CMake build configuration:
Once build configuration is created, build the CMake targets http_client
and
http_server
:
If all goes well, you should find binaries http_server
and http_client
in
./examples/http
:
Run Application¶
Open two terminals, in the first terminal, start the HTTP server:
In the other terminal, run the HTTP client:
You should see client output similar to this:
Also the server should dump you a trace to the console:
What's next¶
Enrich your instrumentation generated automatically with manual of your own codebase. This gets you customized observability data.
You'll also want to configure an appropriate exporter to export your telemetry data to one or more telemetry backends.