-
Notifications
You must be signed in to change notification settings - Fork 896
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
140 additions
and
26 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionCodeAttributesGetter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.play.v2_4; | ||
|
||
import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesGetter; | ||
import javax.annotation.Nullable; | ||
|
||
public class ActionCodeAttributesGetter implements CodeAttributesGetter<ActionData> { | ||
@Nullable | ||
@Override | ||
public Class<?> getCodeClass(ActionData actionData) { | ||
return actionData.codeClass(); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public String getMethodName(ActionData actionData) { | ||
return actionData.methodName(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...aagent/src/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.play.v2_4; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
public class ActionData { | ||
private final Class<?> target; | ||
private final Method method; | ||
|
||
public ActionData(Class<?> target, Method method) { | ||
this.target = target; | ||
this.method = method; | ||
} | ||
|
||
public Class<?> codeClass() { | ||
return target; | ||
} | ||
|
||
public String methodName() { | ||
return method.getName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...agent/src/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionScope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.play.v2_4; | ||
|
||
import static io.opentelemetry.javaagent.instrumentation.play.v2_4.Play24Singletons.instrumenter; | ||
|
||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.context.Scope; | ||
|
||
/** Container used to carry state between enter and exit advices */ | ||
public final class ActionScope { | ||
|
||
private final ActionData actionData; | ||
private final Context context; | ||
private final Scope scope; | ||
|
||
public ActionScope(Context context, Scope scope, ActionData actionData) { | ||
this.actionData = actionData; | ||
this.context = context; | ||
this.scope = scope; | ||
} | ||
|
||
public Context getContext() { | ||
return context; | ||
} | ||
|
||
public Scope getScope() { | ||
return scope; | ||
} | ||
|
||
public static ActionScope start(Context parentContext, ActionData actionData) { | ||
if (!instrumenter().shouldStart(parentContext, actionData)) { | ||
return null; | ||
} | ||
|
||
Context context = instrumenter().start(parentContext, actionData); | ||
return new ActionScope(context, context.makeCurrent(), actionData); | ||
} | ||
|
||
public void closeScope() { | ||
if (scope != null) { | ||
scope.close(); | ||
} | ||
} | ||
|
||
public void end(Throwable throwable) { | ||
closeScope(); | ||
instrumenter().end(context, actionData, null, throwable); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters