Upgrading an Embedded Agent¶
What each release since 4.0 changed for code that embeds the agent, and what to do about it. A release that changed nothing an embedding app sees isn't listed; the changelog lists every change. For the proxy your app's agent connects to, and the standalone agents beside it, see Upgrading the Proxy and Agents, including which versions work together.
Upgrading from 4.8.0¶
- An app written in Kotlin needs Kotlin 2.4 or later to compile. The agent, the Ktor plugin, and the Spring Boot
starter are built with Kotlin 2.5, and Kotlin 2.3 refuses their classes on the compile classpath, even where the
app's code names none of them:
module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.5.0, expected version is 2.3.0. 4.8.0 compiled with Kotlin 2.3. A Java app isn't affected. - The agent logs a WARN at startup for each setting it's given that isn't one, naming the nearest: a key of the
Configgiven tostartAsyncAgent, asetting()key, and the Ktor plugin's and the Spring Boot starter'ssettingskeys. The Ktor plugin warns the same way about a key of itsprometheus-proxy.agentsection that it doesn't read. Such a setting never had an effect: fix its name.
Upgrading from 4.7.0¶
- The agent's relayed dashboard shows on any proxy with
proxy.dashboard.agentScreenson, through the agent's connection, whether or not the app turns its direct dashboard on: its paths, target URLs, scrapes, and activity, to everyone who can sign in to that proxy's dashboard. To keep the app's agent off every proxy, callsetting("dashboard.showOnProxy", false), or set the Ktor plugin's or the Spring Boot starter'ssettings.dashboard.showOnProxytofalse. Unless you do, an agent with its direct dashboard off now keeps its activity feed in memory, withindashboard.activityLogSize, and refuses to start with adashboard.refreshIntervalSecs,dashboard.pathHistorySize, ordashboard.activityLogSizethat isn't positive; 4.7.0 checked only the last two, and only with the direct dashboard on. - The agent's direct dashboard, when it's on, allows framing by default, so any page can show it
in a frame, such as a portal's. 4.7.0 refused framing on every dashboard response. To keep refusing it, call
setting("dashboard.framingEnabled", false), or set the Ktor plugin's or the Spring Boot starter'ssettings.dashboard.framingEnabledtofalse(see Exposure). shutdown()andclose(), andAgent.stop(), throw anIllegalStateException, with thejava.util.concurrent.TimeoutExceptionas its cause, for an agent without astopTimeoutthat doesn't stop within 30 seconds. Through 4.7.0 they threw theTimeoutExceptionitself, which they didn't declare, so Java code couldn't catch it, and a catch ofRuntimeExceptionmissed it. Kotlin code that caughtTimeoutExceptionthere should catchIllegalStateException(seeEmbeddedAgentInfo).- The Spring Boot starter's stop waits for the agent at most its new
prometheus-proxy.agent.stop-timeout, 30 seconds by default, then returns, with a warning, and the agent goes on stopping on a separate daemon thread. Through 4.7.0 it waited the agent's 30 seconds, then threw out ofstop(). Setstop-timeoutinside the window your platform gives the app to stop (see Properties). startIfConfigured(onFailure)logs an exception itsonFailurethrows, and still returnsnull, as it does for the handlers the builder's newonFailureadds. Through 4.7.0 the exception escaped the call. An app that can't run without its agent should callstart(), which throws, instead.- An agent refuses a path of more than one segment, such as
app/metricsor//metrics, which no scrape could reach: through 4.7.0 the agent started with it and served nothing there. ApathConfigsentry in the configstartAsyncAgent()is given now fails its start withConfigLoadException, naming the path. The builder'spath(),scrapeSelf(),source(), andagentMetricsAt()throw it as they're called, beforestartIfConfigured()can catch it. A Ktor plugin or Spring Boot starter path, itspath,metrics-proxy-path, or apathsentry's, keeps the agent off, telling theonFailurehandlers, or fails arequiredagent's app. Give each path one segment, such asapp_metrics. - The builder's
path()throwsConfigLoadExceptionfor a blank URL, andpath()andscrapeSelf()for/alone as a path, as they're called. Through 4.7.0 they took them, and the agent skipped the target at startup with only a warning. A Ktor plugin or Spring Boot starterpathsentry without aurl, as an unset environment variable leaves it, or with/alone as itspath, therefore keeps the agent off, telling theonFailurehandlers, or fails arequiredagent's app, where the agent started without that target. Give the entry its URL, or leave it out. A filepathorlabelsthe Ktor plugin can't read, such aslabels = "team=web"where a section belongs, fails the agent's start in the same way, where it failedinstall(PrometheusProxyAgent), the agent enabled or not. - An agent refuses to start with a proxy endpoint it can't dial: one with no host, such as
:50051or[], or with anything but:portafter a bracketed IPv6 address, such as[::1]50051, whether it comes fromproxy(),fromEnvironment()'sPROMETHEUS_PROXY, asetting(), orPROXY_HOSTNAME.start()throwsConfigLoadException, naming it, andstartIfConfigured()logs that and returnsnull. Through 4.7.0, as the only or first endpoint, one with no host failed the start with a less clear message; as a later failover entry, it let the agent start and failed each connect that reached it, and[::1]50051dialed[::1]on the default port. Write the endpoint in full, such as[::1]:50051. - A TLS certificate, key, or trust collection file that exists but can't be read, such as one the app's user may not
open, and TLS material the agent can't build its TLS context from, fail the start with
ConfigLoadException, naming the setting, as any setting the agent rejects does. Through 4.7.0 they reached the app as aFileNotFoundExceptionor anSSLException. Code that caught either there should catchConfigLoadException.
Upgrading from 4.6.x¶
- The agent no longer brings Logback. Through 4.6.0,
ch.qos.logback:logback-classiccame with it, at runtime scope, and displaced an application's SLF4J provider: Spring Boot failed to start an app on Log4j2, or ignored its Log4j2 configuration. The agent's loggers now go to your application's provider. An application that logged through the Logback the agent brought, with no SLF4J provider of its own, now gets SLF4J's warning that it found none, and no logs, so add Logback to it (see Logging). - The agent reads
DASHBOARD_ENABLED,DASHBOARD_PORT,DASHBOARD_PATH,DASHBOARD_HOST,DASHBOARD_USERNAME,DASHBOARD_PASSWORD, andMETRICS_PROXY_PATHfrom your application's environment, which through 4.6.0 only the proxy read, or nothing did. If your application sets any of them for its own use, the agent now opens its dashboard, on port 8095 unlessDASHBOARD_PORTnames another, or serves its metrics at that path, and a value it can't parse, such as an emptyDASHBOARD_PORT, or a dashboard port that's taken, fails its start. - An agent started with
startAsyncAgent()orEmbeddedAgentConfigregisters no JVM shutdown hook. Through 4.6.0 it did, and on SIGTERM it stopped at the same time as your application's hooks, in no set order. Stop it withshutdown()orclose()where your application stops its services (seeEmbeddedAgentInfo); one that's never stopped ends with the JVM, without draining the scrapes in flight. - An agent started with
startAsyncAgent()orEmbeddedAgentConfigruns on a daemon thread, so it no longer keeps the JVM running. Through 4.6.0 its thread did: an application that failed after starting the agent never exited, and a program whosemain()only started the agent kept running. That program now exits at once, unless the agent's admin or metrics port is on, whose servers' threads keep the JVM running until the agent stops. Keepmain()running for as long as the agent is needed, or start the agent as the standalone agent does, withstartSyncAgent(). - In an application on Spring Boot 4.0 or 4.1, set
kotlin-coroutines.versionto1.11.0andprometheus-client.versionto1.10.0: Spring Boot's dependency management sets kotlinx-coroutines and the Prometheus Java client below the versions the agent runs on. The agent now checks both as it starts, and refuses to start with either too old, naming the property to set, where it failed once it ran. Spring Boot 4.2 needs neither (see Spring Boot Starter). - A JVM
Error, such as anOutOfMemoryError, in the agent's connection to the proxy stops the agent, as one in a scrape already did, and the app runs on without it, withisConnectedfalse. Through 4.6.0 it ended only the connection, and the agent reconnected and ran on in whatever state theErrorleft it in.
Upgrading from 4.4.x¶
startAsyncAgent()throwsConfigLoadExceptionfor a config that loads but holds a setting the agent can't use, as listed underAgent.startAsyncAgent(). Through 4.4.2 those escaped as anIllegalArgumentExceptionor a TypesafeConfigException, and aConfigException's message began with the config URL, credentials included. Code that caught either should catchConfigLoadException; theIllegalArgumentExceptionis now its cause.- The library jar no longer carries a
logback.xml. Through 4.4.2 it did, and Logback, and Spring Boot ahead of yourlogback-spring.xml, took it for your application's configuration. An application with no Logback configuration of its own now gets Logback's default, which logs everything at DEBUG, so add one (see Logging); one whose configuration was being replaced gets it back. - Maven builds now get Jackson 2.23.0 and netty-tcnative 2.0.86.Final, natives included, through the agent, where they got Jackson 2.12.7 and the 2.0.84.Final natives. A Jackson your build declares itself still wins.
- The agent's generated gRPC classes need protobuf-java 4.36.2 or later, which Maven and Gradle builds now resolve
through it, where they got 3.25.9. Your code generated by protoc 3.x keeps working on it. A build that pins
protobuf-java to 3.x must move the pin to 4.36.2 or later, or the agent fails when it connects, with a
NoClassDefFoundErrorforcom.google.protobuf.RuntimeVersion.
Upgrading from 4.1.x¶
- The agent moved from the Prometheus Java client 0.x (
io.prometheus:simpleclient0.16.0) to 1.x (io.prometheus:prometheus-metrics-core1.9.0), and its metrics now register in the 1.x default registry. A host that serves the 0.xCollectorRegistryno longer exposes them. To serve both from one endpoint, serve the 1.x registry and bridge your 0.x metrics into it: addio.prometheus:prometheus-metrics-simpleclient-bridge, at the same version as theprometheus-metrics-corethe agent brings, and callSimpleclientCollector.builder().register()once at startup. simpleclientno longer arrives through the agent. If your application relied on getting it that way, declare it yourself.- With the agent's metrics endpoint on, the
_createdseries of its counters and histograms are gone (setIO_PROMETHEUS_EXPORTER_INCLUDE_CREATED_TIMESTAMPS=trueto bring them back), and with the JVM exports on, the JVM memory metrics are renamed (see JVM Metrics).
Upgrading from 4.0.x¶
grpc-netty-shadedno longer arrives through the agent, which uses the unshadedgrpc-nettytransport. If your application relied on getting it that way, declare it yourself.startAsyncAgent()now waits for the agent to start and throws if it fails, where it used to return a handle to an agent that had failed (seeAgent.startAsyncAgent()).- When a config URL's error message has to be redacted, the
ConfigLoadException's cause is a stand-in exception with the redacted message and the original stack trace, not Typesafe'sConfigException, so code that checkscause is ConfigExceptionno longer matches it.