elastic / elastic/apm-agent-python

[EVENT OUTCOME] 4xx status codes are always reported as errors

Offen
#1,760 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
agent-python community triage
Vorherrschende Sprache
Python
Sterne
431
Forks
239
Ø Merge
5 T. 10 Std.
Gemergte PRs (30 T.)
7

Beschreibung

**Describe the bug**:
For any calls to services, all 4xx status codes are reporting as error. This includes expected 401 / 403 / 404 codes, which just indicate an issue with the requester (not an error in code).

This causes our alerts to be useless since we cannot tell if something is an error (to alert every time to fix) or just an invalid request (to alert for anomalies).

**To Reproduce**

1. Set up monitoring for a project with GCS
2. Have code call to GCS bucket to check for existence on a file that doesn't exist (GCS will return 404)
3. Pull up dashboard (or alerts)
4. See that it is reported as an error

**Environment (please complete the following information)**
- OS: Linux
- Python version: 3.8
- Framework and version [e.g. Django 2.1]: Django 3.8
- APM Server version: 7.15
- Agent version: 6.14.0

**Additional context**
- `requirements.txt`:

Click to expand

```
google-cloud-storage==1.42.0
```


**Observations**
It seems to be handled differently on different parts of code:
* in [traces.py](https://github.com/elastic/apm-agent-python/blob/main/elasticapm/traces.py#L1189) it is looking for 5xx's to error
* in [instrumentation](https://github.com/elastic/apm-agent-python/blob/main/elasticapm/instrumentation/packages/urllib3.py#L136) it is looking for 4xx's to error

**Suggestions**
Could we have 4xx's return as invalid request or warning levels instead? We could still be able to monitor and alert for them, but differently than 5xx's

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit elasticapm/traces.py um Zeile 1189 und elasticapm/instrumentation/packages/urllib3.py um Zeile 136 und vergleiche, wie Antwortstatuscodes klassifiziert werden. Reproduziere den GCS 404-Fall und verfolge die daraus resultierende Ereignis- oder Alarmklassifizierung; abgeschlossen ist die Aufgabe, wenn erwartete 4xx-Antworten von 5xx-Fehlern unterscheidbar sind, ohne die Überwachungssichtbarkeit zu verlieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
django, google-cloud, python
Bereich
observability
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.