OpenTelemetry C++ is an exciting observability solution with stable functionality and a wide base of contributors in an active codebase. New Relic is compatible with OpenTelemetry and the benefits it can provide, such as future proofing code by putting end-point agnostic instrumentation calls versus adhering to vendor-specific formats.
Please see the New Relic OpenTelemetry setup for detailed instructions on how to use OpenTelemetry to work with the language of your choice to send data to New Relic.
The OpenTelemetry C++ repository has many fine examples in GitHub. See its CONTRIBUTING.md for further instructions on building and using the OpenTelemetry C++ SDK as well as building and running the examples.
Want to get started right away and see what New Relic can do without having to instrument your code? Follow the steps below for an example that will have you sending data to New Relic in no time.
When you're ready to start instrumenting, please refer to the New Relic OpenTelemetry setup instructions and the OpenTelemetry C++ repository CONTRIBUTING.md for further details on integrating with your code.
Ensure you have the prerequisites outlined in the New Relic OpenTelemetry documentation.
git clone https://github.com/open-telemetry/opentelemetry-cpp.
- Copy the
docker-compose-collector.yaml, and the
config.dev.yamlexample files to the root of the directory cloned in step 1.
config.dev.yamlwith your license key and endpoint.
docker-compose -f docker-compose-collector.yaml up.
- Verify the two containers are running, one for the collector and one for the C++ application.
Open a terminal in the C++ container and run the following commands:
rm -rf *
$cmake -DCMAKE_BUILD_TYPE=Debug \>-DWITH_METRICS_PREVIEW=ON \>-DWITH_LOGS_PREVIEW=ON \>-DCMAKE_CXX_FLAGS="-Wno-error=deprecated-declarations" \>-DWITH_OTLP=ON \>..
Verify data has arrived by querying your New Relic account data:
- To see span data: Go to one.newrelic.com > All capabilities > Query your data and enter this query:
FROM Span SELECT * where telemetry.sdk.name = 'opentelemetry'
- View the OpenTelemetry service by searching for
unknown_servicefor more details.
version: '3.7'services:cpp:build:context: .dockerfile: Dockerfile.ubuntustdin_open: trueenvironment:- OTEL_EXPORTER_OTLP_ENDPOINT=otel-collector:4318volumes:- ./:/usr/src/myappotel-collector:image: otel/opentelemetry-collector-contribstdin_open: truecommand: ["--config=/etc/otel-collector-config.yml"]volumes:- ./config.dev.yaml:/etc/otel-collector-config.ymlports:- "1888:1888" # pprof extension- "8888:8888" # Prometheus metrics exposed by the collector- "8889:8889" # Prometheus exporter metrics- "13133:13133" # health_check extension- "9411" # Zipkin receiver- "4317:4317" # OTLP gRPC receiver- "4318:4318" # OTLP http receiver- "55680:55679" # zpages extensiondepends_on:- cpp
FROM ubuntu:20.04ENV DEBIAN_FRONTEND noninteractive## Update cache and upgrade imageRUN apt-get -y update && apt-get -y upgrade && apt-get -y dist-upgrade## Build environment packagesRUN apt-get install -qq -y --ignore-missing \apt-utils \automake \bc \build-essential \bzip2 \cmake \curl \git \libcurl4-openssl-dev \libssl-dev \libtool-bin \make \pkg-config \protobuf-compiler \libprotobuf-dev \python \sudo \tar \zip \unzip \wget \zlib1g-devWORKDIR /setup-toolsADD ci/setup_ci_environment.sh /setup-toolsADD ci/setup_cmake.sh /setup-toolsADD ci/install_protobuf.sh /setup-toolsRUN /setup-tools/setup_ci_environment.sh \&& /setup-tools/setup_cmake.sh \&& /setup-tools/install_protobuf.shWORKDIR /usr/src/myapp# ENTRYPOINT bashCMD /bin/bash
exporters:newrelic:apikey: 'EDIT_TO_ADD_YOUR_KEY_HERE'timeout: 30shost_override: "otlp.nr-data.net"logging:loglevel: DEBUGreceivers:otlp:protocols:grpc:endpoint: 0.0.0.0:4317http:endpoint: 0.0.0.0:4318cors:allowed_origins:- '*'service:pipelines:traces:receivers:- otlpexporters:- logging- newreliclogs:receivers:- otlpexporters:- logging