Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Patryk Peszko committed Dec 3, 2009
0 parents commit 6559858
Show file tree
Hide file tree
Showing 179 changed files with 13,349 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/log/*
/tmp/*
vendor/gems/
!vendor/gems/cache/
vendor/rails
Capfile
/doc/
3 changes: 3 additions & 0 deletions CURL_TESTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
curl -H "Content-Type:application/json" -H "Accept:application/json" \
-d "{\"notification\":{\"category\":\"exception\",\"payload\":{\"message\":\"memory warning\"},\"identifier\":\"solr indexer\"}}" \
http://localhost:3000/projects/preview/notifications
101 changes: 101 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
=ExceptionsBegone

ExceptionsBegone is Rails application for handling notifications (also exceptions) from your systems.
The purpose of the system is to aggregate anything you send to it and it's meant for projects which cannot
share its exceptions with other companies (privacy policy).

BTW: it is a tool. It's not supposed to win any design awards (yet ;)

There are just few rules:

* you have to specify identifier (which will be used for bundling notifications)
* specify category
* and not forget the payload

It is irrelevant if you sending this informations from a ruby, erlang, java, php, c# application or from a console.
We provide a ruby {gem - exceptions_begone_notifier}[http://github.com/xing/exceptions_begone_notifier]
which hooks itself into rails application, catches exceptions and provides some easy to use sender methods.
If you need something else: just hack it :)

This application is under heavy development, however is stable to be use in production.

==Installation

It just a normal Rails application. Capistrano will help you to put it live.

==Accepted data format

Here is an example how the message could look like (in JSON)

<tt>{</tt>
"notification": {
"category": "nagios",
"payload": {
"message": "memory warning",
"host": "my_big_host",
"some_important": "informations"
},
"identifier": "solr indexer"
}
<tt>}</tt>

<tt>payload</tt> could be everything you can imagine.

and you could POST it to the chosen project:
http://localhost:3000/projects/preview/notifications where
<tt>preview</tt> would be the project name.

See CURL_TESTS for curl examples.

==Usage

The user doesn't have to log in into the system. But only a logged in user can "work"
on an incoming exception. It means he can click the "processing" button which will put his name
on the exception and change it status to "in progress". After fixing the code he can click on "done" and
remove the exception from the view.

The first exception of the bundle(stack) will be send via email to the specified email address.
This behavior is not configurable right now (and that should change). You can also specified a threshold
on a project show page which will send an email with a high priority if number of the same exceptions reach set value.

The other way to stay up-to-date with notifications is to subscribe to the atom feed.

If you don't want to carry about some sort of exceptions go to exclusions and specify a filter (regex).
After that this particular messages won't be show in the default view.

There are many more feature on the way (also redesign) but I will be happy about any contribution which could
make this tool great for any developers in the world.

I will also try to make this readme more worth reading. Stay tuned!

==Authors

{Patryk Peszko}[http://github.com/ppeszko]

==Contributors

XING Team

==License

The MIT License

Copyright (c) 2009 {XING AG}[http://www.xing.com/]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
10 changes: 10 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

require 'tasks/rails'
Empty file added TODO
Empty file.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
33 changes: 33 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details

# Scrub sensitive parameters from your log
filter_parameter_logging :password

helper_method :current_user

private

def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end

def current_user
return current_user_session && current_user_session.record
end

def load_project
project_id = params[:project_id] ? params[:project_id] : params[:id]

@project = if project_id =~ /^\d+$/
Project.find(project_id)
else
Project.find_by_name(project_id)
end
end
end
40 changes: 40 additions & 0 deletions app/controllers/exclusions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class ExclusionsController < ApplicationController

before_filter :load_project

def index
@exclusions = @project.exclusions
end

def create
@exclusion = @project.exclusions.build(params[:exclusion])
if @exclusion.save
redirect_to project_exclusions_url(@project)
else
render :new
end
end

def edit
@exclusion = @project.exclusions.find(params[:id])
render :new
end

def update
@exclusion = @project.exclusions.find(params[:id])

if @exclusion
@exclusion.update_attributes(params[:exclusion])
redirect_to project_exclusions_url(@project)
else
redirect_to project_exclusions_url(@project)
end
end

def destroy
@exclusion = @project.exclusions.find(params[:id])
@exclusion.destroy if @exclusion
redirect_to project_exclusions_url(@project)
end

end
27 changes: 27 additions & 0 deletions app/controllers/notifications_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class NotificationsController < ApplicationController

skip_before_filter :verify_authenticity_token

before_filter :load_project

def create
attributes = params[:notification]
@notification = Notification.build(@project, attributes)

if @notification.save
respond_to do |format|
format.html do
flash[:notice] = "You accidentally the whole notification!!!"
redirect_to project_notifications_url(@project)
end
format.xml { head :created }
format.json { head :created }
end
else
respond_to do |format|
format.html { render :new }
format.json { head 400 }
end
end
end
end
45 changes: 45 additions & 0 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class ProjectsController < ApplicationController

before_filter :load_project

def index
@projects = Project.paginate(:per_page => 10, :page => params[:page])
end

def show
redirect_to project_stacks_url(@project)
end

def edit
render :new
end

def update
@project.update_attributes(params[:project])
if @project.save
flash[:notice] = "Project succefully updated"
redirect_to root_url
else
render :new
end
end

def new
@project = Project.new
end

def create
@project = Project.new(params[:project])
if @project.save
flash[:notice] = "You accidentally the whole project!!!"
redirect_to root_url
else
render :new
end
end

def destroy
@project.destroy
redirect_to root_url
end
end
50 changes: 50 additions & 0 deletions app/controllers/stacks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
class StacksController < ApplicationController

before_filter :load_project

@@order_possiblities = {"category" => "category", "identifier" => "identifier",
"count" => "notifications_count DESC", "status" => "status",
"updated_at" => "updated_at DESC", "last_occurred_at" => "last_occurred_at DESC"}

def index
per_page = params[:per_page] || 50
order = @@order_possiblities.fetch(params[:order], "updated_at DESC")
session[:filter] = params[:filter] ? params[:filter] : session[:filter]
matching_mode = params[:filter] == "include" ? :include : :exclude

if params[:search]
@stacks = @project.stacks.with_identifier(params[:search]).exclusions_matching(@project.exclusions, matching_mode).paginate(:per_page => per_page, :page => params[:page], :order => order)
else
@stacks = @project.stacks.with_status(session[:filter]).exclusions_matching(@project.exclusions, matching_mode).paginate(:per_page => per_page, :page => params[:page], :order => order)
end
end

def show
@notifications = Notification.paginate_by_stack_id(params[:id], :per_page => 1, :page => params[:page], :order => "id DESC")
@notification = @notifications.first
@sections = ActiveSupport::JSON.decode(@notification.payload)
if @sections["backtrace"]
@sections["backtrace"] = @sections["backtrace"].join("<br/>")
end
end

def update
@stack = @project.stacks.find(params[:id])
@stack.update_attributes(params[:stack])
if @stack.save
flash[:notice] = "Notification succefully updated"
respond_to do |format|
format.js
format.html { redirect_to project_stacks_url(@project) }
end
else
redirect_to project_stacks_url(@project)
end
end

def destroy
@stack = Stack.find(params[:id])
Stack.destroy_all(:identifier => @stack.identifier)
redirect_to project_stacks_url(@project)
end
end
23 changes: 23 additions & 0 deletions app/controllers/user_sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class UserSessionsController < ApplicationController

def new
@user_session = UserSession.new
end

def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Logged in"
redirect_to root_url
else
render :new
end
end

def destroy
@user_session = UserSession.find
@user_session.destroy
flash[:notice] = "Logged out"
redirect_to root_url
end
end
37 changes: 37 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
class UsersController < ApplicationController

def index
@users = User.all
end

def new
@user = User.new
end

def edit
@user = current_user
render :new
end

def update
@user = current_user
@user.update_attributes(params[:user])
if @user.save
flash[:notice] = "Profil updated"
redirect_to root_url
else
render :new
end
end

def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = "Registration successful"
redirect_to root_url
else
render :new
end
end

end
3 changes: 3 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
2 changes: 2 additions & 0 deletions app/helpers/environments_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module EnvironmentsHelper
end
Loading

0 comments on commit 6559858

Please sign in to comment.