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
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ def allowed_rack_request_headers
key = header.to_s.upcase.gsub(/[-\s]/, '_')
case key
when 'CONTENT_TYPE', 'CONTENT_LENGTH'
memo[key] = build_attribute_name('http.request.headers.', header)
memo[key] = build_attribute_name('http.request.header.', header)
else
memo["HTTP_#{key}"] = build_attribute_name('http.request.headers.', header)
memo["HTTP_#{key}"] = build_attribute_name('http.request.header.', header)
end
end
end

def allowed_response_headers
@allowed_response_headers ||= Array(config[:allowed_response_headers]).each_with_object({}) do |header, memo|
memo[header] = build_attribute_name('http.response.headers.', header)
memo[header.to_s.upcase] = build_attribute_name('http.response.headers.', header)
memo[header] = build_attribute_name('http.response.header.', header)
memo[header.to_s.upcase] = build_attribute_name('http.response.header.', header)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,30 +171,30 @@
end

it 'defaults to nil' do
_(first_span.attributes['http.request.headers.foo_bar']).must_be_nil
_(first_span.attributes['http.request.header.foo_bar']).must_be_nil
end

describe 'when configured' do
let(:config) { default_config.merge(allowed_request_headers: ['foo_BAR']) }

it 'returns attribute' do
_(first_span.attributes['http.request.headers.foo_bar']).must_equal 'http foo bar value'
_(first_span.attributes['http.request.header.foo_bar']).must_equal 'http foo bar value'
end
end

describe 'when content-type' do
let(:config) { default_config.merge(allowed_request_headers: ['CONTENT_TYPE']) }

it 'returns attribute' do
_(first_span.attributes['http.request.headers.content_type']).must_equal 'application/json'
_(first_span.attributes['http.request.header.content_type']).must_equal 'application/json'
end
end

describe 'when content-length' do
let(:config) { default_config.merge(allowed_request_headers: ['CONTENT_LENGTH']) }

it 'returns attribute' do
_(first_span.attributes['http.request.headers.content_length']).must_equal '123'
_(first_span.attributes['http.request.header.content_length']).must_equal '123'
end
end
end
Expand All @@ -205,21 +205,21 @@
end

it 'defaults to nil' do
_(first_span.attributes['http.response.headers.foo_bar']).must_be_nil
_(first_span.attributes['http.response.header.foo_bar']).must_be_nil
end

describe 'when configured' do
let(:config) { default_config.merge(allowed_response_headers: ['Foo-Bar']) }

it 'returns attribute' do
_(first_span.attributes['http.response.headers.foo_bar']).must_equal 'foo bar response header'
_(first_span.attributes['http.response.header.foo_bar']).must_equal 'foo bar response header'
end

describe 'case-sensitively' do
let(:config) { default_config.merge(allowed_response_headers: ['fOO-bAR']) }

it 'returns attribute' do
_(first_span.attributes['http.response.headers.foo_bar']).must_equal 'foo bar response header'
_(first_span.attributes['http.response.header.foo_bar']).must_equal 'foo bar response header'
end
end
end
Expand Down