someone9388 / splunk-otel-cpp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Getting Started   •   Getting Involved

Beta GitHub release (latest SemVer)


Splunk Distribution of OpenTelemetry C++

The Splunk Distribution of OpenTelemetry C++ is a wrapper that comes with defaults suitable to report distributed traces to Splunk APM.

This distribution comes with the following defaults:

🚧 This project is currently in BETA. It is officially supported by Splunk. However, breaking changes MAY be introduced.

Getting Started

  1. Clone the repository along with submodules
$ git clone --recurse-submodules https://github.com/signalfx/splunk-otel-cpp.git
  1. Build the dependencies and the project
$ ./build_deps.sh -DCMAKE_INSTALL_PREFIX=/path/to/splunk-otel-cpp-install
$ mkdir build
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/path/to/splunk-otel-cpp-install ..
$ make install
  1. When using CMake, find the Splunk OpenTelemetry package at /path/to/splunk-otel-cpp-install
find_package(SplunkOpenTelemetry REQUIRED)
add_program(example example.cpp)
target_link_libraries(example ${SplunkOpenTelemetry_LIBRARIES})
target_include_directories(example ${SplunkOpenTelemetry_INCLUDE_DIRS})

(Optional) Using Conan package manager with CMake

  • Update your conanfile.txt:
    [requires]
    splunk-opentelemetry-cpp/0.4.0
    
    [generators]
    cmake_find_package
    cmake_paths
    
  • Add include(${CMAKE_BINARY_DIR}/conan_paths.cmake) to your CMakeLists.txt
  • Add find_package(SplunkOpenTelemetry REQUIRED) lines described earlier.
  • mkdir build && cd build && conan install .. && cmake .. && make
  1. Use it
#include <splunk/opentelemetry.h>

int main(int argc, char** argv) {
  splunk::OpenTelemetryOptions options =
    splunk::OpenTelemetryOptions()
      .WithServiceName("my-service");

  splunk::InitOpenTelemetry(options);

  // Use the usual OpenTelemetry API
  auto tracer = opentelemetry::trace::Provider::GetTraceProvider()->GetTracer("my-tracer");
  auto span = tracer->StartSpan("operation-name");

  // Do something useful
  span->End();

  return 0;
}

For more examples, see the examples directory.

Configuration options

Via environment variables

Note: options passed via splunk::OpenTelemetryOptions take preference over environment variables.

Environment variable Default value Notes
OTEL_SERVICE_NAME unknown_service Service name of the application
OTEL_RESOURCE_ATTRIBUTES none Comma separated list of Resource attributes. For example OTEL_RESOURCE_ATTRIBUTES=service.name=foo,deployment.environment=production
OTEL_PROPAGATORS tracecontext,baggage Comma separated list of propagators to use. Possible values: tracecontext, b3, b3multi, baggage
OTEL_TRACES_EXPORTER otlp Trace exporter to use. Possible values: otlp, jaeger-thrift-splunk.
OTEL_EXPORTER_OTLP_PROTOCOL grpc OTLP transport to use. Possible values: grpc.
OTEL_EXPORTER_OTLP_ENDPOINT localhost:4317 (gRPC) or http://localhost:4317/v1/traces
OTEL_EXPORTER_JAEGER_ENDPOINT http://localhost:9080/v1/trace Needs to be compiled with Jaeger support
SPLUNK_ACCESS_TOKEN none Only required when Splunk OpenTelemetry Connector is not used.

Requirements

  • C++11 capable compiler
  • Linux (Windows support coming)

License and versioning

The Splunk Distribution of OpenTelemetry C++ is a distribution of the OpenTelemetry C++ project. It is released under the terms of the Apache Software License version 2.0. See the license file for more details.

About

License:Apache License 2.0


Languages

Language:C++ 80.7%Language:Shell 8.6%Language:CMake 7.9%Language:Dockerfile 2.8%