|
404 | 404 |
|
405 | 405 | details = [::Google::Protobuf::Any.pack(::Google::Protobuf::StringValue.new(value: 'you are a bad request'))] |
406 | 406 | status = ::Google::Rpc::Status.encode(::Google::Rpc::Status.new(code: 1, message: 'bad request', details: details)) |
407 | | - stub_request(:post, 'http://localhost:4318/v1/traces').to_return(status: 400, body: status) |
| 407 | + stub_request(:post, 'http://localhost:4318/v1/traces').to_return(status: 400, body: status, headers: { 'Content-Type' => 'application/x-protobuf' }) |
408 | 408 | span_data = OpenTelemetry::TestHelpers.create_span_data |
409 | 409 |
|
410 | 410 | result = exporter.export([span_data]) |
|
418 | 418 | OpenTelemetry.logger = logger |
419 | 419 | end |
420 | 420 |
|
| 421 | + it 'logs a specific message when there is a 404' do |
| 422 | + log_stream = StringIO.new |
| 423 | + logger = OpenTelemetry.logger |
| 424 | + OpenTelemetry.logger = ::Logger.new(log_stream) |
| 425 | + |
| 426 | + stub_request(:post, 'http://localhost:4318/v1/traces').to_return(status: 404, body: "Not Found\n") |
| 427 | + span_data = OpenTelemetry::TestHelpers.create_span_data |
| 428 | + |
| 429 | + result = exporter.export([span_data]) |
| 430 | + |
| 431 | + _(log_stream.string).must_match( |
| 432 | + %r{ERROR -- : OpenTelemetry error: OTLP exporter received http\.code=404 for uri: '/v1/traces'} |
| 433 | + ) |
| 434 | + |
| 435 | + _(result).must_equal(FAILURE) |
| 436 | + ensure |
| 437 | + OpenTelemetry.logger = logger |
| 438 | + end |
| 439 | + |
421 | 440 | it 'handles Zlib gzip compression errors' do |
422 | 441 | stub_request(:post, 'http://localhost:4318/v1/traces').to_raise(Zlib::DataError.new('data error')) |
423 | 442 | span_data = OpenTelemetry::TestHelpers.create_span_data |
|
0 commit comments