Adding "hooks" for logging/tracing/...
- Langage dominant
- Go
- Étoiles
- 39
- Forks
- 47
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
This issue is a follow-up of https://github.com/xanzy/go-cloudstack/issues/120.
That issue was opened by @synergiator with the title "How to change the log level for go-cloudstack module?" and asked for a way to have more detailed logging.
I proposed a broader solution:
> I also think that adding logging would be useful, but as there's never consensus on what to log or which logging library to use (log, zap, logrus, etc.), what would you think of adding some "hooks", optional functions that would be called before and after the actual http request? The user of CloudStack client could then provide its own logging or tracing logic.
>
> IMHO, the best would be to also add an **optional** context.Context to all API functions, in order to make it possible to do contextual tracing for example.
>
> A possible signature for these hooks could be:
>
> ```go
> // PreRequestHook would be called in newRequest, just before the HTTP request call.
> type PreRequestHook func(ctx context.Context, api string, params url.Values)
>
> // PostRequestHook would be called in each generated client function,
> // just after the Unmarshal step.
> type PostRequestHook func(ctx context.Context, rawResp json.RawMessage, err error, resp interface{})
> ```
>
> I can contribute and submit a PR if you are ok with that.
Any thoughts?
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Lisez l’issue liée concernant la journalisation et les signatures proposées de PreRequestHook et PostRequestHook. Inspectez newRequest et les fonctions client générées pour comprendre où s’appliqueraient les hooks et le contexte optionnel. La tâche est terminée lorsque le projet dispose d’une conception approuvée pour les hooks de requête et la propagation du contexte, plutôt que d’une simple proposition générale.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- go
- Domaine
- api
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 20/100