Embedded Agent Config
An embedded agent's settings, built in code with typed methods rather than as a config file, and started with start. It suits an app that holds the agent's settings itself, such as a token, the proxy's certificate, or the credentials for its own /metrics: they're held in memory and never written to disk.
From Java, build one with builder; from Kotlin, with embeddedAgent:
val agent =
embeddedAgent {
name = "my-app-$version"
proxy = "proxy.example.com:50051"
token = agentToken
trustCertificatePem(pem = certificatePem, authority = "prometheus-proxy")
scrapeSelf(path = "my_app_metrics", port = 8080, username = user, password = password)
}.start(logBanner = false)It builds the same tree a config file holds, rooted at agent, so starting it behaves as Agent.startAsyncAgent does with a Config: the built-in defaults fill in what isn't set, the environment variables of single settings take precedence, and a setting the agent can't use throws ConfigLoadException. toConfig gives the tree itself.
Types
Builds an EmbeddedAgentConfig. Each method returns the builder, so calls chain in Java and read as statements in Kotlin's embeddedAgent block; a method called twice keeps its last value, and path and scrapeSelf add a path each time. Anything the builder has no method for, setting sets by its key. A value the builder can tell is wrong, such as a port out of range, throws ConfigLoadException, as start does for one the agent rejects.
Where an EmbeddedAgentConfig starts.
Functions
Starts an agent with these settings, as Agent.startAsyncAgent does with a Config, and returns its handle once it has started.