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

opentelemetry-otlp exporter with http-proto: should it error on unsuccessful status code? #1275

Closed
sigilioso opened this issue Sep 19, 2023 · 2 comments · Fixed by #1484
Closed
Labels
A-trace Area: issues related to tracing enhancement New feature or request triage:accepted Has been triaged and accepted.

Comments

@sigilioso
Copy link

sigilioso commented Sep 19, 2023

I had some issues setting up the OTLP exporter with http-proto tu report metrics (I finally realized that I needed to include not only the reqwest-client but also the reqwest-rustls feature, since I am using TLS)

While debugging the setup, I would had found really useful having more information about the request errors. Therefore, I was considering extending the MetricsClient implementation of OtlpHttpClient to also consider unsuccessful status codes. Something similar to this:

        let response = client
            .send(request)
            .await
            .map_err(|e| MetricsError::ExportErr(Box::new(Error::RequestFailed(e))))?;

        if !response.status().is_success() {
            let body_msg = std::str::from_utf8(response.body().iter().as_slice())
                .unwrap_or("response body is omitted because it cannot be decoded");
            return Err(MetricsError::ExportErr(Box::new(Error::RequestFailed(
                format!("request failed with status {} ({})", response.status(), body_msg).into(),
            ))))?;
        }

I also realized that opentelemetry_http::ResponseExt already provides a function to check the status code. Unfortunately, it is specialized for traces (it returns TraceError). Maybe a refactor in opentelemetry_http::ResponseExt to use a different error that could be mapped to TraceError, MetricError and LogError would be a better approach.

If this is something you also consider useful and you could provide some guidance, I would be willing to work on it.

@djc
Copy link
Contributor

djc commented Sep 19, 2023

We should definitely log and/or yield errors in these cases, any contribution is welcome!

@cijothomas
Copy link
Member

We should definitely log and/or yield errors in these cases, any contribution is welcome!

💯

@TommyCpp TommyCpp added enhancement New feature or request A-trace Area: issues related to tracing triage:accepted Has been triaged and accepted. labels Sep 19, 2023
jaymell added a commit to jaymell/opentelemetry-rust that referenced this issue Jan 19, 2024
Surfacing these errors is valuable for troubleshooting
configuration issues.

Also modify `ResponseExt` to return the more generic `HttpError`.

Fixes open-telemetry#1275.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trace Area: issues related to tracing enhancement New feature or request triage:accepted Has been triaged and accepted.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants