Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,26 @@ protected MetricsVerifier createMetricsVerifier() {
metric
.hasDescription("The number of active sessions")
.hasUnit("{session}")
.isGauge()
.isUpDownCounter()
.hasDataPointsWithOneAttribute(attributeWithAnyValue("context")))
.add(
"tomcat.errors",
"tomcat.request.errors",
metric ->
metric
.hasDescription("The number of errors encountered")
.hasUnit("{error}")
.isCounter()
.hasDataPointsWithOneAttribute(attribute("proto_handler", "\"http-nio-8080\"")))
.add(
"tomcat.processing_time",
"tomcat.request.duration",
metric ->
metric
.hasDescription("The total processing time")
.hasUnit("ms")
.isCounter()
.hasDataPointsWithOneAttribute(attribute("proto_handler", "\"http-nio-8080\"")))
.add(
"tomcat.traffic",
"tomcat.network.io",
metric ->
metric
.hasDescription("The number of bytes transmitted and received")
Expand Down Expand Up @@ -101,15 +101,15 @@ protected MetricsVerifier createMetricsVerifier() {
attribute("state", "busy"),
attribute("proto_handler", "\"http-nio-8080\""))))
.add(
"tomcat.max_time",
"tomcat.request.duration.max",
metric ->
metric
.hasDescription("Maximum time to process a request")
.hasUnit("ms")
.isGauge()
.hasDataPointsWithOneAttribute(attribute("proto_handler", "\"http-nio-8080\"")))
.add(
"tomcat.request_count",
"tomcat.requests",
metric ->
metric
.hasDescription("The total requests")
Expand Down
42 changes: 21 additions & 21 deletions jmx-scraper/src/main/resources/tomcat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rules:
mapping:
activeSessions:
metric: tomcat.sessions
type: gauge
type: updowncounter
Copy link
Contributor Author

@robsunday robsunday Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be a better fit here. UpDownCounter is also used here in tomcat.yaml from opentelemetry-java-instrumentation project

unit: "{session}"
desc: The number of active sessions

Expand All @@ -26,37 +26,37 @@ rules:
proto_handler: param(name)
mapping:
errorCount:
metric: errors
metric: request.errors
type: counter
unit: "{error}"
desc: The number of errors encountered
requestCount:
metric: request_count
metric: requests
type: counter
unit: "{request}"
desc: The total requests
maxTime:
metric: max_time
metric: request.duration.max
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request.duration is is taken from HTTP semconv

type: gauge
unit: ms
desc: Maximum time to process a request
processingTime:
metric: processing_time
metric: request.duration
type: counter
unit: ms
desc: The total processing time
bytesSent:
metric: traffic
type: counter
unit: By
desc: The number of bytes transmitted and received
metric: &metric network.io
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yaml anchors and references used to improve maintainability

type: &type counter
unit: &unit By
desc: &desc The number of bytes transmitted and received
metricAttribute:
direction: const(sent)
bytesReceived:
metric: traffic
type: counter
unit: By
desc: The number of bytes transmitted and received
metric: *metric
type: *type
unit: *unit
desc: *desc
metricAttribute:
direction: const(received)

Expand All @@ -68,16 +68,16 @@ rules:
proto_handler: param(name)
mapping:
currentThreadCount:
metric: threads
desc: The number of threads
type: gauge
unit: "{thread}"
metric: &metric threads
desc: &desc The number of threads
type: &type gauge
unit: &unit "{thread}"
metricAttribute:
state: const(idle)
currentThreadsBusy:
metric: threads
desc: The number of threads
type: gauge
unit: "{thread}"
metric: *metric
desc: *desc
type: *type
unit: *unit
metricAttribute:
state: const(busy)
Loading