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

Spring boot runtime metrics #13078

Closed
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test more metric types
zeitlinger committed Jan 30, 2025
commit a9a2262ab3ce91eee89e9d8cce0f94996ee6ebcc
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@

package io.opentelemetry.spring.smoketest;

import org.assertj.core.api.AbstractIterableAssert;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest(
@@ -16,6 +17,17 @@
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {
// The headers are simply set here to make sure that headers can be parsed
"otel.exporter.otlp.headers.c=3"
"otel.exporter.otlp.headers.c=3",
"otel.instrumentation.runtime-telemetry-java17.enabled=true",
})
class OtelSpringStarterSmokeTest extends AbstractOtelSpringStarterSmokeTest {}
class OtelSpringStarterSmokeTest extends AbstractOtelSpringStarterSmokeTest {

@Override
protected void assertAdditionalMetrics() {
// JFR based metrics
testing.waitAndAssertMetrics(
"io.opentelemetry.runtime-telemetry-java17",
"jvm.cpu.limit",
AbstractIterableAssert::isNotEmpty);
}
}
Original file line number Diff line number Diff line change
@@ -209,11 +209,20 @@ void shouldSendTelemetry() {
OtelSpringStarterSmokeTestController.METER_SCOPE_NAME,
OtelSpringStarterSmokeTestController.TEST_HISTOGRAM,
AbstractIterableAssert::isNotEmpty);

// runtime metrics
// from special logic for threads that is automatically detected in GraalVM native image
// see io.opentelemetry.instrumentation.runtimemetrics.java8.Threads
testing.waitAndAssertMetrics(
"io.opentelemetry.runtime-telemetry-java8",
"jvm.thread.count",
AbstractIterableAssert::isNotEmpty);
// JMX based metrics
testing.waitAndAssertMetrics(
"io.opentelemetry.runtime-telemetry-java8",
"jvm.memory.used",
AbstractIterableAssert::isNotEmpty);
assertAdditionalMetrics();

// Log
List<LogRecordData> exportedLogRecords = testing.getExportedLogRecords();
@@ -233,6 +242,8 @@ void shouldSendTelemetry() {
}
}

protected void assertAdditionalMetrics() {}

@Test
void databaseQuery() {
testing.clearAllExportedData();