apache / apache/cloudstack-go

Adding "hooks" for logging/tracing/...

Abierto
#3 1 comentario 2 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Go
Estrellas
39
Forks
47
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Read the linked issue about logging and the proposed PreRequestHook and PostRequestHook signatures. Inspect newRequest and the generated client functions to understand where the hooks and optional context would apply. Done means the project has an agreed design for request hooks and context propagation, rather than only a general proposal.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
go
Área
api
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
20/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.