Skip to content

Commit

Permalink
Merge pull request #253 from solarwinds/cc/NH-88139
Browse files Browse the repository at this point in the history
NH-88139: upgrade to joboe 10.0.11 and add some sdk generated trace test
  • Loading branch information
cleverchuk authored Aug 9, 2024
2 parents 2cfcf68 + b6eba92 commit 03b97b5
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ subprojects {
opentelemetryJavaagent: "2.5.0",
bytebuddy : "1.12.10",
guava : "30.1-jre",
joboe : "10.0.9",
joboe : "10.0.11",
agent : "2.5.1", // the custom distro agent version
autoservice : "1.0.1",
caffeine : "2.9.3",
Expand Down
Binary file renamed libs/config-10.0.9.jar → libs/config-10.0.11.jar
Binary file not shown.
Binary file renamed libs/core-10.0.9.jar → libs/core-10.0.11.jar
Binary file not shown.
Binary file renamed libs/logging-10.0.9.jar → libs/logging-10.0.11.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 2 additions & 4 deletions smoke-tests/k6/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,8 @@ function verify_distributed_trace() {

for (let k = 0; k < properties.length; k++) {
const property = properties[k]
if (property.key === "service.name") {
check(property, {"check that remote service, java-apm-smoke-test, is path of the trace": prop => prop.value === "java-apm-smoke-test"})
if (property.value === "java-apm-smoke-test") return;
}
check(property, {"check that remote service, java-apm-smoke-test, is path of the trace": prop => prop.value === "java-apm-smoke-test"})
check(property, {"sdk-trace": prop => prop.value === "SDK.trace.test"})
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions smoke-tests/spring-boot-webmvc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ dependencies {
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")

implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations:2.5.0")
runtimeOnly("io.opentelemetry:opentelemetry-api:1.39.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

testImplementation("org.springframework.boot:spring-boot-starter-test")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
package com.solarwinds.webmvc

import com.solarwinds.api.ext.SolarwindsAgent
import io.opentelemetry.api.GlobalOpenTelemetry
import io.opentelemetry.api.OpenTelemetry
import io.opentelemetry.instrumentation.annotations.WithSpan
import mu.KotlinLogging
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
Expand All @@ -32,16 +35,32 @@ import java.net.http.HttpResponse
@RequestMapping
class Controller {
private val log = KotlinLogging.logger {}
private val otelSdk: OpenTelemetry = GlobalOpenTelemetry.get()
private val tracer = otelSdk.getTracer("sdk.tracing")

@GetMapping("greet/{name}")
fun greet(@PathVariable name: String): String{
val startSpan = tracer.spanBuilder("greet-span")
.setAttribute("sw.test.source", "SDK.trace.test")
.startSpan()
startSpan.makeCurrent().use {
SolarwindsAgent.setTransactionName(name)
startSpan.end()
return "Hello $name\n===================================\n\n"
}
}

@WithSpan
@GetMapping("distributed")
fun distributed(): String {
val startSpan = tracer.spanBuilder("greet-span")
.setAttribute("sw.test.source", "SDK.trace.test")
.startSpan()

startSpan.makeCurrent().use {
log.info("Got request at distributed")
startSpan.end()
}
return HttpClient.newHttpClient()
.send(
HttpRequest.newBuilder(URI.create("http://petclinic:9966/petclinic/api/pettypes")).GET().build(),
Expand Down
8 changes: 8 additions & 0 deletions smoke-tests/src/test/java/com/solarwinds/SmokeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,12 @@ void assertThatLogsAreExported() throws IOException {
assertTrue(passes > 0, "log export is broken");
}

@Test
void assertThatSdkTracingIsWorking() 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.['sdk-trace'].passes");
assertTrue(passes > 1, "SDK trace is not working, expected a count > 1 ");
}
}

0 comments on commit 03b97b5

Please sign in to comment.