public static async Task <T> RecordSendAndReceive <T>(RedisSettings usedSettings, string key, string callType, Func <Task <Pair <T> > > executeAndReturnSentAndReceivedObject, [CallerMemberName] string commandName = "") { var tracerFactory = usedSettings.CommandTracerFactory; ICommandTracer tracer = null; if (tracerFactory != null) { tracer = tracerFactory(); var command = callType + "." + commandName; tracer.CommandStart(usedSettings, command, key); // start within context } object sendObject = null; T receivedObject = default(T); bool isError = true; try { var sendAndReceivedObject = await executeAndReturnSentAndReceivedObject().ConfigureAwait(false); sendObject = sendAndReceivedObject.SentObject; receivedObject = sendAndReceivedObject.ReceivedObject; isError = false; } finally { if (tracer != null) { tracer.CommandFinish(sendObject, receivedObject, isError); // finish without context } } return(receivedObject); }
public static async Task <T> RecordSendAndReceive <T>(RedisSettings usedSettings, RedisKey key, string callType, Func <Task <MonitorPair <T> > > executeAndReturnSentAndReceivedObject, [CallerMemberName] string commandName = "") { var tracerFactory = usedSettings.CommandTracerFactory; ICommandTracer tracer = null; if (tracerFactory != null) { tracer = tracerFactory(); var command = callType + "." + commandName; tracer.CommandStart(usedSettings, command, key); // start within context } MonitorPair <T> pair = null; bool isError = true; try { pair = await executeAndReturnSentAndReceivedObject().ForAwait(); isError = false; } finally { if (tracer != null) { tracer.CommandFinish(pair?.SentObject, pair?.SentSize ?? 0, (pair != null) ? pair.ReceivedObject : default(T), pair?.ReceivedSize ?? 0, isError); // finish without context } } return((pair == null) ? default(T) : pair.ReceivedObject); }
public static async Task RecordSend(RedisSettings usedSettings, string key, string callType, Func <Task <object> > executeAndReturnSentObject, [CallerMemberName] string commandName = "") { var tracerFactory = usedSettings.CommandTracerFactory; ICommandTracer tracer = null; if (tracerFactory != null) { tracer = tracerFactory(); var command = callType + "." + commandName; tracer.CommandStart(usedSettings, command, key); // start within context } object sendObject = null; bool isError = true; try { sendObject = await executeAndReturnSentObject().ConfigureAwait(false); isError = false; } finally { if (tracer != null) { tracer.CommandFinish(sendObject, null, isError); // finish without context } } }
public SimpleCommandWithNoResultHandler(ICommandTracer commandTracer) { _commandTracer = commandTracer; }
Monitor(ICommandTracer tracer) { this.tracer = tracer; }