Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,23 @@ If set to `True`, the agent will intercept the default `sys.excepthook`, which a
Whether each transaction should have the process arguments attached. Disabled by default to save disk space.


### `skip_server_info` [config-skip-server-info]

| Environment | Django/Flask | Default |
| --- | --- | --- |
| `ELASTIC_APM_SKIP_SERVER_INFO` | `SKIP_SERVER_INFO` | `False` |

Whether we should skip the server info check to save some latency on constrained environments like AWS Lambda. Disabled by default.

::::{warning}
This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
::::

::::{warning}
This requires sending data to an APM Server newer than 8.7.0 in order to work properly.
::::


## Django-specific configuration [config-django-specific]


Expand Down
1 change: 1 addition & 0 deletions elasticapm/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ class Config(_ConfigBase):
default=TRACE_CONTINUATION_STRATEGY.CONTINUE,
)
include_process_args = _BoolConfigValue("INCLUDE_PROCESS_ARGS", default=False)
skip_server_info = _BoolConfigValue("SKIP_SERVER_INFO", default=False)

@property
def is_recording(self):
Expand Down
6 changes: 5 additions & 1 deletion elasticapm/transport/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ def _get_cache_control_max_age(self, response_headers):

def _process_queue(self) -> None:
if not self.client.server_version:
self.fetch_server_info()
# this is useful on aws lambda environments where this call incurs in unwanted latency
if self.client.config.skip_server_info:
logger.debug("Skipping to fetch server info")
else:
self.fetch_server_info()
super()._process_queue()

def fetch_server_info(self) -> None:
Expand Down
17 changes: 17 additions & 0 deletions tests/transports/test_urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,23 @@ def test_fetch_server_info_flat_string(waiting_httpserver, caplog, elasticapm_cl
assert_any_record_contains(caplog.records, "No version key found in server response")


def test_skip_server_info(waiting_httpserver, elasticapm_client):
elasticapm_client.config.update(version="1", skip_server_info=True)
waiting_httpserver.serve_content(code=202, content="", headers={"Location": "http://example.com/foo"})
transport = Transport(
waiting_httpserver.url, client=elasticapm_client, headers=elasticapm_client._transport._headers
)
transport.start_thread()
try:
url = transport.send("x".encode("latin-1"))
assert url == "http://example.com/foo"
finally:
transport.close()

assert elasticapm_client.server_version is None
assert elasticapm_client.check_server_version(gte=(8, 7, 1))


def test_close(waiting_httpserver, elasticapm_client):
elasticapm_client.server_version = (8, 0, 0) # avoid making server_info request
waiting_httpserver.serve_content(code=202, content="", headers={"Location": "http://example.com/foo"})
Expand Down
Loading