public static T Excuting <T>(this DiagnosticListener @this, Func <T> mongoRun, MongoClient mongoClient) { var operationId = Guid.Empty; try { operationId = Instance.ExcuteBefore(mongoClient); var result = mongoRun(); Instance.ExcuteAfter(operationId, mongoClient); return(result); } catch (Exception ex) { Instance.ExcuteError(operationId, ex, mongoClient); throw; } }