github.com/waldiirawan/apm-agent-go/v2@v2.2.2/docs/configuration.asciidoc (about) 1 [[configuration]] 2 == Configuration 3 4 Adapt the Elastic APM Go agent to your needs with one of the following methods--listed in descending order of precedence: 5 6 1. {apm-app-ref}/agent-configuration.html[APM Agent Configuration via Kibana] 7 (supported options are marked with <<dynamic-configuration, image:./images/dynamic-config.svg[] >>) 8 2. In code, using the <<tracer-config-api, Tracer Config API>> 9 3. Environment variables 10 11 Configuration defined via Kibana will take precedence over the same 12 configuration defined in code, which takes precedence over environment 13 variables. If configuration is defined via Kibana, and then that is 14 later removed, the agent will revert to configuration defined locally 15 via either the Tracer Config API or environment variables. 16 17 // tag::setup-config[] 18 To simplify development and testing, 19 the agent defaults to sending data to the Elastic APM Server at `http://localhost:8200`. 20 To send data to an alternative location, you must configure 21 <<config-server-url, ELASTIC_APM_SERVER_URL>>. Depending on the configuration 22 of your server, you may also need to set <<config-api-key, ELASTIC_APM_API_KEY>>, 23 <<config-secret-token, ELASTIC_APM_SECRET_TOKEN>>, and 24 <<config-verify-server-cert, ELASTIC_APM_VERIFY_SERVER_CERT>>. All other variables 25 have usable defaults. 26 // end::setup-config[] 27 28 [float] 29 [[dynamic-configuration]] 30 === Dynamic configuration 31 32 Configuration options marked with the image:./images/dynamic-config.svg[] badge can be changed at runtime 33 when set from a supported source. 34 35 The Go Agent supports {apm-app-ref}/agent-configuration.html[Central configuration], 36 which allows you to fine-tune certain configurations via the APM app. 37 This feature is enabled in the Agent by default, with <<config-central-config>>. 38 39 [float] 40 === Configuration formats 41 42 Some options require a unit, either duration or size. These need to be provided 43 in a specific format. 44 45 [float] 46 ==== Duration format 47 48 The _duration_ format is used for options like timeouts. The unit is provided as 49 a suffix directly after the number, without any whitespace. 50 51 *Example:* `5ms` 52 53 *Supported units:* 54 55 - `ms` (milliseconds) 56 - `s` (seconds) 57 - `m` (minutes) 58 59 [float] 60 ==== Size format 61 62 The _size_ format is used for options such as maximum buffer sizes. The unit is 63 provided as a suffix directly after the number, without any whitespace. 64 65 *Example:* `10KB` 66 67 *Supported units:* 68 69 - B (bytes) 70 - KB (kilobytes) 71 - MB (megabytes) 72 - GB (gigabytes) 73 74 NOTE: We use the power-of-two sizing convention, e.g. 1KB = 1024B. 75 76 [float] 77 [[config-server-url]] 78 === `ELASTIC_APM_SERVER_URL` 79 80 [options="header"] 81 |============ 82 | Environment | Default | Example 83 | `ELASTIC_APM_SERVER_URL` | `http://localhost:8200` | `http://localhost:8200` 84 |============ 85 86 The URL for your Elastic APM Server. The Server supports both HTTP and HTTPS. 87 If you use HTTPS, then you may need to configure your client machines so 88 that the server certificate can be verified. You can disable certificate 89 verification with <<config-verify-server-cert>>. 90 91 [float] 92 [[config-server-timeout]] 93 === `ELASTIC_APM_SERVER_TIMEOUT` 94 95 [options="header"] 96 |============ 97 | Environment | Default | Example 98 | `ELASTIC_APM_SERVER_TIMEOUT` | `30s` | `30s` 99 |============ 100 101 The timeout for requests made to your Elastic APM server. When set to zero 102 or a negative value, timeouts will be disabled. 103 104 [float] 105 [[config-secret-token]] 106 === `ELASTIC_APM_SECRET_TOKEN` 107 108 [options="header"] 109 |============ 110 | Environment | Default | Example 111 | `ELASTIC_APM_SECRET_TOKEN` | | "A random string" 112 |============ 113 114 This string is used to ensure that only your agents can send data to your APM server. 115 Both the agents and the APM server have to be configured with the same secret token. 116 117 WARNING: The secret token is sent as plain-text in every request to the server, so you 118 should also secure your communications using HTTPS. Unless you do so, your secret token 119 could be observed by an attacker. 120 121 [float] 122 [[config-api-key]] 123 === `ELASTIC_APM_API_KEY` 124 125 [options="header"] 126 |============ 127 | Environment | Default | Example 128 | `ELASTIC_APM_API_KEY` | | "A base64-encoded string" 129 |============ 130 131 This base64-encoded string is used to ensure that only your agents can send data to your APM server. 132 The API key must be created using the APM Server {apm-guide-ref}/api-key.html[command line tool]. 133 134 WARNING: The API Key is sent as plain-text in every request to the server, so you should also secure 135 your communications using HTTPS. Unless you do so, your API Key could be observed by an attacker. 136 137 [float] 138 [[config-service-name]] 139 === `ELASTIC_APM_SERVICE_NAME` 140 141 [options="header"] 142 |============ 143 | Environment | Default | Example 144 | `ELASTIC_APM_SERVICE_NAME` | Executable name | `my-app` 145 |============ 146 147 The name of your service or application. This is used to keep all the errors and 148 transactions of your service together and is the primary filter in the Elastic APM 149 user interface. 150 151 If you do not specify `ELASTIC_APM_SERVICE_NAME`, the Go agent will use the 152 executable name. e.g. if your executable is called "my-app.exe", then your 153 service will be identified as "my-app". 154 155 NOTE: The service name must conform to this regular expression: `^[a-zA-Z0-9 _-]+$`. 156 In other words: your service name must only contain characters from the ASCII 157 alphabet, numbers, dashes, underscores, and spaces. 158 159 [float] 160 [[config-service-version]] 161 === `ELASTIC_APM_SERVICE_VERSION` 162 163 [options="header"] 164 |============ 165 | Environment | Default | Example 166 | `ELASTIC_APM_SERVICE_VERSION` | | A string indicating the version of the deployed service 167 |============ 168 169 A version string for the currently deployed version of the service. 170 If you don't version your deployments, the recommended value for this field is the commit identifier 171 of the deployed revision, e.g. the output of `git rev-parse HEAD`. 172 173 [float] 174 [[config-service-node-name]] 175 === `ELASTIC_APM_SERVICE_NODE_NAME` 176 177 [options="header"] 178 |============ 179 | Environment | Default | Example 180 | `ELASTIC_APM_SERVICE_NODE_NAME` | | `my-node-name` 181 |============ 182 183 Optional name used to differentiate between nodes in a service. 184 Must be unique, otherwise data from multiple nodes will be aggregated together. 185 186 If you do not specify `ELASTIC_APM_SERVICE_NODE_NAME`, service nodes will be identified using the container ID if available, 187 otherwise the host name. 188 189 NOTE: This feature is fully supported in the APM Server versions >= 7.5. 190 191 [float] 192 [[config-environment]] 193 === `ELASTIC_APM_ENVIRONMENT` 194 195 [options="header"] 196 |============ 197 | Environment | Default | Example 198 | `ELASTIC_APM_ENVIRONMENT` | | `"production"` 199 |============ 200 201 The name of the environment this service is deployed in, e.g. "production" or "staging". 202 203 Environments allow you to easily filter data on a global level in the APM app. 204 It's important to be consistent when naming environments across agents. 205 See {apm-app-ref}/filters.html#environment-selector[environment selector] in the APM app for more information. 206 207 NOTE: This feature is fully supported in the APM app in Kibana versions >= 7.2. 208 You must use the query bar to filter for a specific environment in versions prior to 7.2. 209 210 [float] 211 [[config-active]] 212 === `ELASTIC_APM_ACTIVE` 213 214 [options="header"] 215 |============ 216 | Environment | Default | Example 217 | `ELASTIC_APM_ACTIVE` | true | `false` 218 |============ 219 220 Enable or disable the agent. If set to false, then the Go agent does not send 221 any data to the Elastic APM server, and instrumentation overhead is minimized. 222 223 [float] 224 [[config-recording]] 225 === `ELASTIC_APM_RECORDING` 226 227 <<dynamic-configuration, image:./images/dynamic-config.svg[] >> 228 229 [options="header"] 230 |============ 231 | Environment | Default | Example 232 | `ELASTIC_APM_RECORDING` | true | `false` 233 |============ 234 235 Enable or disable recording of events. If set to false, then the Go agent does not 236 send any events to the Elastic APM server, and instrumentation overhead is 237 minimized, but the agent will continue to poll the server for configuration changes. 238 239 [float] 240 [[config-global-labels]] 241 === `ELASTIC_APM_GLOBAL_LABELS` 242 243 [options="header"] 244 |============ 245 | Environment | Default | Example 246 | `ELASTIC_APM_GLOBAL_LABELS` | | `dept=engineering,rack=number8` 247 |============ 248 249 Labels are added to all events. The format for labels is: `key=value[,key=value[,...]]`. 250 Any labels set by application via the API will override global labels with the same keys. 251 252 This option requires APM Server 7.2 or greater, and will have no effect when using older 253 server versions. 254 255 [float] 256 [[config-ignore-urls]] 257 === `ELASTIC_APM_TRANSACTION_IGNORE_URLS` 258 259 [options="header"] 260 |============ 261 | Environment | Default | Example 262 | `ELASTIC_APM_TRANSACTION_IGNORE_URLS` | | `/heartbeat*, *.jpg` 263 |============ 264 265 A list of patterns to match HTTP requests to ignore. An incoming HTTP request 266 whose request line matches any of the patterns will not be reported as a transaction. 267 268 This option supports the wildcard `*`, which matches zero or more characters. 269 Examples: `/foo/*/bar/*/baz*`, `*foo*`. Matching is case insensitive by default. 270 Prefixing a pattern with `(?-i)` makes the matching case sensitive. 271 272 NOTE: This configuration was previously known as `ELASTIC_APM_IGNORE_URLS`, which has been deprecated and will be removed in a future major 273 version of the agent. 274 275 [float] 276 [[config-sanitize-field-names]] 277 === `ELASTIC_APM_SANITIZE_FIELD_NAMES` 278 279 [options="header"] 280 |============ 281 | Environment | Default | Example 282 | `ELASTIC_APM_SANITIZE_FIELD_NAMES` | `password, passwd, pwd, secret, *key, *token*, *session*, *credit*, *card*, *auth*, set-cookie, *principal*` | `sekrits` 283 |============ 284 285 A list of patterns to match the names of HTTP headers, cookies, and POST form fields to redact. 286 287 This option supports the wildcard `*`, which matches zero or more characters. 288 Examples: `/foo/*/bar/*/baz*`, `*foo*`. Matching is case insensitive by default. 289 Prefixing a pattern with `(?-i)` makes the matching case sensitive. 290 291 [float] 292 [[config-capture-headers]] 293 === `ELASTIC_APM_CAPTURE_HEADERS` 294 295 <<dynamic-configuration, image:./images/dynamic-config.svg[] >> 296 297 [options="header"] 298 |============ 299 | Environment | Default 300 | `ELASTIC_APM_CAPTURE_HEADERS` | `true` 301 |============ 302 303 For transactions that are HTTP requests, the Go agent can optionally capture request and response headers. 304 305 Possible values: `true`, `false`. 306 307 Captured headers are subject to sanitization, per <<config-sanitize-field-names>>. 308 309 [float] 310 [[config-capture-body]] 311 === `ELASTIC_APM_CAPTURE_BODY` 312 313 <<dynamic-configuration, image:./images/dynamic-config.svg[] >> 314 315 [options="header"] 316 |============ 317 | Environment | Default 318 | `ELASTIC_APM_CAPTURE_BODY` | `off` 319 |============ 320 321 For transactions that are HTTP requests, the Go agent can optionally capture the request body. 322 323 Possible values: `errors`, `transactions`, `all`, `off`. 324 325 WARNING: Request bodies often contain sensitive values like passwords, credit card numbers, and so on. 326 If your service handles data like this, enable this feature with care. 327 328 [float] 329 [[config-hostname]] 330 === `ELASTIC_APM_HOSTNAME` 331 332 [options="header"] 333 [options="header"] 334 |============ 335 | Environment | Default | Example 336 | `ELASTIC_APM_HOSTNAME` | `os.Hostname()` | `app-server01` 337 |============ 338 339 The host name to use when sending error and transaction data to the APM server. 340 341 [float] 342 [[config-api-request-time]] 343 === `ELASTIC_APM_API_REQUEST_TIME` 344 345 [options="header"] 346 |============ 347 | Environment | Default 348 | `ELASTIC_APM_API_REQUEST_TIME` | `10s` 349 |============ 350 351 The amount of time to wait before ending a request to the Elastic APM server. 352 When you report transactions, spans and errors, the agent will initiate a 353 request and send them to the server when there is enough data to send; the 354 request will remain open until this time has been exceeded, or until the 355 <<config-api-request-size, maximum request size>> has been reached. 356 357 [float] 358 [[config-api-request-size]] 359 === `ELASTIC_APM_API_REQUEST_SIZE` 360 361 [options="header"] 362 |============ 363 | Environment | Default | Minimum | Maximum 364 | `ELASTIC_APM_API_REQUEST_SIZE` | `750KB` | `1KB` | `5MB` 365 |============ 366 367 The maximum size of request bodies to send to the Elastic APM server. 368 The agent will maintain an in-memory buffer of compressed data for streaming 369 to the APM server. 370 371 [float] 372 [[config-api-buffer-size]] 373 === `ELASTIC_APM_API_BUFFER_SIZE` 374 375 [options="header"] 376 |============ 377 | Environment | Default | Minimum | Maximum 378 | `ELASTIC_APM_API_BUFFER_SIZE` | `1MB` | `10KB` | `100MB` 379 |============ 380 381 The maximum number of bytes of uncompressed, encoded events to store in memory 382 while the agent is busy. When the agent is able to, it will transfer buffered 383 data to the request buffer, and start streaming it to the server. If the buffer 384 fills up, new events will start replacing older ones. 385 386 [float] 387 [[config-transaction-max-spans]] 388 === `ELASTIC_APM_TRANSACTION_MAX_SPANS` 389 390 <<dynamic-configuration, image:./images/dynamic-config.svg[] >> 391 392 [options="header"] 393 |============ 394 | Environment | Default 395 | `ELASTIC_APM_TRANSACTION_MAX_SPANS` | `500` 396 |============ 397 398 Limits the amount of spans that are recorded per transaction. 399 400 This is helpful in cases where a transaction creates a large number 401 of spans (e.g. thousands of SQL queries). Setting an upper limit will 402 prevent overloading the agent and the APM server with too much work 403 for such edge cases. 404 405 [float] 406 [[config-exit-span-min-duration]] 407 === `ELASTIC_APM_EXIT_SPAN_MIN_DURATION` 408 409 <<dynamic-configuration, image:./images/dynamic-config.svg[] >> 410 411 [options="header"] 412 |============ 413 | Environment | Default 414 | `ELASTIC_APM_EXIT_SPAN_MIN_DURATION` | `1ms` 415 |============ 416 417 Sets the minimum duration for an exit span to be reported. Spans shorter or 418 equal to this threshold will be dropped by the agent and reported as statistics 419 in the span's transaction, as long as the transaction didn't end before the span 420 was reported. 421 422 When span compression is enabled (<<config-span-compression-enabled>>), the sum 423 of the compressed span composite is considered. 424 425 The minimum duration allowed for this setting is 1 microsecond (`us`). 426 427 [float] 428 [[config-span-frames-min-duration-ms]] 429 === `ELASTIC_APM_SPAN_FRAMES_MIN_DURATION` 430 431 <<dynamic-configuration, image:./images/dynamic-config.svg[] >> 432 433 [options="header"] 434 |============ 435 | Environment | Default 436 | `ELASTIC_APM_SPAN_FRAMES_MIN_DURATION` | `5ms` 437 |============ 438 439 The APM agent will collect a stack trace for every recorded span whose duration 440 exceeds this configured value. While this is very helpful to find the exact 441 place in your code that causes the span, collecting this stack trace does have 442 some processing and storage overhead. 443 444 NOTE: This configuration has been deprecated and will be removed in a future major version of the agent. 445 446 [float] 447 [[config-span-stack-trace-min-duration]] 448 === `ELASTIC_APM_SPAN_STACK_TRACE_MIN_DURATION` 449 450 <<dynamic-configuration, image:./images/dynamic-config.svg[] >> 451 452 [options="header"] 453 |============ 454 | Environment | Default 455 | `ELASTIC_APM_SPAN_STACK_TRACE_MIN_DURATION` | `5ms` 456 |============ 457 458 The APM agent will collect a stack trace for every recorded span whose duration 459 exceeds this configured value. While this is very helpful to find the exact 460 place in your code that causes the span, collecting this stack trace does have 461 some processing and storage overhead. 462 463 NOTE: This configuration was previously known as `ELASTIC_APM_SPAN_FRAMES_MIN_DURATION`, which has been deprecated and will be removed in a future major 464 version of the agent. 465 466 [float] 467 [[config-stack-trace-limit]] 468 === `ELASTIC_APM_STACK_TRACE_LIMIT` 469 470 <<dynamic-configuration, image:./images/dynamic-config.svg[] >> 471 472 [options="header"] 473 |============ 474 | Environment | Default 475 | `ELASTIC_APM_STACK_TRACE_LIMIT` | `50` 476 |============ 477 478 Limits the number of frames captured for each stack trace. 479 480 Setting the limit to 0 will disable stack trace collection, while any positive 481 integer value will be used as the maximum number of frames to collect. Setting 482 a negative value, such as -1, means that all frames will be collected. 483 484 [float] 485 [[config-transaction-sample-rate]] 486 === `ELASTIC_APM_TRANSACTION_SAMPLE_RATE` 487 488 <<dynamic-configuration, image:./images/dynamic-config.svg[] >> 489 490 [options="header"] 491 |============ 492 | Environment | Default 493 | `ELASTIC_APM_TRANSACTION_SAMPLE_RATE` | `1.0` 494 |============ 495 496 By default, the agent will sample every transaction (e.g. request to your service). 497 To reduce overhead and storage requirements, set the sample rate to a value 498 between `0.0` and `1.0`. We still record overall time and the result for unsampled 499 transactions, but no context information, tags, or spans. 500 501 [float] 502 [[config-metrics-interval]] 503 === `ELASTIC_APM_METRICS_INTERVAL` 504 505 [options="header"] 506 |============ 507 | Environment | Default 508 | `ELASTIC_APM_METRICS_INTERVAL` | 30s 509 |============ 510 511 The interval at which APM agent gathers and reports metrics. Set to `0s` to disable. 512 513 [float] 514 [[config-disable-metrics]] 515 === `ELASTIC_APM_DISABLE_METRICS` 516 517 [options="header"] 518 |============ 519 | Environment | Default | Example 520 | `ELASTIC_APM_DISABLE_METRICS` | | `system.*, *cpu*` 521 |============ 522 523 Disables the collection of certain metrics. If the name of a metric matches any of 524 the wildcard expressions, it will not be collected. 525 526 This option supports the wildcard `*`, which matches zero or more characters. 527 Examples: `/foo/*/bar/*/baz*`, `*foo*`. Matching is case insensitive by default. 528 Prefixing a pattern with `(?-i)` makes the matching case sensitive. 529 530 [float] 531 [[config-breakdown-metrics]] 532 === `ELASTIC_APM_BREAKDOWN_METRICS` 533 534 [options="header"] 535 |============ 536 | Environment | Default 537 | `ELASTIC_APM_BREAKDOWN_METRICS` | `true` 538 |============ 539 540 Capture breakdown metrics. Set to `false` to disable. 541 542 [float] 543 [[config-server-cert]] 544 === `ELASTIC_APM_SERVER_CERT` 545 546 [options="header"] 547 |============ 548 | Environment | Default 549 | `ELASTIC_APM_SERVER_CERT` | 550 |============ 551 552 If you have configured your APM Server with a self signed TLS certificate, or you 553 want to pin the server certificate, specify the path to the PEM-encoded 554 certificate via the `ELASTIC_APM_SERVER_CERT` configuration. 555 556 [float] 557 [[config-server-ca-cert-file]] 558 === `ELASTIC_APM_SERVER_CA_CERT_FILE` 559 560 [options="header"] 561 |============ 562 | Environment | Default 563 | `ELASTIC_APM_SERVER_CA_CERT_FILE` | 564 |============ 565 566 The path to a PEM-encoded TLS Certificate Authority certificate that will be 567 used for verifying the server's TLS certificate chain. 568 569 [float] 570 [[config-verify-server-cert]] 571 === `ELASTIC_APM_VERIFY_SERVER_CERT` 572 573 [options="header"] 574 |============ 575 | Environment | Default 576 | `ELASTIC_APM_VERIFY_SERVER_CERT` | `true` 577 |============ 578 579 By default, the agent verifies the server's certificate if you use an 580 HTTPS connection to the APM server. Verification can be disabled by 581 changing this setting to `false`. This setting is ignored when 582 `ELASTIC_APM_SERVER_CERT` is set. 583 584 [float] 585 [[config-log-file]] 586 === `ELASTIC_APM_LOG_FILE` 587 588 [options="header"] 589 |============ 590 | Environment | Default 591 | `ELASTIC_APM_LOG_FILE` | 592 |============ 593 594 `ELASTIC_APM_LOG_FILE` specifies the output file for the agent's default, internal 595 logger. The file will be created, or truncated if it exists, when the process starts. 596 By default, logging is disabled. You must specify `ELASTIC_APM_LOG_FILE` to enable 597 it. This environment variable will be ignored if a logger is configured programatically. 598 599 There are two special file names that the agent recognizes: `stdout` and `stderr`. 600 These will configure the logger to write to standard output and standard error 601 respectively. 602 603 [float] 604 [[config-log-level]] 605 === `ELASTIC_APM_LOG_LEVEL` 606 607 [options="header"] 608 |============ 609 | Environment | Default 610 | `ELASTIC_APM_LOG_LEVEL` | `"error"` 611 |============ 612 613 `ELASTIC_APM_LOG_LEVEL` specifies the log level for the agent's default, internal 614 logger. The only two levels used by the logger are "error" and "debug". By default, 615 logging is disabled. You must specify `ELASTIC_APM_LOG_FILE` to enable it. 616 617 This environment variable will be ignored if a logger is configured programatically. 618 619 [float] 620 [[config-central-config]] 621 ==== `ELASTIC_APM_CENTRAL_CONFIG` 622 623 [options="header"] 624 |============ 625 | Environment | Default 626 | `ELASTIC_APM_CENTRAL_CONFIG` | `true` 627 |============ 628 629 Activate APM Agent Configuration via Kibana. By default the agent will poll the server 630 for agent configuration changes. This can be disabled by changing the setting to `false`. 631 632 NOTE: This feature requires APM Server v7.3 or later and that the APM Server is configured with `kibana.enabled: true`. 633 634 [float] 635 [[config-use-elastic-traceparent-header]] 636 ==== `ELASTIC_APM_USE_ELASTIC_TRACEPARENT_HEADER` 637 |============ 638 | Environment | Default 639 | `ELASTIC_APM_USE_ELASTIC_TRACEPARENT_HEADER` | `true` 640 |============ 641 642 To enable {apm-guide-ref}/apm-distributed-tracing.html[distributed tracing], the agent 643 adds trace context headers to outgoing HTTP requests made with <<builtin-modules-apmhttp>>. 644 These headers (`traceparent` and `tracestate`) are defined in the 645 https://www.w3.org/TR/trace-context-1/[W3C Trace Context] specification. 646 647 When this setting is `true`, the agent will also add the header `elastic-apm-traceparent` 648 for backwards compatibility with older versions of Elastic APM agents. 649 650 [float] 651 [[config-cloud-provider]] 652 ==== `ELASTIC_APM_CLOUD_PROVIDER` 653 654 [options="header"] 655 |============ 656 | Environment | Default | Example 657 | `ELASTIC_APM_CLOUD_PROVIDER` | `"none"` | `"aws"` 658 |============ 659 660 This config value allows you to specify which cloud provider should be assumed 661 for metadata collection. By default, the agent will use trial and error to 662 automatically collect the cloud metadata. 663 664 Valid options are `"none"`, `"auto"`, `"aws"`, `"gcp"`, and `"azure"` 665 If this config value is set to `"none"`, then no cloud metadata will be collected. 666 667 [float] 668 [[config-span-compression-enabled]] 669 === `ELASTIC_APM_SPAN_COMPRESSION_ENABLED` 670 671 <<dynamic-configuration, image:./images/dynamic-config.svg[] >> 672 673 [options="header"] 674 |============ 675 | Environment | Default 676 | `ELASTIC_APM_SPAN_COMPRESSION_ENABLED` | `false` 677 |============ 678 679 When enabled, the agent will attempt to compress _short_ exit spans that share the 680 same parent into a composite span. The exact duration for what is considered 681 _short_, depends on the compression strategy used (`same_kind` or `exact_match`). 682 683 In order for a span to be compressible, these conditions need to be met: 684 685 * Spans are exit spans. 686 * Spans are siblings (share the same parent). 687 * Spans have not propagated their context downstream. 688 * Each span duration is equal or lower to the compression strategy maximum duration. 689 * Spans are compressed with `same_kind` strategy when these attributes are equal: 690 ** `span.type`. 691 ** `span.subtype`. 692 ** `span.context.destination.service.resource` 693 * Spans are compressed with `exact_match` strategy when all the previous conditions 694 are met and the `span.name` is equal. 695 696 Compressing short exit spans should provide some storage savings for services that 697 create a lot of consecutive short exit spans to for example databases or cache 698 services which are generally uninteresting when viewing a trace. 699 700 experimental::["This feature is experimental and requires APM Server v7.15 or later."] 701 702 [float] 703 [[config-span-compression-exact-match-duration]] 704 === `ELASTIC_APM_SPAN_COMPRESSION_EXACT_MATCH_MAX_DURATION` 705 706 <<dynamic-configuration, image:./images/dynamic-config.svg[] >> 707 708 [options="header"] 709 |============ 710 | Environment | Default 711 | `ELASTIC_APM_SPAN_COMPRESSION_EXACT_MATCH_MAX_DURATION` | `50ms` 712 |============ 713 714 The maximum duration to consider for compressing sibling exit spans that are an 715 exact match for compression. 716 717 [float] 718 [[config-span-compression-same-kind-duration]] 719 === `ELASTIC_APM_SPAN_COMPRESSION_SAME_KIND_MAX_DURATION` 720 721 <<dynamic-configuration, image:./images/dynamic-config.svg[] >> 722 723 [options="header"] 724 |============ 725 | Environment | Default 726 | `ELASTIC_APM_SPAN_COMPRESSION_SAME_KIND_MAX_DURATION` | `5ms` 727 |============ 728 729 The maximum duration to consider for compressing sibling exit spans that are of 730 the same kind for compression. 731 732 [float] 733 [[config-trace-continuation-strategy]] 734 === `ELASTIC_APM_TRACE_CONTINUATION_STRATEGY` 735 736 <<dynamic-configuration, image:./images/dynamic-config.svg[] >> 737 738 [options="header"] 739 |============ 740 | Environment | Default 741 | `ELASTIC_APM_TRACE_CONTINUATION_STRATEGY` | `continue` 742 |============ 743 744 This option allows some control over how the APM agent handles W3C trace-context headers on incoming requests. 745 By default, the traceparent and tracestate headers are used per W3C spec for distributed tracing. 746 However, in certain cases it can be helpful to not use the incoming traceparent header. Some example use cases: 747 748 - An Elastic-monitored service is receiving requests with traceparent headers from unmonitored services. 749 - An Elastic-monitored service is publicly exposed, and does not want tracing data (trace-ids, sampling decisions) to possibly be spoofed by user requests. 750 751 Valid options are `continue`, `restart`, and `restart_external`: 752 753 continue:: The default behavior. An incoming `traceparent` value is used to continue the trace and determine the sampling decision. 754 restart:: Always ignores the `traceparent` header of incoming requests. A new trace-id will be generated and the sampling decision will be made based on `transaction_sample_rate`. A span link will be made to the incoming `traceparent`. 755 restart_external:: If an incoming request includes the `es` vendor flag in `tracestate`, then any `traceparent` will be considered internal and will be handled as described for *continue* above. Otherwise, any `traceparent` is considered external and will be handled as described for *restart* above. 756 757 Starting with Elastic Observability 8.2, span links are visible in trace views.