Consider using warnings over logging.warning for important messages
@NathanielRN ci sta già lavorando.
Dal 5/7/2022.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Hello X-Ray team!
I've recently discovered that tracing annotations with - or spaces in the name are silently dropped at the SDK level. When looking for a possible cause, I've found out X-Ray documentation calls this out in the API Segment Document schema page.
It would've been quicker to spot this issue if X-Ray SDK were to use the standard library Warnings package. This allows library maintainers to warn their users and give them a chance to suppress certain filters at will.
What's the difference between logging.warning vs warnings.warn?
For Logging, it's a good practice for library owners to use a NullHandler. This means any logging message produced by a library will be silently dropped, unless the consumer explicitly enables the library logging in question (or sets a Root logger).
In contrast, warnings.warn will notify consumers that something it's worth investigating. They also support categories of warnings to allow complex libraries to have multiple warnings, so their consumers can explicitly disable a subset of warnings without having to know every possible message to filter out.
Here's an example in Lambda Powertools for Python where we warn customers if they have no metrics to be flushed. This will happen regardless of how they configure their loggers. If they're intentional about having no user-defined metrics, they suppress this warning altogether with warnings.filterwarnings("ignore", "No metrics to publish*").
Hopefully this will help strike a balance between not interrupting customers at runtime while warning them they might be losing important tracing information.
Thank you!
- Lingua principale
- Python
- Stelle
- 339
- Fork
- 147
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aws/aws-xray-sdk-python
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
aws/aws-xray-sdk-python#490 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 1/100
aws/aws-xray-sdk-python#460 ·
-
Next release Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
aws/aws-xray-sdk-python#457 · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
aws/aws-xray-sdk-python#453 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
aws/aws-xray-sdk-python#452 · 1 reazione ·
Tutte le issue di aws/aws-xray-sdk-python
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
stephrobert/dsoxlab#238 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
sublimehq/package_control#1780 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
nwg-piotr/nwg-displays#145 ·