Skip to content

Latest commit

 

History

History

README.md

fluentd Exporter for OpenTelemetry C++

Prerequisite

Installation

CMake Install Instructions

Refer to install instructions INSTALL.md. Modify step 2 to create cmake build configuration for compiling fluentd as below:

   $ cmake ..
   -- The C compiler identification is GNU 9.3.0
   -- The CXX compiler identification is GNU 9.3.0
   ...
   -- Configuring done
   -- Generating done
   -- Build files have been written to: /home/<user>/source/opentelemetry-cpp/build
   $

VCPKG Integration

If integrating with VCPKG, make sure the cmake invocation defines the additional CMAKE_TOOLCHAIN_FILE.

For example:

    $ .../opentelemetry-cpp-contrib2/exporters/fluentd$ ~/vcpkg/vcpkg install
    $ .../opentelemetry-cpp-contrib2/exporters/fluentd$ cmake -D CMAKE_TOOLCHAIN_FILE=/home/niande/vcpkg/scripts/buildsystems/vcpkg.cmake
    $ .../opentelemetry-cpp-contrib2/exporters/fluentd$ make

Incorporating into an existing CMake Project

To use the library from a CMake project, you can locate it directly with find_package and use the imported targets from generated package configurations. As of now, this will import targets for both trace and logs.

# CMakeLists.txt
find_package(opentelemetry-cpp CONFIG REQUIRED)
find_package(opentelemetry-cpp-fluentd CONFIG REQUIRED)
...
target_include_directories(foo PRIVATE ${OPENTELEMETRY_CPP_FLUENTD_INCLUDE_DIRS})
target_link_libraries(foo PRIVATE ${OPENTELEMETRY_CPP_LIBRARIES} ${OPENTELEMETRY_CPP_FLUENTD_LIBRARY_DIRS})

Bazel Install Instructions

TODO

Usage

Install the exporter on your application and pass the options. service_name is an optional string. If omitted, the exporter will first try to get the service name from the Resource. If no service name can be detected on the Resource, a fallback name of "unknown_service" will be used.

opentelemetry::exporter::fluentd::fluentdExporterOptions options;
options.endpoint = "http://localhost:9411/api/v2/spans";
options.service_name = "my_service";

auto exporter = std::unique_ptr<opentelemetry::sdk::trace::SpanExporter>(
    new opentelemetry::exporter::fluentd::fluentdExporter(options));
auto processor = std::shared_ptr<sdktrace::SpanProcessor>(
    new sdktrace::SimpleSpanProcessor(std::move(exporter)));
auto provider = nostd::shared_ptr<opentelemetry::trace::TracerProvider>(
    new sdktrace::TracerProvider(processor, opentelemetry::sdk::resource::Resource::Create({}),
                std::make_shared<opentelemetry::sdk::trace::AlwaysOnSampler>()));

// Set the global tracer provider
opentelemetry::trace::Provider::SetTracerProvider(provider);

Viewing your traces

Please visit the fluentd UI endpoint http://localhost:9411