From 2710f4dea3f6f14dd13545af4a81585772ef44d1 Mon Sep 17 00:00:00 2001 From: tomershafir Date: Sun, 24 Dec 2023 15:55:30 +0200 Subject: [PATCH] fix: send sampleRate url param only when needed --- .../java/io/pyroscope/javaagent/impl/PyroscopeExporter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/agent/src/main/java/io/pyroscope/javaagent/impl/PyroscopeExporter.java b/agent/src/main/java/io/pyroscope/javaagent/impl/PyroscopeExporter.java index 850ab4d..2979a2a 100644 --- a/agent/src/main/java/io/pyroscope/javaagent/impl/PyroscopeExporter.java +++ b/agent/src/main/java/io/pyroscope/javaagent/impl/PyroscopeExporter.java @@ -1,6 +1,7 @@ package io.pyroscope.javaagent.impl; import io.pyroscope.http.Format; +import io.pyroscope.javaagent.EventType; import io.pyroscope.javaagent.Snapshot; import io.pyroscope.javaagent.api.Exporter; import io.pyroscope.javaagent.api.Logger; @@ -147,10 +148,11 @@ private HttpUrl urlForSnapshot(final Snapshot snapshot) { .addQueryParameter("name", nameWithStaticLabels()) .addQueryParameter("units", snapshot.eventType.units.id) .addQueryParameter("aggregationType", snapshot.eventType.aggregationType.id) - .addQueryParameter("sampleRate", Long.toString(config.profilingIntervalInHertz())) .addQueryParameter("from", Long.toString(started.getEpochSecond())) .addQueryParameter("until", Long.toString(finished.getEpochSecond())) .addQueryParameter("spyName", Config.DEFAULT_SPY_NAME); + if (EventType.CPU == snapshot.eventType || EventType.ITIMER == snapshot.eventType || EventType.WALL == snapshot.eventType) + builder.addQueryParameter("sampleRate", Long.toString(config.profilingIntervalInHertz())); if (config.format == Format.JFR) builder.addQueryParameter("format", "jfr"); return builder.build();