apache / apache/cloudstack-go

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

オープン
#3 コメント 1 件 リアクション 2 件 担当者 0 名 GitHub で見る
主要言語
Go
スター
39
フォーク
47
PR マージ指標
30日以内にマージされた PR はありません

説明

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?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

ロギングと、提案されている PreRequestHook および PostRequestHook のシグネチャについて、リンク先の issue を読んでください。newRequest と生成されたクライアント関数を調査し、フックとオプションのコンテキストをどこで適用するかを理解してください。プロジェクトでリクエストフックとコンテキストの伝播について合意された設計がまとまり、単なる一般的な提案にとどまらない状態が完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
go
領域
api
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
20/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。