Skip to content

Commit

Permalink
[CONS-848] overriding setOperationName to update http.route attr (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
guiguatura authored Oct 25, 2023
1 parent 7f7c571 commit 46c1221
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions impl/java/tracing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ dependencies {
api("io.opentracing:opentracing-util:0.33.0")

// Open Telemetry
api("io.opentelemetry:opentelemetry-api:1.28.0")
api("io.opentelemetry:opentelemetry-extension-kotlin:1.28.0")

api("io.opentelemetry:opentelemetry-api:1.30.0")
api("io.opentelemetry:opentelemetry-extension-kotlin:1.30.0")
api("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv:1.30.0-alpha")
// AspectJ
implementation("org.aspectj:aspectjweaver:1.9.19")
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import io.opentelemetry.api.metrics.Meter
import io.opentelemetry.api.trace.Span
import io.opentelemetry.api.trace.Tracer
import io.opentelemetry.context.Context
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerRoute
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerRouteSource
import java.io.Closeable
import java.util.concurrent.ConcurrentHashMap

Expand All @@ -28,8 +30,12 @@ class OpenTelemetryTracer : TracerEngine, ThreadContextManager<Span> {
}

override fun setOperationName(name: String) {
val span = currentSpan()
span?.updateName(name)
HttpServerRoute.update(
Context.current(),
HttpServerRouteSource.CONTROLLER,
{ _, _ -> name },
Unit
)
}

override fun addProperty(key: String, value: String?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,7 @@ class OpenTelemetryTracerTest {

@Test
fun `should set operation name successfully`() {
val span = currentSpyiedSpan()
openTelemetryTracer.setOperationName("my-operation")

verify(exactly = 1) {
span.updateName("my-operation")
}
}

private fun currentSpyiedSpan(): Span {
Expand Down

0 comments on commit 46c1221

Please sign in to comment.