Performance Tuningedit

There are many options available to tune agent performance. Which option to adjust depends on whether you are optimizing for speed, memory usage, bandwidth or storage.

Samplingedit

The first knob to reach for when tuning the performance of the agent is TransactionSampleRate. Adjusting the sample rate controls what percent of requests are traced. By default, the sample rate is set at 1.0, meaning all requests are traced.

The sample rate will impact all four performance categories, so simply turning down the sample rate is an easy way to improve performance.

Here’s an example of setting the sample rate to 20% using Configuration on ASP.NET Core:

{
    "ElasticApm": {
        "TransactionSampleRate": 0.2
    }
}

Stack Tracesedit

In a complex application, a request may produce many spans. Capturing a stack trace for every span can result in significant memory usage. Stack traces are also captured for every error. There are several settings to adjust how stack traces are captured.

Disable capturing stack tracesedit

To disable capturing stack traces (for both spans and errors), set StackTraceLimit to 0.

Capture stack traces only for long running spansedit

In its default settings, the APM agent collects a stack trace for every recorded span with duration longer than 5ms. To increase the duration threshold, set SpanFramesMinDuration.

Reduce number of captured stack trace framesedit

The StackTraceLimit controls how many stack frames should be collected when a capturing stack trace.

Disable capturing HTTP request and response headersedit

Capturing HTTP request and response headers increases memory allocations, network bandwidth and disk space used by Elasticsearch. To disable capturing HTTP request and response headers, set CaptureHeaders to false.

Increase metrics collection intervaledit

The .NET agent tracks certain system and application metrics. These metrics are regularly collected and sent to the APM Server and from there to Elasticsearch. You can adjust the interval for metrics collection with the setting MetricsInterval.