You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tuning.asciidoc
+15-11Lines changed: 15 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
== Performance tuning
3
3
4
4
Using an APM solution comes with certain trade-offs, and the Python agent for Elastic APM is no different.
5
-
Instrumenting your code, measuring timings, recording context data, etc., all need resources:
5
+
Instrumenting your code, measuring timings, recording context data, etc., all need resources:
6
6
7
7
* CPU time
8
8
* memory
@@ -67,24 +67,28 @@ In some cases, however, the number of spans can explode:
67
67
68
68
* long-running transactions
69
69
* unoptimized code, e.g. doing hundreds of SQL queries in a loop
70
-
70
+
71
71
To avoid these edge cases overloading both the agent and the APM Server,
72
72
the agent stops recording spans when a specified limit is reached.
73
73
You can configure this limit by changing the <<config-transaction-max-spans,`transaction_max_spans`>> setting.
74
74
75
-
Another option to reduce the overhead of collecting contextual data for spans is to disable collection for very short spans.
76
-
While this contextual data (specifically, the stack trace) can be very useful to pinpoint where exactly the span is caused in your code,
77
-
it is less interesting for very short spans.
78
-
You can define a minimal threshold for span duration in milliseconds,
79
-
using the <<config-span-frames-min-duration,`span_frames_min_duration`>> setting.
80
-
If a span takes less than this duration, no stack frames will be collected for this span.
81
-
Other contextual information, like the SQL query, will still be available.
75
+
[float]
76
+
[[tuning-span-stack-trace-collection]]
77
+
=== Span Stack Trace Collection
78
+
79
+
Collecting stack traces for spans can be fairly costly from a performance standpoint.
80
+
Stack traces are very useful for pinpointing which part of your code is generating a span;
81
+
however, these stack traces are less useful for very short spans (as problematic spans tend to be longer).
82
+
83
+
You can define a minimal threshold for span duration
84
+
using the <<config-span-stack-trace-min-duration,`span_stack_trace_min_duration`>> setting.
85
+
If a span's duration is less than this config value, no stack frames will be collected for this span.
82
86
83
87
[float]
84
88
[[tuning-frame-context]]
85
89
=== Collecting Frame Context
86
90
87
-
When a stack trace is captured, the agent will also capture several lines of source code around each frame location in the stack trace. This allows the APM app to give greater insight into where exactly the error or span happens.
91
+
When a stack trace is captured, the agent will also capture several lines of source code around each frame location in the stack trace. This allows the APM app to give greater insight into where exactly the error or span happens.
88
92
89
93
There are four settings you can modify to control this behavior:
90
94
@@ -93,7 +97,7 @@ There are four settings you can modify to control this behavior:
As you can see, these settings are divided between app frames, which represent your application code, and library frames, which represent the code of your dependencies. Each of these categories are also split into separate error and span settings.
100
+
As you can see, these settings are divided between app frames, which represent your application code, and library frames, which represent the code of your dependencies. Each of these categories are also split into separate error and span settings.
97
101
98
102
Reading source files inside a running application can cause a lot of disk I/O, and sending up source lines for each frame will have a network and storage cost that is quite high. Turning down these limits will help prevent excessive memory usage.
0 commit comments