Skip to content

Commit bd68b16

Browse files
authored
span_stack_trace_min_duration config spec (#454)
* Add spec for `span_stack_trace_min_duration` config * Update `duration` spec to allow for non-ms suffixes * Required unit suffixes for durations * Review suggestions * Add configuration scope and invalid configuration guidance * Use "precedence" instead of "scope" * Make span_stack_trace_min_duration case-sensitive * Add size as a config type * Add validating regex for size/duration * Clarify config precedence with requirement level keywords * Add case-sensitivity requirements for duration/size * Use `MAY` for config precedence (+typo)
1 parent c9c1912 commit bd68b16

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

specs/agents/configuration.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,53 @@ Here's a list of the config options across all agents, their types, default valu
1010

1111
They are provided as environment variables but depending on the language there might be several feasible ways to let the user tweak them. For example besides the environment variable `ELASTIC_APM_SERVER_URL`, the Node.js Agent might also allow the user to configure the server URL via a config option named `serverUrl`, while the Python Agent might also allow the user to configure it via a config option named `server_url`.
1212

13+
### Configuration Source Precedence
14+
15+
Configuration can be provided via a number of sources. Values from central
16+
configuration MUST have the highest precedence, and default values MUST have
17+
the lowest precedence. Otherwise, agents MAY adopt the following config
18+
source precedence. Sources higher on this list will override values provided
19+
by sources lower on this list:
20+
21+
- Central configuration
22+
- Environment variables
23+
- Inline configuration in code
24+
- Config files
25+
- Default value
26+
27+
### Invalid Configuration Values
28+
29+
If an invalid value for a configuration option is provided (for example:
30+
`breakdown_metrics="yes"` or `apiRequestTime="1h"`) then the agent MUST ignore
31+
the value (falling back to a config source with lower precedence) and SHOULD
32+
emit a log warning about the ignored value.
33+
34+
### Configuration Value Types
35+
36+
The following table enumerates the available configuration types across the
37+
agents:
38+
39+
40+
| Type | Description (if needed) |
41+
|------|-------------------------|
42+
| String | |
43+
| Integer | |
44+
| Float | |
45+
| Boolean | Encoded as a lower-case boolean string: `"false"`, `"true"` |
46+
| List | Encoded as a comma-separated string (whitespace surrounding items should be stripped): `"foo,bar,baz"` |
47+
| Mapping | Encoded as a string, with `"key=value"` pairs separated by commas (whitespace surrounding items should be stripped): `"foo=bar,baz=foo"` |
48+
| Duration | Case-sensitive string with duration encoded using unit suffixes (`ms` for millisecond, `s` for second, `m` for minute). Validating regex: `^(-)?(\d+)(ms|s|m)$` |
49+
| Size | Case-insensitive string with a positive size encoded using unit suffixes (`b` for bytes, `kb` for kilobytes, `mb` for megabytes, `gb` for gigabytes, with a 1024 multiplier between each unit). Validating regex: `^(\d+)(b|kb|mb|gb)$` |
50+
51+
#### Duration/Size Config Legacy Considerations
52+
53+
For duration/size-formatted config options, some agents allow users to omit the unit
54+
suffix for backwards compatibility reasons. Going forward, all
55+
duration/size-formatted config options should require the unit suffix, falling back
56+
to the default value if an invalid value is provided. Existing
57+
duration/size-formatted config options should be changed to require the unit suffix
58+
at the next major version.
59+
1360
### APM Agent Configuration via Kibana
1461

1562
Also known as "central configuration". Agents can query the APM Server for configuration updates; the server proxies and caches requests to Kibana.

specs/agents/tracing-spans.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,36 @@ The documentation should clarify that spans with `unknown` outcomes are ignored
5454

5555
### Span stack traces
5656

57-
Spans may have an associated stack trace, in order to locate the associated source code that caused the span to occur. If there are many spans being collected this can cause a significant amount of overhead in the application, due to the capture, rendering, and transmission of potentially large stack traces. It is possible to limit the recording of span stack traces to only spans that are slower than a specified duration, using the config variable `ELASTIC_APM_SPAN_FRAMES_MIN_DURATION`.
57+
Spans may have an associated stack trace, in order to locate the associated
58+
source code that caused the span to occur. If there are many spans being
59+
collected this can cause a significant amount of overhead in the application,
60+
due to the capture, rendering, and transmission of potentially large stack
61+
traces. It is possible to limit the recording of span stack traces to only
62+
spans that are slower than a specified duration, using the config variable
63+
`span_stack_trace_min_duration`. (Previously
64+
`span_frames_min_duration`.)
65+
66+
#### `span_stack_trace_min_duration` configuration
67+
68+
Sets the minimum duration of a span for which stack frames/traces will be
69+
captured.
70+
71+
This values for this option are case-sensitive.
72+
73+
| | |
74+
|----------------|---|
75+
| Valid options | [duration](configuration.md#configuration-value-types) |
76+
| Default | `5ms` (soft default, agents may modify as needed) |
77+
| Dynamic | `true` |
78+
| Central config | `true` |
79+
80+
A negative value will result in never capturing the stack traces.
81+
82+
A value of `0` (regardless of unit suffix) will result in always capturing the
83+
stack traces.
84+
85+
A non-default value for this configuration option should override any value
86+
set for the deprecated `span_frames_min_duration`.
5887

5988
### Exit spans
6089

0 commit comments

Comments
 (0)