Search in sources :

Example 11 with Context

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));
}
Also used : Context(com.megaease.easeagent.plugin.api.Context) CommandSucceededEvent(com.mongodb.event.CommandSucceededEvent) BsonDocument(org.bson.BsonDocument) BsonString(org.bson.BsonString) MethodInfo(com.megaease.easeagent.plugin.interceptor.MethodInfo) MongoInternalConnectionSendAndReceiveAsync4TraceInterceptor(com.megaease.easeagent.plugin.mongodb.interceptor.MongoInternalConnectionSendAndReceiveAsync4TraceInterceptor) Test(org.junit.Test)

Example 12 with 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));
}
Also used : Context(com.megaease.easeagent.plugin.api.Context) CommandFailedEvent(com.mongodb.event.CommandFailedEvent) MethodInfo(com.megaease.easeagent.plugin.interceptor.MethodInfo) MongoInternalConnectionSendAndReceiveAsync4TraceInterceptor(com.megaease.easeagent.plugin.mongodb.interceptor.MongoInternalConnectionSendAndReceiveAsync4TraceInterceptor) Test(org.junit.Test)

Example 13 with 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);
}
Also used : CommandFailedEvent(com.mongodb.event.CommandFailedEvent) Context(com.megaease.easeagent.plugin.api.Context) Test(org.junit.Test)

Example 14 with Context

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);
}
Also used : Context(com.megaease.easeagent.plugin.api.Context)

Example 15 with Context

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);
}
Also used : Context(com.megaease.easeagent.plugin.api.Context)

Aggregations

Context (com.megaease.easeagent.plugin.api.Context)122 Test (org.junit.Test)101 MethodInfo (com.megaease.easeagent.plugin.interceptor.MethodInfo)87 ReportSpan (com.megaease.easeagent.plugin.report.tracing.ReportSpan)39 Span (com.megaease.easeagent.plugin.api.trace.Span)32 RequestContext (com.megaease.easeagent.plugin.api.context.RequestContext)13 Scope (com.megaease.easeagent.plugin.api.trace.Scope)13 Message (org.springframework.amqp.core.Message)10 URI (java.net.URI)9 LastJsonReporter (com.megaease.easeagent.mock.report.impl.LastJsonReporter)8 TagVerifier (com.megaease.easeagent.mock.plugin.api.utils.TagVerifier)7 BsonDocument (org.bson.BsonDocument)7 MockServerWebExchange (org.springframework.mock.web.server.MockServerWebExchange)7 HttpRequest (com.megaease.easeagent.plugin.tools.trace.HttpRequest)6 CommandSucceededEvent (com.mongodb.event.CommandSucceededEvent)6 ArrayList (java.util.ArrayList)6 BsonString (org.bson.BsonString)6 Call (okhttp3.Call)5 ClientRequest (org.springframework.web.reactive.function.client.ClientRequest)4 MockClientRequest (org.springframework.web.reactive.function.client.MockClientRequest)4