Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
6 changes: 6 additions & 0 deletions handlers/callApi.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ func CallApiJSON[Req any, Resp any](
webFramework.AddLog(w, CallApiLogEntry, slog.Any(method, param))

param.BodyType = libCallApi.JSON
if param.Context == nil {
param.Context = w.Ctx // Set context for distributed tracing if not already set
}
resp, err := libCallApi.RemoteCall(param)
if err != nil {
webFramework.AddLog(w, CallApiLogEntry, slog.Any(fmt.Sprintf("%s-error", method), err))
Expand All @@ -113,6 +116,9 @@ func CallApiForm[Req any, Resp any](
webFramework.AddLog(w, CallApiLogEntry, slog.Any(method, param))

param.BodyType = libCallApi.Form
if param.Context == nil {
param.Context = w.Ctx // Set context for distributed tracing if not already set
}
resp, err := libCallApi.RemoteCall(param)
if err != nil {
webFramework.AddLog(w, CallApiLogEntry, slog.Any(fmt.Sprintf("%s-error", method), err))
Expand Down
2 changes: 2 additions & 0 deletions handlers/consumeHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (c CallArgs[Req, Resp]) Handler(req HandlerRequest[Req, Resp]) (Resp, error
Api: *req.Core.Params().GetRemoteApi(c.Api),
Method: c.Method,
Path: finalPath,
Context: req.W.Ctx, // Pass context for distributed tracing
},
)
if err != nil {
Expand Down Expand Up @@ -224,6 +225,7 @@ func (h *ConsumeHandlerType[Req, Resp]) Handler(req HandlerRequest[Req, Resp]) (
EnableLog: false,
Headers: headersMap,
Builder: req.Builder,
Context: req.W.Ctx, // Pass context for distributed tracing
})
if errCall != nil {
return req.Response, errCall
Expand Down
2 changes: 2 additions & 0 deletions libCallApi/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type CallParamData struct {
ValidateTls bool
EnableLog bool
JsonBody any
Context context.Context `json:"-"` // Context for distributed tracing and request cancellation
}

func (r CallParamData) LogValue() slog.Value {
Expand Down Expand Up @@ -99,6 +100,7 @@ func Call[RespType any](param CallParam) CallResult[RespType] {
EnableLog: param.EnableLog,
Timeout: param.Timeout,
Req: param.JsonBody,
Context: param.Context, // Pass context for distributed tracing
httpClient: param.HttpClient,
}
resp, wsResp, callResp, err := ConsumeRest(callData)
Expand Down
Loading