Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JMX Scraper: Kafka server, producer and consumer YAMLs and integration tests added #1670

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robsunday
Copy link
Contributor

@robsunday robsunday commented Jan 24, 2025

Three target systems connected to Kafka have been added:

  1. Server
  2. Producer
  3. Consumer

To fully test Kafka metrics there is a need to spin multiple containers, so these three components can correctly interact and metrics can be correctly generated.
Base integration test class TargetSystemIntegrationTest was modified to support initialization of multiple containers.

There are still some TODOs left that will be fixed in subsequent PRs

Part of #1362

@@ -86,12 +88,23 @@ static void afterAll() {

@AfterEach
void afterEach() {
if (scraper != null && scraper.isRunning()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] I rearranged containers shutdown sequence to be in reverse order than starting to avoid unnecessary errors in the logs

}

protected void verifyMetrics() {
MetricsVerifier metricsVerifier = createMetricsVerifier();
await()
.atMost(Duration.ofSeconds(60))
.pollInterval(Duration.ofSeconds(1))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] Just to decrease CPU usage a bit if we do not have all metrics available immediately.

.hasUnit("{request}")
.isGauge()
.hasDataPointsWithOneAttribute(
attributeWithAnyValue("client.id"))) // changed to follow semconv
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] This is one of the changes to get closer to semconv standards

metric
.hasDescription(
"The average number of bytes consumed for all topics per second")
.hasUnit("By")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] Changed from 'by' to follow semconv

metric
.hasDescription(
"The average number of records consumed for all topics per second")
.hasUnit("{record}")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] Multiple units in this file have been changed from "1" to annotated form to follow semconv

"sh",
"-c",
"echo 'Sending messages to test-topic-1'; "
+ "i=1; while true; do echo \"Message $i\"; sleep .25; i=$((i+1)); done | /opt/bitnami/kafka/bin/kafka-console-producer.sh --bootstrap-server "
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] Topic is automatically created when messages are sent to it - no need to manually create it

AttributeMatcherGroup[] requestTypes = {
// attribute values are changed from lowercase to PascalCase
// because it is impossible to make them lowercase with YAML config
// TODO: What about const value attributes defined in YAML that are lowercase?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] We need to decide what to do with attribute names for Kafka.
Currently attributes extracted from bean names are in PascalCase, while the attributes defined by const(...) are lowercase (see YAMLs)
Maybe that is fine?

.withEnv("JMX_PORT", Integer.toString(jmxPort))
.withExposedPorts(jmxPort)
.waitingFor(Wait.forListeningPorts(jmxPort));
// .waitingFor(Wait.forLogMessage(".*Sending messages to test-topic-1.*", 1));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] Will be cleaned

metric: kafka.purgatory.size
type: updowncounter
desc: The number of requests waiting in purgatory
unit: "{request}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] Please verify all annotations of units. In the original files they were either in plular form, or were missing (unit: "1" was used instead)

mapping:
fetch-rate:
desc: The number of fetch requests for all topics per second
unit: '{request}'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] Please verify all annotations of units. In the original files they were either in plular form, or were missing (unit: "1" was used instead)

unit: ms
request-rate:
desc: The average number of requests sent per second
unit: '{request}'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] Please verify all annotations of units. In the original files they were either in plular form, or were missing (unit: "1" was used instead)

@robsunday robsunday marked this pull request as ready for review January 24, 2025 12:58
@robsunday robsunday requested a review from a team as a code owner January 24, 2025 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants