Skip to content

Commit

Permalink
Merge pull request #53 from DataDog/truncate_events
Browse files Browse the repository at this point in the history
Truncate events
  • Loading branch information
conorbranagan committed Nov 17, 2014
2 parents 029ef5a + b282df9 commit 897aa0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/dogapi/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def to_hash
class EventService < Dogapi::Service

API_VERSION = "1.0.0"
MAX_BODY_LENGTH = 4000
MAX_TITLE_LENGTH = 100

# <b>DEPRECATED:</b> Going forward, use the V1 services. This legacy service will be
# removed in an upcoming release.
Expand All @@ -82,8 +84,8 @@ def submit(api_key, event, scope=nil, source_type=nil)
:alert_type => event.alert_type,
:event_type => event.event_type,
:event_object => event.event_object,
:msg_title => event.msg_title,
:msg_text => event.msg_text,
:msg_title => event.msg_title[0..MAX_TITLE_LENGTH - 1],
:msg_text => event.msg_text[0..MAX_BODY_LENGTH - 1],
:json_payload => event.json_payload,
}

Expand Down
6 changes: 4 additions & 2 deletions lib/dogapi/v1/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class V1 # for namespacing
class EventService < Dogapi::APIService

API_VERSION = "v1"
MAX_BODY_LENGTH = 4000
MAX_TITLE_LENGTH = 100

# Records an Event with no duration
def post(event, scope=nil)
Expand All @@ -17,8 +19,8 @@ def post(event, scope=nil)
}

body = event.to_hash.merge({
:title => event.msg_title,
:text => event.msg_text,
:title => event.msg_title[0..MAX_TITLE_LENGTH - 1],
:text => event.msg_text[0..MAX_BODY_LENGTH - 1],
:date_happened => event.date_happened.to_i,
:host => scope.host,
:device => scope.device,
Expand Down

0 comments on commit 897aa0b

Please sign in to comment.