fix: sender and recipient.id

This commit is contained in:
Manendra Pal Singh
2026-02-23 23:16:49 +05:30
parent ab89102711
commit c2f3dbce2c

View File

@@ -8,6 +8,7 @@ import (
"net/http" "net/http"
"net/http/httputil" "net/http/httputil"
"strconv" "strconv"
"strings"
"time" "time"
"github.com/beckn-one/beckn-onix/pkg/log" "github.com/beckn-one/beckn-onix/pkg/log"
@@ -376,18 +377,22 @@ func (h *stdHandler) initSteps(ctx context.Context, mgr PluginManager, cfg *Conf
} }
func setBecknAttr(span trace.Span, r *http.Request, h *stdHandler) { func setBecknAttr(span trace.Span, r *http.Request, h *stdHandler) {
recipientID := h.SubscriberID selfID := h.SubscriberID
remoteID := ""
if v, ok := r.Context().Value(model.ContextKeySubscriberID).(string); ok {
recipientID = v
}
senderID := ""
if v, ok := r.Context().Value(model.ContextKeyCallerID).(string); ok { if v, ok := r.Context().Value(model.ContextKeyCallerID).(string); ok {
senderID = v remoteID = v
} }
var senderID, receiverID string
if strings.Contains(h.moduleName, "Caller") {
senderID = selfID
receiverID = remoteID
} else {
senderID = remoteID
receiverID = selfID
}
attrs := []attribute.KeyValue{ attrs := []attribute.KeyValue{
attribute.String("recipient.id", recipientID), attribute.String("recipient.id", receiverID),
attribute.String("sender.id", senderID), attribute.String("sender.id", senderID),
attribute.String("span_uuid", uuid.New().String()), attribute.String("span_uuid", uuid.New().String()),
attribute.String("http.request.method", r.Method), attribute.String("http.request.method", r.Method),