Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADDED] Option to include subscription details in monitoring responses #1318

Merged
merged 1 commit into from
Mar 30, 2020

Conversation

matthiashanel
Copy link
Contributor

added sub=detail option to routez/connz.
When specified will include subscriptions_list_detail instead.
I would have liked to change the type of subscriptions_list from []string to []interface{} and not have subscriptions_list_detail, but that is part of the interface used by embedded server.

Applies to routez and connz and closed connections.
with detail

{
  "server_id": "NDVNBYWHR7OZFDDVLNAHFK5PLRTBLENHSNMRV5WBSFAF6W3E67PCLC6A",
  "now": "2020-03-20T17:00:12.399586-04:00",
  "num_connections": 1,
  "total": 1,
  "offset": 0,
  "limit": 1024,
  "connections": [
    {
      "cid": 2,
      "ip": "127.0.0.1",
      "port": 49722,
      "start": "2020-03-20T16:59:57.558987-04:00",
      "last_activity": "2020-03-20T17:00:05.690868-04:00",
      "uptime": "14s",
      "idle": "6s",
      "pending_bytes": 0,
      "in_msgs": 0,
      "out_msgs": 0,
      "in_bytes": 0,
      "out_bytes": 0,
      "subscriptions": 1,
      "subscriptions_list_detail": [
        {
          "subject": "foo",
          "qgroup": "queue",
          "sid": "5",
          "msgs": 0,
          "cid": 2
        }
      ]
    }
  ]
}%

without

curl "http://localhost:8080/connz?subs=1"
{
  "server_id": "NDVNBYWHR7OZFDDVLNAHFK5PLRTBLENHSNMRV5WBSFAF6W3E67PCLC6A",
  "now": "2020-03-20T17:00:08.310969-04:00",
  "num_connections": 1,
  "total": 1,
  "offset": 0,
  "limit": 1024,
  "connections": [
    {
      "cid": 2,
      "ip": "127.0.0.1",
      "port": 49722,
      "start": "2020-03-20T16:59:57.558987-04:00",
      "last_activity": "2020-03-20T17:00:05.690868-04:00",
      "uptime": "10s",
      "idle": "2s",
      "pending_bytes": 0,
      "in_msgs": 0,
      "out_msgs": 0,
      "in_bytes": 0,
      "out_bytes": 0,
      "subscriptions": 1,
      "subscriptions_list": [
        "foo"
      ]
    }
  ]
}%  

Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

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

No need for public function and maybe some refactor to reduce duplicated code.

AuthorizedUser string `json:"authorized_user,omitempty"`
Account string `json:"account,omitempty"`
Subs []string `json:"subscriptions_list,omitempty"`
SubsDetail []SubDetail `json:"subscriptions_list_detail,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I would have made it a []*SubDetail in case we ever need to sort those (since []SubDetail would force move of SubDetail struct inside the array), but I see that we also use []SubDetail in subz, so...

server/monitor.go Outdated Show resolved Hide resolved
server/monitor.go Show resolved Hide resolved
server/monitor.go Outdated Show resolved Hide resolved
server/monitor.go Outdated Show resolved Hide resolved
server/monitor.go Outdated Show resolved Hide resolved
server/monitor.go Outdated Show resolved Hide resolved
Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

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

Comment about the copy of routez option was not addressed?

server/monitor.go Outdated Show resolved Hide resolved
…ses.

Applies to routez and connz and closed connections.
Enable by specifying subs=detail

Signed-off-by: Matthias Hanel <mh@synadia.com>
Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor Author

@matthiashanel matthiashanel left a comment

Choose a reason for hiding this comment

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

After discussion, changed the logic to avoid the copy alltogether.

server/monitor.go Show resolved Hide resolved
Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

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

LGTM

@kozlovic kozlovic changed the title Adding an option to include subscription details in monitoring responses [ADDED] Option to include subscription details in monitoring responses Mar 30, 2020
@kozlovic kozlovic merged commit e63fc5f into master Mar 30, 2020
@kozlovic kozlovic deleted the monitoring branch March 30, 2020 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants