Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ Even when matching on the main class name or on system properties,
* Fix `NullPointerException` on legacy Apache client instrumentation when host is `null` - {pull}1746[#1746]
* Apply consistent proxy class exclusion heuristic - {pull}1738[#1738]

[float]
===== Refactors
* Migrate MongoDB plugin to indy dispatcher {pull}1369[#1369]

[[release-notes-1.x]]
=== Java Agent version 1.x

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package co.elastic.apm.agent.mongoclient;

import co.elastic.apm.agent.bci.VisibleForAdvice;
import co.elastic.apm.agent.impl.GlobalTracer;
import co.elastic.apm.agent.impl.transaction.AbstractSpan;
import co.elastic.apm.agent.impl.transaction.Span;
Expand All @@ -41,12 +40,11 @@

public class ConnectionAdvice {

@VisibleForAdvice
public static final Logger logger = LoggerFactory.getLogger(ConnectionAdvice.class);

@Nullable
@Advice.OnMethodEnter(suppress = Throwable.class)
public static Span onEnter(@Advice.This Connection thiz,
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static Object onEnter(@Advice.This Connection thiz,
@Advice.Argument(0) Object databaseOrMongoNamespace,
@Advice.Argument(1) BsonDocument command) {
Span span = null;
Expand Down Expand Up @@ -113,9 +111,10 @@ public static Span onEnter(@Advice.This Connection thiz,
return span;
}

@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class)
public static void onExit(@Nullable @Advice.Enter Span span, @Advice.Thrown Throwable thrown, @Advice.Origin("#m") String methodName) {
if (span != null) {
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onExit(@Nullable @Advice.Enter Object spanObj, @Advice.Thrown Throwable thrown, @Advice.Origin("#m") String methodName) {
if (spanObj instanceof Span) {
Span span = (Span) spanObj;
span.deactivate().captureException(thrown);
if (!methodName.endsWith("Async")) {
span.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public ElementMatcher<? super MethodDescription> getMethodMatcher() {
}

@Nullable
@Advice.OnMethodEnter(suppress = Throwable.class)
public static Span onEnter(@Advice.This Connection thiz,
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static Object onEnter(@Advice.This Connection thiz,
@Advice.Argument(0) MongoNamespace namespace,
@Advice.Origin("#m") String methodName) {
Span span = null;
Expand Down Expand Up @@ -109,9 +109,10 @@ public static Span onEnter(@Advice.This Connection thiz,
return span;
}

@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class)
public static void onExit(@Nullable @Advice.Enter Span span, @Advice.Thrown Throwable thrown) {
if (span != null) {
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onExit(@Nullable @Advice.Enter Object spanObj, @Advice.Thrown Throwable thrown) {
if (spanObj instanceof Span) {
Span span = (Span) spanObj;
span.deactivate().captureException(thrown);
span.end();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,4 @@ public Collection<String> getInstrumentationGroupNames() {
return Collections.singletonList("mongodb-client");
}

@Override
public boolean indyPlugin() {
return false;
}
}