public static bool HandleRequest(object thisObj, object requestContext, object currentOperationContext, int opCode, int mdToken) { var handleRequestDelegate = Emit.DynamicMethodBuilder <Func <object, object, object, bool> > .GetOrCreateMethodCallDelegate( thisObj.GetType(), "HandleRequest", (OpCodeValue)opCode); if (!Tracer.Instance.Settings.IsIntegrationEnabled(IntegrationName) || !(requestContext is RequestContext castRequestContext)) { return(handleRequestDelegate(thisObj, requestContext, currentOperationContext)); } using (var wcfDelegate = WcfRequestMessageSpanIntegrationDelegate.CreateAndBegin(castRequestContext)) { try { return(handleRequestDelegate(thisObj, requestContext, currentOperationContext)); } catch (Exception ex) when(wcfDelegate?.SetExceptionForFilter(ex) ?? false) { // unreachable code throw; } } }
public static bool HandleRequest( object channelHandler, object requestContext, object currentOperationContext, int opCode, int mdToken, long moduleVersionPtr) { Func <object, object, object, bool> instrumentedMethod; var declaringType = channelHandler.GetInstrumentedType(ChannelHandlerTypeName); try { instrumentedMethod = MethodBuilder <Func <object, object, object, bool> > .Start(moduleVersionPtr, mdToken, opCode, nameof(HandleRequest)) .WithConcreteType(declaringType) .WithParameters(requestContext, currentOperationContext) .WithNamespaceAndNameFilters( ClrNames.Bool, "System.ServiceModel.Channels.RequestContext", "System.ServiceModel.OperationContext") .Build(); } catch (Exception ex) { Log.ErrorException($"Error resolving {ChannelHandlerTypeName}.{nameof(HandleRequest)}(...)", ex); throw; } if (!Tracer.Instance.Settings.IsIntegrationEnabled(IntegrationName) || !(requestContext is RequestContext castRequestContext)) { return(instrumentedMethod(channelHandler, requestContext, currentOperationContext)); } using (var wcfDelegate = WcfRequestMessageSpanIntegrationDelegate.CreateAndBegin(castRequestContext)) { try { return(instrumentedMethod(channelHandler, requestContext, currentOperationContext)); } catch (Exception ex) { wcfDelegate?.SetExceptionForFilter(ex); throw; } } }