Skip to content

Commit

Permalink
NH-93485: export metrics via otlp
Browse files Browse the repository at this point in the history
  • Loading branch information
cleverchuk committed Oct 29, 2024
1 parent c7f8ca3 commit ed24d89
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 22 deletions.
65 changes: 43 additions & 22 deletions smoke-tests/k6/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,42 +552,63 @@ function silence(fn) {
}

export default function () {
silence(verify_that_span_data_is_persisted_0)
const request_count = (measurement) => check(measurement, {"request_count": mrs => mrs.value > 0})
const tracecount = (measurement) => check(measurement, {"tracecount": mrs => mrs.value > 0})
const samplecount = (measurement) => check(measurement, {"samplecount": mrs => mrs.value > 0})
const response_time = (measurement) => check(measurement, {"response_time": mrs => mrs.value > 0})
silence(verify_that_span_data_is_persisted_0)

const request_count = (measurement) => check(measurement, {"request_count": mrs => mrs.value > 0})
const tracecount = (measurement) => check(measurement, {"tracecount": mrs => mrs.value > 0})
const samplecount = (measurement) => check(measurement, {"samplecount": mrs => mrs.value > 0})
const response_time = (measurement) => check(measurement, {"response_time": mrs => mrs.value > 0})

if (`${__ENV.LAMBDA}` === "true") {

silence(function () {
verify_that_metrics_are_reported("trace.service.request_count", request_count)
verify_that_metrics_are_reported("trace.service.request_count", request_count)
})

silence(function () {
verify_that_metrics_are_reported("trace.service.tracecount", tracecount)
verify_that_metrics_are_reported("trace.service.tracecount", tracecount)
})

silence(function () {
verify_that_metrics_are_reported("trace.service.samplecount", samplecount)
verify_that_metrics_are_reported("trace.service.samplecount", samplecount)
})

silence(function () {
verify_that_metrics_are_reported("trace.service.response_time", response_time)
verify_that_metrics_are_reported("trace.service.response_time", response_time)
})

silence(verify_transaction_name)

if (`${__ENV.LAMBDA}` === "false") {
silence(function () {
verify_that_metrics_are_reported("jvm.memory.used",
(measurement) => check(measurement, {"otel-metrics": mrs => mrs.value > 0}),
"java-apm-smoke-test"
)
})
silence(verify_logs_export)
silence(verify_that_specialty_path_is_not_sampled)

silence(verify_that_span_data_is_persisted)
silence(verify_that_trace_is_persisted)
silence(verify_distributed_trace)
} else {
const service = "java-apm-smoke-test"
silence(function () {
verify_that_metrics_are_reported("trace.service.request_count", request_count, service)
})

silence(function () {
verify_that_metrics_are_reported("trace.service.tracecount", tracecount, service)
})

silence(function () {
verify_that_metrics_are_reported("trace.service.samplecount", samplecount, service)
})

silence(function () {
verify_that_metrics_are_reported("trace.service.response_time", response_time, service)
})

silence(function () {
verify_that_metrics_are_reported("jvm.memory.used",
(measurement) => check(measurement, {"otel-metrics": mrs => mrs.value > 0}),
service
)
})

silence(verify_logs_export)
silence(verify_that_specialty_path_is_not_sampled)

silence(verify_that_span_data_is_persisted)
silence(verify_that_trace_is_persisted)
silence(verify_distributed_trace)
}
};
36 changes: 36 additions & 0 deletions smoke-tests/src/test/java/com/solarwinds/SmokeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,40 @@ void assertThatSdkTracingIsWorking() throws IOException {
double passes = ResultsCollector.read(resultJson, "$.root_group.checks.['sdk-trace'].passes");
assertTrue(passes > 1, "SDK trace is not working, expected a count > 1 ");
}

@Test
void assertThatRequestCountMetricIsReported() throws IOException {
String resultJson = new String(
Files.readAllBytes(namingConventions.local.k6Results(Configs.E2E.config.agents().get(0))));

double passes = ResultsCollector.read(resultJson, "$.root_group.checks.['request_count'].passes");
assertTrue(passes > 1, "Expects a count > 1 ");
}

@Test
void assertThatTraceCountMetricIsReported() throws IOException {
String resultJson = new String(
Files.readAllBytes(namingConventions.local.k6Results(Configs.E2E.config.agents().get(0))));

double passes = ResultsCollector.read(resultJson, "$.root_group.checks.['tracecount'].passes");
assertTrue(passes > 1, "Expects a count > 1 ");
}

@Test
void assertThatSampleCountMetricIsReported() throws IOException {
String resultJson = new String(
Files.readAllBytes(namingConventions.local.k6Results(Configs.E2E.config.agents().get(0))));

double passes = ResultsCollector.read(resultJson, "$.root_group.checks.['samplecount'].passes");
assertTrue(passes > 1, "Expects a count > 1 ");
}

@Test
void assertThatResponseTimeMetricIsReported() throws IOException {
String resultJson = new String(
Files.readAllBytes(namingConventions.local.k6Results(Configs.E2E.config.agents().get(0))));

double passes = ResultsCollector.read(resultJson, "$.root_group.checks.['response_time'].passes");
assertTrue(passes > 1, "Expects a count > 1 ");
}
}

0 comments on commit ed24d89

Please sign in to comment.