Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Consider using warnings over logging.warning for important messages

Aperta
#347 4 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aws/aws-xray-sdk-python

Tutte le issue di aws/aws-xray-sdk-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.