Enable distributed tracing for your C applications

This document explains how to enable and instrument distributed tracing for the New Relic's C SDK.

Enable distributed tracing

To enable distributed tracing for a New Relic-monitored C application:

  1. Create a default newrelic_app_config_t and set the distributed_tracing.enabled field to true.

    newrelic_app_config_t* config
        = newrelic_create_app_config(app_name, license_key);
    config->distributed_tracing.enabled = true;
  2. Continue with the procedures to instrument transactions and HTTP requests.

Instrument transactions and HTTP requests

For transactions that occur in multiple services, the distributed trace payload contains information that allows New Relic to stitch them together into a complete transaction trace. However, if New Relic-monitored services are not sending trace context to each other, it will result in incomplete trace details. For more information, see the documentation about passing the distributed tracing API header and the C SDK's distributed tracing documentation on GitHub.

If you want to... Use this

Create and return a payload to be sent to the called service

newrelic_create_distributed_trace_payload()

Accept a payload sent from the first service

newrelic_accept_distributed_trace_payload()

This will link these services together in a trace.

Return a base64-encoded JSON string representation of the payload
newrelic_create_distributed_trace_payload_httpsafe()

This offers the same behavior as newrelic_create_distributed_trace_payload().

Accept a base64-encoded string for the payload
newrelic_accept_distributed_trace_payload_httpsafe()

This offers the same behavior as newrelic_accept_distributed_trace_payload().

For more help

Recommendations for learning more: