Configuration
editConfiguration
editConfigure the agent with AgentConfigBuilder
passing the AgentConfiguration
to the start
function.
let config = AgentConfigBuilder() .withServerUrl(URL(string: "http://localhost:8200")) .withSecretToken("<Token>") .build() Agent.start(with:config)
The AgentConfigBuilder
can be configured with the following functions
Configuration options
editwithServerUrl
edit- Type: URL
-
Default:
http://127.0.0.1:8200
withSecretToken
edit- Type: String
- Default: nil
-
Env:
OTEL_EXPORTER_OTLP_HEADERS
Sets the secret token for connecting to an authenticated APM Server. If using the env-var, the whole header map must be defined per OpenTelemetry Protocol Exporter Config (e.g.: OTEL_EXPORTER_OTLP_HEADERS="Authorization=bearer <secret token>"
)
This setting is mutually exclusive with withApiKey
withApiKey
edit- Type: String
- Default: nil
-
Env:
OTEL_EXPORTER_OTLP_HEADERS
Sets the API Token for connecting to an authenticated APM Server. If using the env-var, the whole header map must be defined per OpenTelemetry Protocol Exporter Config (e.g.: OTEL_EXPORTER_OTLP_HEADERS="Authorization=ApiKey <key>"
)
This setting is mutually exclusive with withSecretToken
disableAgent() -> Self
editDisables the Elastic agent. This is useful for disabling the agent during development without having to remove the Elastic agent completely. A log will report "Elastic APM Agent has been disabled."
Resource Attribute Injection
editIn v0.5.0, the agent provides a means to set resource attributes using the OTEL_RESOURCE_ATTRIBUTES
env-var. This env-var also works through the application plist. Any resource attribute can be overridden using this method, so care should be taken, as some attributes are critical to the functioning of the kibana UI.
deployment.environment
editDeployment environment is set to default
. This can be overridden using the OTEL_RESOURCE_ATTRIBUTES
set in your deployment’s plist. Use the field key as OTEL_RESOURCE_ATTRIBUTES
and the value as deployment.environment=staging