diff --git a/pkg/sip/outbound.go b/pkg/sip/outbound.go index c0f946a..4d9e166 100644 --- a/pkg/sip/outbound.go +++ b/pkg/sip/outbound.go @@ -423,7 +423,7 @@ func (c *outboundCall) sipSignal(ctx context.Context) error { // TODO: should we retry? maybe new offer will work var e *ErrorStatus if errors.As(err, &e) { - c.mon.InviteError(fmt.Sprintf("status-%d", e.StatusCode)) + c.mon.InviteError(statusName(e.StatusCode)) } else { c.mon.InviteError("other") } diff --git a/pkg/sip/protocol.go b/pkg/sip/protocol.go index 66b0a5f..902d601 100644 --- a/pkg/sip/protocol.go +++ b/pkg/sip/protocol.go @@ -40,6 +40,70 @@ var ( referIdRegexp = regexp.MustCompile(`^refer(;id=(\d+))?$`) ) +// TODO: Add String method to sipgo.StatusCode +var statusNamesMap = map[int]string{ + 100: "Trying", + 180: "Ringing", + 181: "CallIsForwarded", + 182: "Queued", + 183: "SessionInProgress", + + 200: "OK", + 202: "Accepted", + + 301: "MovedPermanently", + 302: "MovedTemporarily", + 305: "UseProxy", + + 400: "BadRequest", + 401: "Unauthorized", + 402: "PaymentRequired", + 403: "Forbidden", + 404: "NotFound", + 405: "MethodNotAllowed", + 406: "NotAcceptable", + 407: "ProxyAuthRequired", + 408: "RequestTimeout", + 409: "Conflict", + 410: "Gone", + 413: "RequestEntityTooLarge", + 414: "RequestURITooLong", + 415: "UnsupportedMediaType", + 416: "RequestedRangeNotSatisfiable", + 420: "BadExtension", + 421: "ExtensionRequired", + 423: "IntervalToBrief", + 480: "TemporarilyUnavailable", + 481: "CallTransactionDoesNotExists", + 482: "LoopDetected", + 483: "TooManyHops", + 484: "AddressIncomplete", + 485: "Ambiguous", + 486: "BusyHere", + 487: "RequestTerminated", + 488: "NotAcceptableHere", + + 500: "InternalServerError", + 501: "NotImplemented", + 502: "BadGateway", + 503: "ServiceUnavailable", + 504: "GatewayTimeout", + 505: "VersionNotSupported", + 513: "MessageTooLarge", + + 600: "GlobalBusyEverywhere", + 603: "GlobalDecline", + 604: "GlobalDoesNotExistAnywhere", + 606: "GlobalNotAcceptable", +} + +func statusName(status int) string { + if name := statusNamesMap[status]; name != "" { + return fmt.Sprintf("%d-%s", status, name) + } + return fmt.Sprintf("status-%d", status) +} + type ErrorStatus struct { StatusCode int Message string diff --git a/pkg/stats/monitor.go b/pkg/stats/monitor.go index 431cc69..2334241 100644 --- a/pkg/stats/monitor.go +++ b/pkg/stats/monitor.go @@ -31,7 +31,7 @@ import ( var ( // durBucketsOp lists histogram buckets for relatively short operations like SIP INVITE. durBucketsOp = []float64{ - 0.1, 0.5, 1, 5, 10, 30, 60, 3 * 60, + 0.1, 0.5, 1, 2.5, 5, 10, 20, 30, 60, 3 * 60, } // durBucketsLong lists histogram buckets for long operations like call/session durations. durBucketsLong = []float64{ @@ -46,9 +46,9 @@ type CallDir bool func (d CallDir) String() string { if d == Inbound { - return "inbound" + return "in" } - return "outbound" + return "out" } const (