Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed Mar 26, 2021
1 parent 4899066 commit 7546e16
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ public static void onExit(
@Advice.Thrown Throwable throwable,
@Advice.Local("otelContext") Context context,
@Advice.Local("otelScope") Scope scope) {
if (scope == null) {
return;
}
scope.close();

tracer().endVaadinServiceSpan(context, throwable);
Expand Down Expand Up @@ -134,7 +131,9 @@ public static void onEnter(
@Advice.Local("otelScope") Scope scope) {

context = tracer().startRequestHandlerSpan(requestHandler, method);
scope = context.makeCurrent();
if (context != null) {
scope = context.makeCurrent();
}
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.opentelemetry.instrumentation.api.tracer.BaseTracer;
import io.opentelemetry.instrumentation.api.tracer.ServerSpan;
import java.lang.reflect.Method;
import org.checkerframework.checker.nullness.qual.Nullable;

public class VaadinTracer extends BaseTracer {
private static final ContextKey<VaadinServiceContext> SERVICE_CONTEXT_KEY =
Expand Down Expand Up @@ -66,7 +67,7 @@ public void endVaadinServiceSpan(Context context, Throwable throwable) {
}
}

public Context startRequestHandlerSpan(RequestHandler requestHandler, Method method) {
public @Nullable Context startRequestHandlerSpan(RequestHandler requestHandler, Method method) {
Context current = Context.current();
// ignore nested request handlers
if (current.get(REQUEST_HANDLER_CONTEXT_KEY) != null) {
Expand Down Expand Up @@ -141,7 +142,7 @@ public Context startRpcInvocationHandlerSpan(

@Override
protected String getInstrumentationName() {
return "io.opentelemetry.javaagent.vaadin";
return "io.opentelemetry.javaagent.vaadin-14.2";
}

private static class VaadinServiceContext {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package test.vaadin

class Vaadin142Test extends AbstractVaadin14Test {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package test.vaadin

class Vaadin14LatestTest extends AbstractVaadin14Test {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package test.vaadin

class Vaadin16Test extends AbstractVaadin16Test {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package test.vaadin

class VaadinLatestTest extends AbstractVaadin16Test {

}
24 changes: 22 additions & 2 deletions instrumentation/vaadin-14.2/javaagent/vaadin-14.2-javaagent.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply from: "$rootDir/gradle/instrumentation.gradle"
apply plugin: 'org.unbroken-dome.test-sets'

muzzle {
fail {
Expand All @@ -23,17 +24,36 @@ muzzle {
}
}


testSets {
vaadin142Test
vaadin14LatestTest
vaadin16Test
latestDepTest {
dirName = 'vaadinLatestTest'
}
}

test.dependsOn vaadin142Test, vaadin16Test
if (findProperty('testLatestDeps')) {
test.dependsOn vaadin14LatestTest
}

dependencies {
compileOnly "com.vaadin:flow-server:2.2.0"

testLibrary 'com.vaadin:vaadin-spring-boot-starter:16.0.0'
vaadin16TestImplementation 'com.vaadin:vaadin-spring-boot-starter:16.0.0'
vaadin142TestImplementation 'com.vaadin:vaadin-spring-boot-starter:14.2.0'

testImplementation project(':instrumentation:vaadin-14.2:vaadin-testing')
testImplementation(project(':testing-common')) {
exclude(module: 'jetty-server')
}

testInstrumentation project(':instrumentation:servlet:servlet-3.0:javaagent')
testInstrumentation project(':instrumentation:servlet:servlet-common:javaagent')
testInstrumentation project(':instrumentation:servlet:servlet-javax-common:javaagent')
testInstrumentation project(':instrumentation:tomcat-7.0:javaagent')

vaadin14LatestTestImplementation 'com.vaadin:vaadin-spring-boot-starter:14.+'
latestDepTestImplementation 'com.vaadin:vaadin-spring-boot-starter:+'
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan

import com.vaadin.flow.server.Version

class Vaadin14Test extends AbstractVaadinTest {
abstract class AbstractVaadin14Test extends AbstractVaadinTest {
static final boolean VAADIN_14_4 = Version.majorVersion >= 2 && Version.minorVersion >= 4

List<String> getRequestHandlers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan

import com.vaadin.flow.server.Version

class Vaadin16Test extends AbstractVaadinTest {
abstract class AbstractVaadin16Test extends AbstractVaadinTest {
static final boolean VAADIN_17 = Version.majorVersion >= 4
static final boolean VAADIN_19 = Version.majorVersion >= 6

Expand Down
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ include ':instrumentation:tomcat-7.0:javaagent'
include ':instrumentation:twilio-6.6:javaagent'
include ':instrumentation:undertow-1.4:javaagent'
include ':instrumentation:vaadin-14.2:javaagent'
include ':instrumentation:vaadin-14.2:vaadin-14.2-testing'
include ':instrumentation:vaadin-14.2:vaadin-testing'
include ':instrumentation:vertx-web-3.0:javaagent'
include ':instrumentation:vertx-reactive-3.5:javaagent'
Expand Down

0 comments on commit 7546e16

Please sign in to comment.