Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TRACE] OTLP HTTP exporter console logs issues #1702

Closed
marcalff opened this issue Oct 20, 2022 · 0 comments · Fixed by #1703
Closed

[TRACE] OTLP HTTP exporter console logs issues #1702

marcalff opened this issue Oct 20, 2022 · 0 comments · Fixed by #1703
Labels
bug Something isn't working

Comments

@marcalff
Copy link
Member

Using the OTLP HTTP exporter, and printing debug logs generated by otlp_http_client.cc leads to the following data:

2022-10-20T22:00:14.654921Z 0 [...] [OTEL DEBUG] /.../opentelemetry-cpp/opentelemetry-cpp-1.6.1/exporters/otlp/src/otlp_http_client.cc:126 [OTLP HTTP Client] Export success, Status:200Header:        Content-Length : 0^M,   Content-Type : application/x-protobuf^M,        Date : Thu, 20 Oct 2022 22:00:14 GMT^M,Body:

Note how "Status:200Header:" is printed, without spaces or comma to separate status from header.

Note how fields are printed sometime as "field:value", sometime as "field : value"
Because of this, logs are harder to parse that necessary.

If using spaces before and after ":", and a "," plus space to separate fields, then please use this consistently.

For example, print "Status : 200, Header :" instead.

The code printing this log is exporter::otlp::ResponseHandler::BuildResponseLogMessage

  std::string BuildResponseLogMessage(http_client::Response &response,
                                      const std::string &body) noexcept
  {
    std::stringstream ss;
    ss << "Status:" << response.GetStatusCode() << "Header:";
    response.ForEachHeader([&ss](opentelemetry::nostd::string_view header_name,
                                 opentelemetry::nostd::string_view header_value) {
      ss << "\t" << header_name.data() << " : " << header_value.data() << ",";
      return true;
    });
    ss << "Body:" << body;

    return ss.str();
  }

Also, as seen when reading the code in exporter::otlp::ResponseHandler::OnResponse,

      if (response.GetStatusCode() != 200 && response.GetStatusCode() != 202)
      {
        log_message = BuildResponseLogMessage(response, body_);

        OTEL_INTERNAL_LOG_ERROR("OTLP HTTP Client] Export failed, " << log_message);
        result = sdk::common::ExportResult::kFailure;
      }

      if (console_debug_)
      {
        if (log_message.empty())
        {
          log_message = BuildResponseLogMessage(response, body_);
        }
        OTEL_INTERNAL_LOG_DEBUG("[OTLP HTTP Client] Export success, " << log_message);
      }
    }

The OTEL_INTERNAL_LOG_DEBUG() log statement prints "Export success", including on failures.

@marcalff marcalff added the bug Something isn't working label Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant