Skip to content

Commit

Permalink
Use collectSpanAttributes
Browse files Browse the repository at this point in the history
  • Loading branch information
agoallikmaa committed May 27, 2021
1 parent 24a89a4 commit 354250a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import akka.stream.ActorMaterializer
import groovy.lang.Closure
import io.opentelemetry.instrumentation.test.base.HttpServerTest
import io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint._
import io.opentelemetry.javaagent.testing.common.Java8BytecodeBridge

import scala.concurrent.{Await, ExecutionContextExecutor, Future}

Expand All @@ -34,12 +33,10 @@ object AkkaHttpTestAsyncWebServer {
endpoint match {
case SUCCESS => resp.withEntity(endpoint.getBody)
case INDEXED_CHILD =>
Java8BytecodeBridge
.currentSpan()
.setAttribute(
"test.request.id",
uri.query().get("id").orNull.toLong
)
INDEXED_CHILD.collectSpanAttributes(new UrlParameterProvider {
override def getParameter(name: String): String =
uri.query().get(name).orNull
})
resp.withEntity("")
case QUERY_PARAM => resp.withEntity(uri.queryString().orNull)
case REDIRECT =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import akka.stream.ActorMaterializer
import groovy.lang.Closure
import io.opentelemetry.instrumentation.test.base.HttpServerTest
import io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint._
import io.opentelemetry.javaagent.testing.common.Java8BytecodeBridge

import scala.concurrent.Await

Expand All @@ -32,12 +31,10 @@ object AkkaHttpTestSyncWebServer {
endpoint match {
case SUCCESS => resp.withEntity(endpoint.getBody)
case INDEXED_CHILD =>
Java8BytecodeBridge
.currentSpan()
.setAttribute(
"test.request.id",
uri.query().get("id").orNull.toLong
)
INDEXED_CHILD.collectSpanAttributes(new UrlParameterProvider {
override def getParameter(name: String): String =
uri.query().get(name).orNull
})
resp.withEntity("")
case QUERY_PARAM => resp.withEntity(uri.queryString().orNull)
case REDIRECT =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package io.opentelemetry.javaagent.testing.common;

import io.opentelemetry.api.trace.Span;
import io.opentelemetry.context.Context;

/**
Expand All @@ -19,9 +18,4 @@ public final class Java8BytecodeBridge {
public static Context currentContext() {
return Context.current();
}

/** Calls {@link Span#current()}. */
public static Span currentSpan() {
return Span.current();
}
}

0 comments on commit 354250a

Please sign in to comment.