Skip to content

Option to treat HTTP status codes such as 500 as errors #2700

@markmcclelland-artisan

Description

@markmcclelland-artisan

Feature description

I am looking for a feature similar to the one that was described in this question: #2441

I am trying to configure the HTTP client error statuses for Datadog Trace on Android, similar to how it's done in the Java library using the environment variable DD_HTTP_CLIENT_ERROR_STATUSES (e.g., 400-403,405,410-499). By default, the Java library reports 4xx errors as client errors for tracing, but I am unable to achieve the same behavior in the Android SDK.

I need to configure this because I have custom HTTP status codes that need to be considered as errors for tracing, and the default 4xx range doesn't cover them.

In my case, I want to treat client status codes in the range of 500-599 as errors. Currently, these all have a status of "OK".

I tried implementing a custom interceptor and using GlobalTracer.get().activeSpan() to query the active span and change its Tags.ERROR value to true when the HTTP status code is >= 500, but I wasn't able to get it to work.

The question I linked to above was closed out, with a comment that an internal ticket had been created to track this work item. Is there a way we can see the status of that work? If not, can we keep this feature request open as a proxy for that internal ticket?

Thanks!

Proposed solution

One possibility would be to expose client error statuses as an option on TraceConfiguration. Another possibility would be to add an optional validateStatus() function similar to the one that was implemented here as part of dd-trace-js: https://github.com/DataDog/dd-trace-js/pull/301/files.

Other relevant information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions