Skip to content

[FEATURE]: Handle DjangoRestFramework 404s as status=ok #15647

@nijave

Description

@nijave

Package Name

django-rest-framework

Package Version(s)

No response

Describe the goal of the feature

In DRF, 404s are commonly created by raising Http404. When this happens, ddtrace marks the span as having an error which then creates an Error in DD Error Tracking.

ddtrace should handle DRF 404s the same way as Django 404s and not mark these are errors

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/ddtrace/contrib/internal/trace_utils.py", line 336, in wrapper
    return func(mod, pin, wrapped, instance, args, kwargs)
  File "/usr/local/lib/python3.10/site-packages/ddtrace/contrib/internal/django/patch.py", line 340, in wrapped
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/rest_framework/decorators.py", line 50, in handler
    return func(*args, **kwargs)
  File "/app/hris_connector/sync/views.py", line 170, in latest_sync_log
    latest_sync_log = get_latest_sync_log(ff_company_id, status)
  File "/app/hris_connector/sync/db.py", line 23, in get_latest_sync_log
    raise Http404("No import log found")
django.http.response.Http404: No import log found

Is your feature request related to a problem?

Yes, we're seeing a high degree of false positives in Datadog Error Tracking

Describe alternatives you've considered

We're currently using a TraceProcessor to unmark the errors

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions