SaaSus API リクエストへの trace_id 自動引継#12
Open
takahujikeita wants to merge 2 commits into
Open
Conversation
yutakahashi114
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
フロントエンドから送信される
X-Saasus-Trace-Idヘッダーを受け取り、SaaSus SDK 経由の API リクエストに自動伝播する仕組みを追加しました。これにより、フロントエンドから SaaSus API までのリクエストを横断的にトレースできるようになります。変更内容
main.goCORS 設定:
AllowHeadersにX-Saasus-Trace-Idを追加し、フロントエンドからのヘッダー送信を許可ミドルウェア追加:
extractTraceIdEcho()をグローバルミドルウェアとして登録extractTraceIdEcho()関数の新規実装: リクエストヘッダーからX-Saasus-Trace-Idを取得し、ctxlib.XSaaSusTraceIdKeyとしてcontext.Contextに格納。SDK が API 呼び出し時にコンテキストから trace_id を自動的に読み取り、SaaSus API へ伝播する動作フロー
Client → [X-Saasus-Trace-Id header] → Echo middleware → context.Context に格納 → SaaSus SDK → SaaSus API備考
既存の
extractRefererEcho()と同じパターンで実装X-Saasus-Trace-Idヘッダーが未指定の場合はスキップされ、既存動作に影響なしSDK バージョン: v1.10.19