use of com.megaease.easeagent.plugin.api.Context in project easeagent by megaease.
the class MongoReactiveTraceTest method performSuccess.
@Test
public void performSuccess() {
Context context = EaseAgent.getContext();
MethodInfo methodInfo = MethodInfo.builder().args(new Object[] { null, null, null, mock(SingleResultCallback.class) }).build();
interceptor.before(methodInfo, context);
BsonDocument bsonDocument = new BsonDocument();
bsonDocument.put("collection", new BsonString(collection));
CommandSucceededEvent succeededEvent = new CommandSucceededEvent(this.requestId, this.connectionDescription, this.cmdName, bsonDocument, 10);
this.listener.commandStarted(startedEvent);
this.listener.commandSucceeded(succeededEvent);
MongoInternalConnectionSendAndReceiveAsync4TraceInterceptor.SingleResultCallbackProxy<?> proxy = (MongoInternalConnectionSendAndReceiveAsync4TraceInterceptor.SingleResultCallbackProxy<?>) methodInfo.getArgs()[3];
proxy.onResult(null, null);
this.assertTrace(true, null);
context.exit(interceptor.getEnterKey(methodInfo, context));
}
use of com.megaease.easeagent.plugin.api.Context in project easeagent by megaease.
the class MongoReactiveTraceTest method performOpFail2.
@Test
public void performOpFail2() {
Context context = EaseAgent.getContext();
MethodInfo methodInfo = MethodInfo.builder().args(new Object[] { null, null, null, mock(SingleResultCallback.class) }).build();
interceptor.before(methodInfo, context);
CommandFailedEvent failedEvent = new CommandFailedEvent(this.requestId, this.connectionDescription, this.cmdName, 10, new RuntimeException(this.errMsg));
this.listener.commandStarted(startedEvent);
this.listener.commandFailed(failedEvent);
MongoInternalConnectionSendAndReceiveAsync4TraceInterceptor.SingleResultCallbackProxy<?> proxy = (MongoInternalConnectionSendAndReceiveAsync4TraceInterceptor.SingleResultCallbackProxy<?>) methodInfo.getArgs()[3];
proxy.onResult(null, null);
this.assertTrace(false, errMsg);
context.exit(interceptor.getEnterKey(methodInfo, context));
}
use of com.megaease.easeagent.plugin.api.Context in project easeagent by megaease.
the class TraceHelperTest method performOpFail2.
@Test
public void performOpFail2() {
CommandFailedEvent failedEvent = new CommandFailedEvent(this.requestId, this.connectionDescription, this.cmdName, 10, new RuntimeException(this.errMsg));
Context context = EaseAgent.getContext();
TraceHelper.commandStarted(context, this.config, this.startedEvent);
TraceHelper.commandFailed(context, failedEvent);
this.assertTrace(false, errMsg);
}
use of com.megaease.easeagent.plugin.api.Context in project easeagent by megaease.
the class MongoMetricCommandListener method commandSucceeded.
@Override
public void commandSucceeded(CommandSucceededEvent event) {
// LOGGER.warn("commandSucceeded metric");
Context context = EaseAgent.getContext();
MetricHelper.commandSucceeded(context, config, this.mongoMetric, event);
}
use of com.megaease.easeagent.plugin.api.Context in project easeagent by megaease.
the class MongoReactiveTraceCommandListener method commandFailed.
@Override
public void commandFailed(CommandFailedEvent event) {
// LOGGER.warn("reactive commandFailed trace");
Context context = EaseAgent.getContext();
context.put(MongoUtils.EVENT_KEY, event);
}
Aggregations