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

stats - add queues: {name: size} info on /stat #197

Merged
merged 3 commits into from
Jan 16, 2019

Conversation

thapakazi
Copy link
Contributor

@thapakazi thapakazi commented Jan 10, 2019

This PR is for queue info addition on /stats endpoint.

Motivation

Faktory was missing the json stats endpoint about queues like in sidekiq.

Edit Jan 11: queues map is moved into /stats inside faktory.queues

$ curl -s http://localhost:7420/stats | jq .faktory.queues
{
  "app0": 87,
  "app1": 82,
  "app2": 73,
  "app3": 81,
  "app4": 76,
  "app5": 75,
  "app6": 75,
  "app7": 78,
  "app8": 71,
  "app9": 63,
  "default": 0
}

Remarks
Not sure if I should write test for this :neckbeard: or change other files. The existing test are passing as usual 😁
Added test too :)

@mperham
Copy link
Collaborator

mperham commented Jan 10, 2019

Perfect, thank you for adding a test. 👍

server/server.go Outdated
func (s *Server) CurrentQueueState() (map[string]interface{}, error) {

queues := make(map[string]interface{})
s.Store().EachQueue(func(q storage.Queue) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rather you push this logic down into the Handler and not create a public API for it here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In other words, move this code into statsQueueHandler.

@mperham
Copy link
Collaborator

mperham commented Jan 10, 2019

I would instead suggest that you add these elements to server.CurrentState(), which is already does all of the hard work. I would add a new queues hash with name: size pairs within. WDYT?

@thapakazi
Copy link
Contributor Author

thapakazi commented Jan 11, 2019

Yeah sure 👍 one stat to get it all. I was just following up with that of sidekiq.
Will push new changes accordingly. Thanks

@thapakazi
Copy link
Contributor Author

I have pushed the changes. please review.

btw, I have placed queues inside faktory like:

I mean this
{
  faktory: {
	default_size: 0,
	queues: {
	  app0: 1674,
	  app1: 13780,
	  app2: 13451,
	  app3: 13529,
	  app4: 13602,
	  app5: 13760,
	  app6: 13915,
	  app7: 13591,
	  app8: 13588,
	  app9: 13435,
	  default: 0
	},
	tasks: {
	  Busy: {
		reaped: 0,
		size: 5
	  },
	  Dead: {
		cycles: 4,
		enqueued: 0,
		size: 0,
		wall_time_sec: 0.000277531
	  },
	  Retries: {
		cycles: 49,
		enqueued: 0,
		size: 0,
		wall_time_sec: 0.005136246
	  },
	  Scheduled: {
		cycles: 49,
		enqueued: 0,
		size: 0,
		wall_time_sec: 0.011227027
	  },
	  Workers: {
		reaped: 0,
		size: 1
	  }
	},
	total_enqueued: 124325,
	total_failures: 0,
	total_processed: 12036,
	total_queues: 11
  },
  server: {
	command_count: 296863,
	connections: 50,
	faktory_version: "0.9.5",
	uptime: 248,
	used_memory_mb: "68 MB"
  },
  server_utc_time: "03:21:20 UTC"
}
Thanks :)

@thapakazi thapakazi changed the title stats - json: get current queue length via a endpoint: /stat/queues stats - add queues: {name: size} info on /stat Jan 11, 2019
@mperham mperham merged commit 4098ac0 into contribsys:master Jan 16, 2019
mperham added a commit that referenced this pull request Jan 16, 2019
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