Adding "hooks" for logging/tracing/...
- Linguagem predominante
- Go
- Estrelas
- 39
- Forks
- 47
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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?
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Leia a issue vinculada sobre logging e as assinaturas propostas de PreRequestHook e PostRequestHook. Inspecione newRequest e as funções de cliente geradas para entender onde os hooks e o contexto opcional seriam aplicados. A tarefa estará concluída quando o projeto tiver um design acordado para hooks de requisição e propagação de contexto, em vez de apenas uma proposta geral.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- go
- Domínio
- api
- Tipo de issue
- Funcionalidade
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Status de atividade
- Estagnada
- Clareza
- Precisa de esclarecimento
- Facilidade para iniciantes
- 20/100