Skip to content

Commit f1abe62

Browse files
author
Muriel Picone Farías
committed
Remove http.status_code attribute
1 parent ef12e43 commit f1abe62

File tree

2 files changed

+1
-22
lines changed

2 files changed

+1
-22
lines changed

instrumentation/grape/lib/opentelemetry/instrumentation/grape/event_handler.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ def endpoint_run_finish(_name, _id, payload)
2626
token = payload.delete(:__opentelemetry_ctx_token)
2727
return unless span && token
2828

29-
if payload[:exception_object]
30-
handle_payload_exception(span, payload[:exception_object])
31-
else
32-
span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, payload[:endpoint].status)
33-
end
29+
handle_payload_exception(span, payload[:exception_object]) if payload[:exception_object]
3430

3531
span.finish
3632
OpenTelemetry::Context.detach(token)
@@ -111,9 +107,6 @@ def run_attributes(payload)
111107
def handle_payload_exception(span, exception)
112108
span.record_exception(exception)
113109
span.status = OpenTelemetry::Trace::Status.error("Unhandled exception of type: #{exception.class}")
114-
return unless exception.respond_to?('status') && exception.status
115-
116-
span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, exception.status)
117110
end
118111

119112
def request_method(endpoint)

instrumentation/grape/test/opentelemetry/instrumentation/grape_test.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class BasicAPI < Grape::API
5555
_(span.attributes['http.route']).must_equal '/hello'
5656
_(span.attributes['grape.route.method']).must_equal 'GET'
5757
_(span.attributes['http.method']).must_equal 'GET'
58-
_(span.attributes['http.status_code']).must_equal 200
5958
end
6059

6160
it 'produces a child endpoint_render span with the expected attributes' do
@@ -258,7 +257,6 @@ class ValidationErrorAPI < Grape::API
258257
_(span.events.first.name).must_equal 'exception'
259258
_(span.events.first.attributes['exception.type']).must_equal expected_error_type
260259
_(span.events.first.attributes['exception.message']).must_equal 'name is missing'
261-
_(span.attributes['http.status_code']).must_equal(400)
262260
end
263261
end
264262

@@ -308,12 +306,6 @@ class RaisedErrorAPI < Grape::API
308306
_(span.status.code).wont_equal OpenTelemetry::Trace::Status::ERROR
309307
end
310308
end
311-
312-
it 'does not add the http.status_code attribute to the endpoint_run span' do
313-
span = run_spans.first
314-
315-
_(span.attributes).wont_include 'http.status_code'
316-
end
317309
end
318310

319311
describe 'when an API endpoint raises an error in the filters' do
@@ -422,12 +414,6 @@ class ErrorResponseAPI < Grape::API
422414
_(span.status.code).wont_equal OpenTelemetry::Trace::Status::ERROR
423415
end
424416
end
425-
426-
it 'sets endpoint_run span status code to expected value' do
427-
span = run_spans.first
428-
429-
_(span.attributes['http.status_code']).must_equal 404
430-
end
431417
end
432418

433419
describe 'when an API endpoint receives a request and some events are ignored in the configs' do

0 commit comments

Comments
 (0)