-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add jetty.yaml to JMX scraper (#1517)
- Loading branch information
1 parent
e0fbc71
commit df4960b
Showing
9 changed files
with
224 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
...ionTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/JettyIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.contrib.jmxscraper.target_systems; | ||
|
||
import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertGauge; | ||
import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertGaugeWithAttributes; | ||
import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertSumWithAttributes; | ||
import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertSumWithAttributesMultiplePoints; | ||
|
||
import io.opentelemetry.contrib.jmxscraper.JmxScraperContainer; | ||
import java.time.Duration; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
import org.testcontainers.images.builder.ImageFromDockerfile; | ||
|
||
public class JettyIntegrationTest extends TargetSystemIntegrationTest { | ||
|
||
@Override | ||
protected GenericContainer<?> createTargetContainer(int jmxPort) { | ||
GenericContainer<?> container = | ||
new GenericContainer<>( | ||
new ImageFromDockerfile() | ||
.withDockerfileFromBuilder( | ||
builder -> | ||
builder | ||
.from("jetty:11") | ||
.run( | ||
"java", | ||
"-jar", | ||
"/usr/local/jetty/start.jar", | ||
"--add-to-startd=jmx,stats,http") | ||
.run("mkdir -p /var/lib/jetty/webapps/ROOT/") | ||
.run("touch /var/lib/jetty/webapps/ROOT/index.html") | ||
.build())); | ||
|
||
container | ||
.withEnv("JAVA_OPTIONS", genericJmxJvmArguments(jmxPort)) | ||
.withStartupTimeout(Duration.ofMinutes(2)) | ||
.waitingFor(Wait.forLogMessage(".*Started Server.*", 1)); | ||
|
||
return container; | ||
} | ||
|
||
@Override | ||
protected JmxScraperContainer customizeScraperContainer(JmxScraperContainer scraper) { | ||
return scraper.withTargetSystem("jetty"); | ||
} | ||
|
||
@Override | ||
protected void verifyMetrics() { | ||
waitAndAssertMetrics( | ||
metric -> | ||
assertSumWithAttributes( | ||
metric, | ||
"jetty.session.count", | ||
"The number of sessions established in total.", | ||
"{session}", | ||
attrs -> attrs.containsKey("resource")), | ||
metric -> | ||
assertSumWithAttributes( | ||
metric, | ||
"jetty.session.time.total", | ||
"The total time sessions have been active.", | ||
"s", | ||
attrs -> attrs.containsKey("resource")), | ||
metric -> | ||
assertGaugeWithAttributes( | ||
metric, | ||
"jetty.session.time.max", | ||
"The maximum amount of time a session has been active.", | ||
"s", | ||
attrs -> attrs.containsKey("resource")), | ||
metric -> | ||
assertSumWithAttributesMultiplePoints( | ||
metric, | ||
"jetty.select.count", | ||
"The number of select calls.", | ||
"{operation}", | ||
/* isMonotonic= */ true, | ||
// minor divergence from jetty.groovy with extra metrics attributes | ||
attrs -> attrs.containsKey("context").containsKey("id")), | ||
metric -> | ||
assertGaugeWithAttributes( | ||
metric, | ||
"jetty.thread.count", | ||
"The current number of threads.", | ||
"{thread}", | ||
attrs -> attrs.containsEntry("state", "busy"), | ||
attrs -> attrs.containsEntry("state", "idle")), | ||
metric -> | ||
assertGauge( | ||
metric, | ||
"jetty.thread.queue.count", | ||
"The current number of threads in the queue.", | ||
"{thread}")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
|
||
rules: | ||
|
||
- bean: org.eclipse.jetty.io:context=*,type=managedselector,id=* | ||
mapping: | ||
selectCount: | ||
metric: jetty.select.count | ||
type: counter | ||
unit: "{operation}" | ||
desc: The number of select calls. | ||
metricAttribute: | ||
# minor divergence from jetty.groovy with extra attribute(s) | ||
# 'id' is a numerical value in [0,9] by default | ||
# 'context' is a high cardinality value like 'HTTP_1_1@7674f035' but likely stable for the | ||
# duration of the jetty process lifecycle | ||
context: param(context) | ||
id: param(id) | ||
|
||
- bean: org.eclipse.jetty.server.session:context=*,type=sessionhandler,id=* | ||
prefix: jetty.session. | ||
metricAttribute: | ||
resource: param(context) | ||
mapping: | ||
sessionsCreated: | ||
metric: count | ||
type: counter | ||
unit: "{session}" | ||
desc: The number of sessions established in total. | ||
sessionTimeTotal: | ||
metric: time.total | ||
type: counter | ||
unit: s | ||
desc: The total time sessions have been active. | ||
sessionTimeMax: | ||
metric: time.max | ||
# here a 'counter' seems more appropriate but gauge reflects jetty.groovy impl. | ||
type: gauge | ||
unit: s | ||
desc: The maximum amount of time a session has been active. | ||
|
||
- bean: org.eclipse.jetty.util.thread:type=queuedthreadpool,id=* | ||
# here the 'id' can be ignored as it's usually a single value equal to '0' | ||
prefix: jetty.thread. | ||
unit: "{thread}" | ||
mapping: | ||
busyThreads: | ||
metric: count | ||
# here an 'updowncounter' seems more appropriate but gauge reflects jetty.groovy impl. | ||
type: gauge | ||
desc: The current number of threads. | ||
metricAttribute: | ||
state: const(busy) | ||
idleThreads: | ||
metric: count | ||
# here an 'updowncounter' seems more appropriate but gauge reflects jetty.groovy impl. | ||
type: gauge | ||
desc: The current number of threads. | ||
metricAttribute: | ||
state: const(idle) | ||
queueSize: | ||
metric: queue.count | ||
# here an 'updowncounter' seems more appropriate but gauge reflects jetty.groovy impl. | ||
type: gauge | ||
desc: The current number of threads in the queue. |