To adapt the Elastic APM Go agent to your needs, you can configure it using environment variables.
By default, the agent will attempt to send data to the Elastic APM Server
http://localhost:8200, to simplify development and testing. To send
data to an alternative location, you must configure
ELASTIC_APM_SERVER_URL. Depending on the configuration
of your server, you may also need to set ELASTIC_APM_SECRET_TOKEN
and ELASTIC_APM_VERIFY_SERVER_CERT. All other
variables have usable defaults.
The URL for your Elastic APM server. The server supports both HTTP and HTTPS.
If you use HTTPS, then you may need to configure your client machines so
that the server certificate can be verified. You can also disable certificate
"A random string"
This string is used to ensure that only your agents can send data to your APM server. Both the agents and the APM server have to be configured with the same secret token.
the secret token is sent as plain-text in every request to the server, so you should also secure your communications using HTTPS. Unless you do so, your secret token could be observed by an attacker.
The name of your service/application. This is used to keep all the errors and transactions of your service together and is the primary filter in the Elastic APM user interface.
If you do not specify
ELASTIC_APM_SERVICE_NAME, the Go agent will use the
executable name. e.g. if your executable is called "my-app.exe", then your
service will be identified as "my-app".
The service name must conform to this regular expression:
In other words: your service name must only contain characters from the ASCII
alphabet, numbers, dashes, underscores and spaces.
A string indicating the version of the deployed service
A version string for the currently deployed version of the service.
If you don’t version your deployments, the recommended value for this field is the commit identifier
of the deployed revision, e.g. the output of
git rev-parse HEAD.
The name of the environment this service is deployed in, e.g. "production" or "staging".
Enable or disable the tracer. If set to false, then the Go agent does not send any data to the Elastic APM server, and instrumentation overhead is minimized.
A regular expression matching the names of HTTP cookies and POST form fields to redact.
The pattern specified in
ELASTIC_APM_SANITIZE_FIELD_NAMES is treated
case-insensitively by default. To override this behavior and match case-sensitively,
wrap the value like
(?-i:<value>). For a full definition of Go’s regular
expression syntax, see https://golang.org/pkg/regexp/syntax/.
For transactions that are HTTP requests, the Go agent can optionally capture the request body.
request bodies often contain sensitive values like passwords, credit card numbers, etc. If your service handles data like this, enable this feature with care.
The host name to use when sending error and transaction data to the APM server.
Amount of time to wait before sending transactions to the Elastic APM server. Transactions will be batched up and sent periodically. Errors are always sent as soon as possible.
A lower value will increase the load on your APM server, while a higher value can increase the memory pressure on your app. A higher value also impacts the time until transactions are indexed and searchable in Elasticsearch.
Limits the amount of spans that are recorded per transaction.
This is helpful in cases where a transaction creates a large number of spans (e.g. thousands of SQL queries). Setting an upper limit will prevent overloading the agent and the APM server with too much work for such edge cases.
The APM agent will collect a stack trace for every recorded span whose duration exceeds this configured value. While this is very helpful to find the exact place in your code that causes the span, collecting this stack trace does have some processing and storage overhead.
Maximum queue length of transactions before sending transactions to the APM server. A lower value will increase the load on your APM server, while a higher value can increase the memory pressure of your app. A higher value also impacts the time until transactions are indexed and searchable in Elasticsearch.
This setting is useful to limit memory consumption if you experience a sudden spike of traffic. The queue will not grow beyond the configured size; once it has reached capacity, old transactions are dropped in favour of new ones.
By default, the agent will sample every transaction (e.g. request to your service).
To reduce overhead and storage requirements, you can set the sample rate to a value
1.0. We still record overall time and the result for unsampled
transactions, but no context information, tags, or spans.
By default, the agent verifies the server’s certificate if you use an
HTTPS connection to the APM server. Verification can be disabled by
changing this setting to
ELASTIC_APM_DEBUG can be used to debug issues with the Elastic APM Go agent
or your instrumentation. The value should be a comma-separated list of key=value
debug directives. Currently we support just one:
ELASTIC_APM_DEBUG="tracetransport=1", the Go agent will log all
transport calls to the terminal.