public static T SendReceive <T>(object redisNativeClient, byte[][] cmdWithBinaryArgs, object fn, object completePipelineFn, bool sendWithoutRead) { var originalMethod = Emit.DynamicMethodBuilder <Func <object, byte[][], object, object, bool, T> > .GetOrCreateMethodCallDelegate( redisNativeClient.GetType(), "SendReceive", methodGenericArguments : new[] { typeof(T) }); using (var scope = RedisHelper.CreateScope( Tracer.Instance, IntegrationName, GetHost(redisNativeClient), GetPort(redisNativeClient), GetRawCommand(cmdWithBinaryArgs))) { try { return(originalMethod(redisNativeClient, cmdWithBinaryArgs, fn, completePipelineFn, sendWithoutRead)); } catch (Exception ex) when(scope?.Span.SetExceptionForFilter(ex) ?? false) { // unreachable code throw; } } }
public static T SendReceive <T>( object redisNativeClient, byte[][] cmdWithBinaryArgs, object fn, object completePipelineFn, bool sendWithoutRead, int opCode, int mdToken, long moduleVersionPtr) { if (redisNativeClient == null) { throw new ArgumentNullException(nameof(redisNativeClient)); } Func <object, byte[][], object, object, bool, T> instrumentedMethod; try { var instrumentedType = redisNativeClient.GetInstrumentedType(RedisNativeClient); instrumentedMethod = MethodBuilder <Func <object, byte[][], object, object, bool, T> > .Start(moduleVersionPtr, mdToken, opCode, nameof(SendReceive)) .WithConcreteType(instrumentedType) .WithParameters(cmdWithBinaryArgs, fn, completePipelineFn, sendWithoutRead) .WithMethodGenerics(typeof(T)) .WithNamespaceAndNameFilters(ClrNames.Ignore, "System.Byte[][]", "System.Func`1", "System.Action`1", ClrNames.Bool) .Build(); } catch (Exception ex) { Log.ErrorRetrievingMethod( exception: ex, moduleVersionPointer: moduleVersionPtr, mdToken: mdToken, opCode: opCode, instrumentedType: RedisNativeClient, methodName: nameof(SendReceive), instanceType: redisNativeClient.GetType().AssemblyQualifiedName); throw; } using (var scope = RedisHelper.CreateScope( Tracer.Instance, IntegrationName, GetHost(redisNativeClient), GetPort(redisNativeClient), GetRawCommand(cmdWithBinaryArgs))) { try { return(instrumentedMethod(redisNativeClient, cmdWithBinaryArgs, fn, completePipelineFn, sendWithoutRead)); } catch (Exception ex) { scope?.Span?.SetException(ex); throw; } } }
public static T SendReceive <T>( object redisNativeClient, byte[][] cmdWithBinaryArgs, object fn, object completePipelineFn, bool sendWithoutRead, int opCode, int mdToken) { Func <object, byte[][], object, object, bool, T> instrumentedMethod = null; try { var instrumentedType = redisNativeClient.GetInstrumentedType(RedisNativeClient); instrumentedMethod = MethodBuilder <Func <object, byte[][], object, object, bool, T> > .Start(instrumentedType.Assembly, mdToken, opCode, nameof(SendReceive)) .WithConcreteType(instrumentedType) .WithParameters(cmdWithBinaryArgs, fn, completePipelineFn, sendWithoutRead) .WithMethodGenerics(typeof(T)) .Build(); } catch (Exception ex) { Log.ErrorException($"Error resolving {RedisNativeClient}.{nameof(SendReceive)}(...)", ex); throw; } using (var scope = RedisHelper.CreateScope( Tracer.Instance, IntegrationName, GetHost(redisNativeClient), GetPort(redisNativeClient), GetRawCommand(cmdWithBinaryArgs))) { try { return(instrumentedMethod(redisNativeClient, cmdWithBinaryArgs, fn, completePipelineFn, sendWithoutRead)); } catch (Exception ex) { scope?.Span?.SetException(ex); throw; } } }