Skip to content
Open
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
12 changes: 9 additions & 3 deletions pkg/sip/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ func (c *Client) newCall(ctx context.Context, conf *config.Config, log logger.Lo
jitterBuf: jitterBuf,
projectID: projectID,
}
call.log = call.log.WithValues("jitterBuf", call.jitterBuf)
// Generate SIP call ID early so it's available for all logging
toUri := CreateURIFromUserAndAddress(sipConf.to, sipConf.address, tr)
toHeader := &sip.ToHeader{Address: *toUri.GetURI()}
Comment on lines +112 to +113
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not against it, but it's a bit unfortunate that it now requires building these two objects outside of the constructor function.

sipCallID := guid.HashedID(fmt.Sprintf("%s-%s", string(id), toHeader.Address.String()))
call.log = call.log.WithValues("jitterBuf", call.jitterBuf, "sipCallID", sipCallID)

call.cc = c.newOutbound(log, id, URI{
User: sipConf.from,
Host: sipConf.host,
Expand All @@ -126,6 +131,9 @@ func (c *Client) newCall(ctx context.Context, conf *config.Config, log logger.Lo
return AttrsToHeaders(r.LocalParticipant.Attributes(), c.sipConf.attrsToHeaders, headers)
})

// Set the SIP call ID in the sipOutbound struct
call.cc.callID = sipCallID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should pass it to newOutbound then.


call.mon = c.mon.NewCall(stats.Outbound, sipConf.host, sipConf.address)
var err error

Expand Down Expand Up @@ -751,8 +759,6 @@ func (c *sipOutbound) Invite(ctx context.Context, to URI, user, pass string, hea
toHeader := &sip.ToHeader{Address: *to.GetURI()}

dest := to.GetDest()
c.callID = guid.HashedID(fmt.Sprintf("%s-%s", string(c.id), toHeader.Address.String()))
c.log = c.log.WithValues("sipCallID", c.callID)

var (
sipHeaders Headers
Expand Down
Loading