Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/raven/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ def initialize(init = {})

@user.merge!(@context.user)
@extra.merge!(@context.extra)

tags = @tags.dup
@tags = {}
@tags.merge!(@configuration.tags)
@tags.merge!(@context.tags)
@tags.merge!(tags)

# Some type coercion
@timestamp = @timestamp.strftime('%Y-%m-%dT%H:%M:%S') if @timestamp.is_a?(Time)
Expand Down
44 changes: 44 additions & 0 deletions spec/raven/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,50 @@
end
end

context 'tags hierarchy respected' do
let(:hash) do
config = Raven::Configuration.new
config.tags = {
'configuration_context_event_key' => 'configuration_value',
'configuration_context_key' => 'configuration_value',
'configuration_event_key' => 'configuration_value',
'configuration_key' => 'configuration_value',
}

Raven.tags_context({
'configuration_context_event_key' => 'context_value',
'configuration_context_key' => 'context_value',
'context_event_key' => 'context_value',
'context_key' => 'context_value',
})

Raven::Event.new(
:level => 'warning',
:logger => 'foo',
:tags => {
'configuration_context_event_key' => 'event_value',
'configuration_event_key' => 'event_value',
'context_event_key' => 'event_value',
'event_key' => 'event_value',
},
:server_name => 'foo.local',
:configuration => config
).to_hash
end

it 'merges tags data' do
expect(hash[:tags]).to eq({
'configuration_context_event_key' => 'event_value',
'configuration_context_key' => 'context_value',
'configuration_event_key' => 'event_value',
'context_event_key' => 'event_value',
'configuration_key' => 'configuration_value',
'context_key' => 'context_value',
'event_key' => 'event_value',
})
end
end

describe '.initialize' do
it 'should not touch the env object for an ignored environment' do
Raven.configure do |config|
Expand Down