Skip to content

Commit ef12e43

Browse files
author
Muriel Picone Farías
committed
Remove API class name from span name
1 parent 0287ab6 commit ef12e43

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def tracer
8888
end
8989

9090
def span_name(endpoint)
91-
"#{api_instance(endpoint)} #{request_method(endpoint)} #{path(endpoint)}"
91+
"#{request_method(endpoint)} #{path(endpoint)}"
9292
end
9393

9494
def run_attributes(payload)
@@ -97,7 +97,7 @@ def run_attributes(payload)
9797
{
9898
'component' => 'web',
9999
'operation' => 'endpoint_run',
100-
'grape.route.endpoint' => api_instance(endpoint),
100+
'grape.route.endpoint' => endpoint.options[:for]&.base.to_s,
101101
'grape.route.path' => path,
102102
'grape.route.method' => endpoint.options[:method].first,
103103
OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => request_method(endpoint),
@@ -116,10 +116,6 @@ def handle_payload_exception(span, exception)
116116
span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, exception.status)
117117
end
118118

119-
def api_instance(endpoint)
120-
endpoint.options[:for]&.base.to_s
121-
end
122-
123119
def request_method(endpoint)
124120
endpoint.options[:method]&.first
125121
end

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class BasicAPI < Grape::API
3737

3838
let(:app) { BasicAPI }
3939
let(:request_path) { '/hello' }
40-
let(:expected_span_name) { 'BasicAPI GET /hello' }
40+
let(:expected_span_name) { 'GET /hello' }
4141

4242
before { get request_path }
4343

@@ -103,7 +103,7 @@ class RouteParamAPI < Grape::API
103103

104104
let(:app) { RouteParamAPI }
105105
let(:request_path) { '/users/1' }
106-
let(:expected_span_name) { 'RouteParamAPI GET /users/:id' }
106+
let(:expected_span_name) { 'GET /users/:id' }
107107
let(:expected_path) { '/users/:id' }
108108

109109
before { get request_path }
@@ -128,7 +128,7 @@ class VersionedWithPrefixAPI < Grape::API
128128

129129
let(:app) { VersionedWithPrefixAPI }
130130
let(:request_path) { '/api/v1/hello' }
131-
let(:expected_span_name) { 'VersionedWithPrefixAPI GET /api/v1/hello' }
131+
let(:expected_span_name) { 'GET /api/v1/hello' }
132132
let(:expected_path) { '/api/v1/hello' }
133133

134134
before { get request_path }
@@ -156,7 +156,7 @@ class NestedAPI < Grape::API
156156

157157
let(:app) { NestedAPI }
158158
let(:request_path) { '/internal/users' }
159-
let(:expected_span_name) { 'NestedAPI GET /internal/users' }
159+
let(:expected_span_name) { 'GET /internal/users' }
160160
let(:expected_path) { '/internal/users' }
161161

162162
before { get request_path }
@@ -181,7 +181,7 @@ class FilteredAPI < Grape::API
181181

182182
let(:app) { FilteredAPI }
183183
let(:request_path) { '/filtered' }
184-
let(:expected_span_name) { 'FilteredAPI GET /filtered' }
184+
let(:expected_span_name) { 'GET /filtered' }
185185

186186
before { get request_path }
187187

@@ -239,7 +239,7 @@ class ValidationErrorAPI < Grape::API
239239

240240
let(:app) { ValidationErrorAPI }
241241
let(:request_path) { '/new' }
242-
let(:expected_span_name) { 'ValidationErrorAPI POST /new' }
242+
let(:expected_span_name) { 'POST /new' }
243243
let(:headers) { { 'Content-Type' => 'application/json' } }
244244
let(:expected_error_type) { 'Grape::Exceptions::ValidationErrors' }
245245

@@ -279,7 +279,7 @@ class RaisedErrorAPI < Grape::API
279279

280280
let(:app) { RaisedErrorAPI }
281281
let(:request_path) { '/failure' }
282-
let(:expected_span_name) { 'RaisedErrorAPI GET /failure' }
282+
let(:expected_span_name) { 'GET /failure' }
283283
let(:expected_error_type) { 'StandardError' }
284284

285285
before do
@@ -326,7 +326,7 @@ class ErrorInFilterAPI < Grape::API
326326

327327
let(:app) { ErrorInFilterAPI }
328328
let(:request_path) { '/filtered' }
329-
let(:expected_span_name) { 'ErrorInFilterAPI GET /filtered' }
329+
let(:expected_span_name) { 'GET /filtered' }
330330
let(:expected_error_type) { 'StandardError' }
331331

332332
before do
@@ -369,7 +369,7 @@ class ErrorInFormatterAPI < Grape::API
369369

370370
let(:app) { ErrorInFormatterAPI }
371371
let(:request_path) { '/bad_format' }
372-
let(:expected_span_name) { 'ErrorInFormatterAPI GET /bad_format' }
372+
let(:expected_span_name) { 'GET /bad_format' }
373373
let(:expected_error_type) { 'Grape::Exceptions::InvalidFormatter' }
374374

375375
before { get request_path }
@@ -412,7 +412,7 @@ class ErrorResponseAPI < Grape::API
412412

413413
let(:app) { ErrorResponseAPI }
414414
let(:request_path) { '/error_response' }
415-
let(:expected_span_name) { 'ErrorResponseAPI GET /error_response' }
415+
let(:expected_span_name) { 'GET /error_response' }
416416

417417
before { get request_path }
418418

@@ -440,7 +440,7 @@ class IgnoredEventAPI < Grape::API
440440
let(:config) { { ignored_events: [:endpoint_render] } }
441441
let(:app) { IgnoredEventAPI }
442442
let(:request_path) { '/success' }
443-
let(:expected_span_name) { 'IgnoredEventAPI GET /success' }
443+
let(:expected_span_name) { 'GET /success' }
444444

445445
before { get request_path }
446446

0 commit comments

Comments
 (0)