elastic / elastic/apm-agent-python
[EVENT OUTCOME] 4xx status codes are always reported as errors
- Lenguaje dominante
- Python
- Estrellas
- 431
- Forks
- 239
- Merge medio
- 5 d 10 h
- PR fusionados (30 d)
- 7
Descripción
**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
Guía de contribución
Línea de trabajo
Empieza por elasticapm/traces.py alrededor de la línea 1189 y elasticapm/instrumentation/packages/urllib3.py alrededor de la línea 136, comparando cómo se clasifican los códigos de estado de las respuestas. Reproduce el caso GCS 404 y rastrea la clasificación resultante del evento o la alerta; se considera terminado cuando las respuestas 4xx esperadas se pueden distinguir de los errores 5xx sin perder visibilidad de la monitorización.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- django, google-cloud, python
- Área
- observability
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100