Better span names jaxrs (#268)
This commit is contained in:
parent
9566ee9951
commit
ebcf5212a5
|
@ -99,12 +99,11 @@ class DropwizardTest extends HttpServerTest<DropwizardTestSupport> {
|
|||
@Override
|
||||
void handlerSpan(TraceAssert trace, int index, Object parent, String method = "GET", ServerEndpoint endpoint = SUCCESS) {
|
||||
trace.span(index) {
|
||||
operationName "jax-rs.request"
|
||||
operationName "${this.testResource().simpleName}.${endpoint.name().toLowerCase()}"
|
||||
spanKind INTERNAL
|
||||
errored endpoint == EXCEPTION
|
||||
childOf((SpanData) parent)
|
||||
tags {
|
||||
"$MoreTags.RESOURCE_NAME" "${this.testResource().simpleName}.${endpoint.name().toLowerCase()}"
|
||||
"$Tags.COMPONENT" JaxRsAnnotationsDecorator.DECORATE.getComponentName()
|
||||
if (endpoint == EXCEPTION) {
|
||||
errorTags(Exception, EXCEPTION.body)
|
||||
|
@ -126,7 +125,6 @@ class DropwizardTest extends HttpServerTest<DropwizardTestSupport> {
|
|||
parent()
|
||||
}
|
||||
tags {
|
||||
"$MoreTags.RESOURCE_NAME" "$method ${endpoint == PATH_PARAM ? "/path/{id}/param" : endpoint.resolvePath(address).path}"
|
||||
"$Tags.COMPONENT" component
|
||||
"$MoreTags.NET_PEER_IP" { it == null || it == "127.0.0.1" } // Optional
|
||||
"$MoreTags.NET_PEER_PORT" Long
|
||||
|
|
|
@ -20,7 +20,6 @@ import static io.opentelemetry.auto.bootstrap.WeakMap.Provider.newWeakMap;
|
|||
import io.opentelemetry.OpenTelemetry;
|
||||
import io.opentelemetry.auto.bootstrap.WeakMap;
|
||||
import io.opentelemetry.auto.bootstrap.instrumentation.decorator.BaseDecorator;
|
||||
import io.opentelemetry.auto.instrumentation.api.MoreTags;
|
||||
import io.opentelemetry.auto.instrumentation.api.Tags;
|
||||
import io.opentelemetry.auto.tooling.ClassHierarchyIterable;
|
||||
import io.opentelemetry.trace.Span;
|
||||
|
@ -53,10 +52,9 @@ public class JaxRsAnnotationsDecorator extends BaseDecorator {
|
|||
// When jax-rs is the root, we want to name using the path, otherwise use the class/method.
|
||||
final boolean isRootScope = !parent.getContext().isValid();
|
||||
if (isRootScope && !resourceName.isEmpty()) {
|
||||
span.setAttribute(MoreTags.RESOURCE_NAME, resourceName);
|
||||
span.updateName(resourceName);
|
||||
} else {
|
||||
span.setAttribute(
|
||||
MoreTags.RESOURCE_NAME, DECORATE.spanNameForClass(target) + "." + method.getName());
|
||||
span.updateName(DECORATE.spanNameForClass(target) + "." + method.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +66,6 @@ public class JaxRsAnnotationsDecorator extends BaseDecorator {
|
|||
|
||||
if (!resourceName.isEmpty()) {
|
||||
span.updateName(resourceName);
|
||||
span.setAttribute(MoreTags.RESOURCE_NAME, resourceName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
import io.opentelemetry.auto.bootstrap.WeakMap
|
||||
import io.opentelemetry.auto.instrumentation.api.MoreTags
|
||||
import io.opentelemetry.auto.instrumentation.api.Tags
|
||||
import io.opentelemetry.auto.instrumentation.jaxrs1.JaxRsAnnotationsDecorator
|
||||
import io.opentelemetry.auto.test.AgentTestRunner
|
||||
|
@ -45,9 +44,8 @@ class JaxRsAnnotationsInstrumentationTest extends AgentTestRunner {
|
|||
assertTraces(1) {
|
||||
trace(0, 1) {
|
||||
span(0) {
|
||||
operationName "jax-rs.request"
|
||||
operationName "POST /a"
|
||||
tags {
|
||||
"$MoreTags.RESOURCE_NAME" "POST /a"
|
||||
"$Tags.COMPONENT" "jax-rs-controller"
|
||||
}
|
||||
}
|
||||
|
@ -69,15 +67,13 @@ class JaxRsAnnotationsInstrumentationTest extends AgentTestRunner {
|
|||
operationName name
|
||||
parent()
|
||||
tags {
|
||||
"$MoreTags.RESOURCE_NAME" name
|
||||
"$Tags.COMPONENT" "jax-rs"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
operationName "jax-rs.request"
|
||||
operationName "${className}.call"
|
||||
childOf span(0)
|
||||
tags {
|
||||
"$MoreTags.RESOURCE_NAME" "${className}.call"
|
||||
"$Tags.COMPONENT" "jax-rs-controller"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
import io.dropwizard.testing.junit.ResourceTestRule
|
||||
import io.opentelemetry.auto.instrumentation.api.MoreTags
|
||||
import io.opentelemetry.auto.instrumentation.api.Tags
|
||||
import io.opentelemetry.auto.test.AgentTestRunner
|
||||
import org.junit.ClassRule
|
||||
|
@ -47,16 +46,14 @@ class JerseyTest extends AgentTestRunner {
|
|||
span(0) {
|
||||
operationName expectedResourceName
|
||||
tags {
|
||||
"$MoreTags.RESOURCE_NAME" expectedResourceName
|
||||
"$Tags.COMPONENT" "jax-rs"
|
||||
}
|
||||
}
|
||||
|
||||
span(1) {
|
||||
childOf span(0)
|
||||
operationName "jax-rs.request"
|
||||
operationName controllerName
|
||||
tags {
|
||||
"$MoreTags.RESOURCE_NAME" controllerName
|
||||
"$Tags.COMPONENT" "jax-rs-controller"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import static io.opentelemetry.auto.bootstrap.WeakMap.Provider.newWeakMap;
|
|||
import io.opentelemetry.OpenTelemetry;
|
||||
import io.opentelemetry.auto.bootstrap.WeakMap;
|
||||
import io.opentelemetry.auto.bootstrap.instrumentation.decorator.BaseDecorator;
|
||||
import io.opentelemetry.auto.instrumentation.api.MoreTags;
|
||||
import io.opentelemetry.auto.instrumentation.api.Tags;
|
||||
import io.opentelemetry.auto.tooling.ClassHierarchyIterable;
|
||||
import io.opentelemetry.trace.Span;
|
||||
|
@ -63,10 +62,9 @@ public class JaxRsAnnotationsDecorator extends BaseDecorator {
|
|||
// When jax-rs is the root, we want to name using the path, otherwise use the class/method.
|
||||
final boolean isRootScope = !parent.getContext().isValid();
|
||||
if (isRootScope && !resourceName.isEmpty()) {
|
||||
span.setAttribute(MoreTags.RESOURCE_NAME, resourceName);
|
||||
span.updateName(resourceName);
|
||||
} else {
|
||||
span.setAttribute(
|
||||
MoreTags.RESOURCE_NAME,
|
||||
span.updateName(
|
||||
DECORATE.spanNameForClass(target) + (method == null ? "" : "." + method.getName()));
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +77,6 @@ public class JaxRsAnnotationsDecorator extends BaseDecorator {
|
|||
|
||||
if (!resourceName.isEmpty()) {
|
||||
span.updateName(resourceName);
|
||||
span.setAttribute(MoreTags.RESOURCE_NAME, resourceName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
import io.opentelemetry.auto.bootstrap.WeakMap
|
||||
import io.opentelemetry.auto.instrumentation.api.MoreTags
|
||||
import io.opentelemetry.auto.instrumentation.api.Tags
|
||||
import io.opentelemetry.auto.instrumentation.jaxrs2.JaxRsAnnotationsDecorator
|
||||
import io.opentelemetry.auto.test.AgentTestRunner
|
||||
|
@ -45,9 +44,8 @@ class JaxRsAnnotationsInstrumentationTest extends AgentTestRunner {
|
|||
assertTraces(1) {
|
||||
trace(0, 1) {
|
||||
span(0) {
|
||||
operationName "jax-rs.request"
|
||||
operationName "POST /a"
|
||||
tags {
|
||||
"$MoreTags.RESOURCE_NAME" "POST /a"
|
||||
"$Tags.COMPONENT" "jax-rs-controller"
|
||||
}
|
||||
}
|
||||
|
@ -69,15 +67,13 @@ class JaxRsAnnotationsInstrumentationTest extends AgentTestRunner {
|
|||
operationName name
|
||||
parent()
|
||||
tags {
|
||||
"$MoreTags.RESOURCE_NAME" name
|
||||
"$Tags.COMPONENT" "jax-rs"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
operationName "jax-rs.request"
|
||||
operationName "${className}.call"
|
||||
childOf span(0)
|
||||
tags {
|
||||
"$MoreTags.RESOURCE_NAME" "${className}.call"
|
||||
"$Tags.COMPONENT" "jax-rs-controller"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
import io.dropwizard.testing.junit.ResourceTestRule
|
||||
import io.opentelemetry.auto.instrumentation.api.MoreTags
|
||||
import io.opentelemetry.auto.instrumentation.api.Tags
|
||||
import io.opentelemetry.auto.test.AgentTestRunner
|
||||
import org.jboss.resteasy.core.Dispatcher
|
||||
|
@ -75,15 +74,13 @@ abstract class JaxRsFilterTest extends AgentTestRunner {
|
|||
span(0) {
|
||||
operationName parentResourceName != null ? parentResourceName : "test.span"
|
||||
tags {
|
||||
"$MoreTags.RESOURCE_NAME" parentResourceName
|
||||
"$Tags.COMPONENT" "jax-rs"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
childOf span(0)
|
||||
operationName abort ? "jax-rs.request.abort" : "jax-rs.request"
|
||||
operationName controllerName
|
||||
tags {
|
||||
"$MoreTags.RESOURCE_NAME" controllerName
|
||||
"$Tags.COMPONENT" "jax-rs-controller"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue