New announcements for Serverless, Network, RUM, and more from Dash! New announcements from Dash!

APM Troubleshooting

When experiencing unexpected behavior with Datadog APM, there are a few common issues you can look for before reaching out to Datadog support:

  1. Make sure the Agent has APM enabled:

    Run the following command on the Agent host: netstat -anp | grep 8126.

    If you don’t see an entry, then the Agent is not listening on port 8126, which usually means either that the Agent is not running or that APM is not enabled in your datadog.yaml file. See the APM Agent setup documentation for more information.

  2. Ensure that the Agent is functioning properly:

    In some cases the Agent may have issues sending traces to Datadog. Enable Agent debug mode and check the Trace Agent logs to see if there are any errors.

  3. Verify that your tracer is running correctly:

    After having enabled tracer debug mode, check your Agent logs to see if there is more info about your issue.

If there are errors that you don’t understand, or traces are reported to be flushed to Datadog and you still cannot see them in the Datadog UI, contact Datadog support and provide the relevant log entries with a flare.

Tracer debug mode

Datadog debug settings are used to diagnose issues or audit trace data. Enabling debug mode in production systems is not recommended, as it increases the number of events that are sent to your loggers. Use it sparingly, for debugging purposes only.

Debug mode is disabled by default. To enable it, follow the corresponding language tracer instructions:

To enable debug mode for the Datadog Java Tracer, set the flag -Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug when starting the JVM.

Note: Datadog Java Tracer implements SL4J SimpleLogger. As such, all of its settings can be applied like logging to a dedicated log file: -Ddatadog.slf4j.simpleLogger.logFile=<NEW_LOG_FILE_PATH>

To enable debug mode for the Datadog Python Tracer, set the environment variable DATADOG_TRACE_DEBUG=true when using ddtrace-run.

To enable debug mode for the Datadog Ruby Tracer, set the debug option to true in the tracer initialization configuration:

Datadog.configure do |c|
  c.tracer debug: true
end

Application Logs:

By default, all logs are processed by the default Ruby logger. When using Rails, you should see the messages in your application log file.

Datadog client log messages are marked with [ddtrace], so you can isolate them from other messages.

Additionally, it is possible to override the default logger and replace it with a custom one. This is done using the log attribute of the tracer.

f = File.new("<FILENAME>.log", "w+")           # Log messages should go there
Datadog.configure do |c|
  c.tracer log: Logger.new(f)                 # Overriding the default tracer
end

Datadog::Tracer.log.info { "this is typically called by tracing code" }

See the API documentation for more details.

To enable debug mode for the Datadog Go Tracer, enable the debug mode during the Start config:

package main

import "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"

func main() {
    tracer.Start(tracer.WithDebugMode(true))
    defer tracer.Stop()
}

To enable debug mode for the Datadog Node.js Tracer, enable it during its init:

const tracer = require('dd-trace').init({
  debug: true
})

Application Logs:

By default, logging from this library is disabled. In order to get debbuging information and errors sent to logs, the debug options should be set to true in the init() method.

The tracer will then log debug information to console.log() and errors to console.error(). This behavior can be changed by passing a custom logger to the tracer. The logger should contain debug() and error() methods that can handle messages and errors, respectively.

For example:

const bunyan = require('bunyan')
const logger = bunyan.createLogger({
  name: 'dd-trace',
  level: 'trace'
})

const tracer = require('dd-trace').init({
  logger: {
    debug: message => logger.trace(message),
    error: err => logger.error(err)
  },
  debug: true
})

Then check the Agent logs to see if there is more info about your issue:

  • If the trace was sent to the Agent properly, you should see Response from the Agent: OK log entries. This indicates that the tracer is working properly, therefore the problem may be with the Agent itself. Refer to the Agent troubleshooting guide for more information.

  • If an error was reported by the Agent (or the Agent could not be reached), you will see Error from the Agent log entries. In this case, validate your network configuration to ensure the Agent can be reached. If you are confident the network is functional and that the error is coming from the Agent, refer to the Agent troubleshooting guide.

If neither of these log entries is present, then no request was sent to the Agent, which means that the tracer is not instrumenting your application. In this case, contact Datadog support and provide the relevant log entries with a flare.

For more tracer settings, check out the API documentation.

To enable debug mode for the Datadog .NET Tracer, set the isDebugEnabled argument to true when creating a new tracer instance:

using Datadog.Trace;

var tracer = Tracer.Create(isDebugEnabled: true);

// optional: set the new tracer as the new default/global tracer
Tracer.Instance = tracer;

To enable debug mode for the Datadog PHP Tracer, set the environment variable DD_TRACE_DEBUG=true. See the PHP configuration docs for details about how and when this environment variable value should be set in order to be properly handled by the tracer.

In order to tell PHP where it should put error_log messages, you can either set it at the server level, or as a PHP ini parameter, which is the standard way to configure PHP behavior.

If you are using an Apache server, use the ErrorLog directive. If you are using an NGINX server, use the error_log directive. If you are configuring instead at the PHP level, use PHP’s error_log ini parameter.

The release binary libraries are all compiled with debug symbols added to the optimized release. It is possible to use gdb or lldb to debug the library and to read core dumps. If you are building the library from source, pass the argument -DCMAKE_BUILD_TYPE=RelWithDebInfo to cmake to compile an optimized build with debug symbols.

cd .build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
make
make install

Further Reading