elasticapm.properties 内的环境变量未解析

Environment variables within elasticapm.properties are not resolved

src/main/resources/elasticapm.properties
server_url=${PROJECT_ELASTICAPM_URL}

当服务器 url 作为 ENV 参数传递给由 [=18 启动的服务时,elasticapm.properties 中的环境变量在运行时未 解析 =].而是抛出以下错误

ch.client.WIRE       : [7f640f1e] Received raw response: 200 OK
2021-04-05 12:51:42,242 [elastic-apm-configuration-reloader] WARN  co.elastic.apm.agent.shaded.stagemonitor.configuration.ConfigurationOption - Error in Attachment configuration: no protocol: ${PROJECT_ELASTICAPM_URL} Default value 'http://localhost:8200' for 'server_url' will be applied.

您可以通过环境变量直接为变量 ELASTIC_APM_SERVER_URL 提供值来提供 server_url 的值。例如:

environment:
  - ELASTIC_APM_SERVICE_NAME=backend-java
  - ELASTIC_APM_SERVER_URL=http://apm-server:8200
  - ELASTIC_APM_APPLICATION_PACKAGES=com.riferrei.backend.*

有关 Elastic APM Java 代理配置的更多信息:

https://www.elastic.co/guide/en/apm/agent/java/current/configuration.html