Skip to content

Go proc metrics collector#55

Open
talonx wants to merge 7 commits into
ApptuitAI:apptuit-masterfrom
talonx:apptuit-master
Open

Go proc metrics collector#55
talonx wants to merge 7 commits into
ApptuitAI:apptuit-masterfrom
talonx:apptuit-master

Conversation

@talonx

@talonx talonx commented May 23, 2018

Copy link
Copy Markdown

Fix for #49

Comment thread collectors/0/goproc.py Outdated
from __future__ import print_function
import traceback

import requests

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Will this require a dependency on python-requests.deb/rpm?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

As discussed, it's already part of the installer dependencies.

Comment thread collectors/0/goproc.py Outdated
from collectors.lib import utils

COLLECTION_INTERVAL_SECONDS = 15
SKIP_MEM_KEYS = ['PauseNs', 'PauseEnd', 'BySize']

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can we move these to the yml?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The collector decides what metrics it will emit, this should not be user configurable.

Comment thread collectors/0/goproc.py Outdated
@@ -0,0 +1,64 @@
#!/usr/bin/env python

from __future__ import print_function

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How come other collectors did not have this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

Comment thread collectors/0/goproc.py Outdated


def main(argv):
expvar_url = goprocconf.get_expvar_url()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

First line of main is usually utils.drop_privileges()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks, added

Comment thread collectors/0/goproc.py Outdated
except:
utils.err("Unexpected error: %s" % sys.exc_info()[0])
traceback.print_exc()
exit(13)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Instead of exiting anytime we get a connection error, I suggest we change the workflow to:

  1. Before while(true): Try connecting to the endpoint if it errors out then exit - This is the scenario where the URL in the yml is not on this server
  2. In the while(true): On connection error, we log the error and continue the loop - This is the scenario where the URL is correct (we checked before the loop), but there is a transient error

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

Comment thread collectors/0/goproc.py Outdated
print("memstats.%s %s %s" % (mk, ts, mv))
elif k != 'cmdline':
_print_nested_metrics(k, v, ts)
sys.stdout.flush()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Convention has been to flush once at the end of each loop, please move it just before the sleep

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

Comment thread conf/goproc.yml Outdated
collector:
name: goproc
config:
expvar_url: http://localhost:3001/debug/vars No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please change the path to collector.config.endpoints.url so thatwe could support multiple URL scraping in future

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done. It's a list of dictionaries now in the YAML but we just parse the first element in the list.

Comment thread collectors/0/goproc.py Outdated
import sys
import time

from collectors.etc import goprocconf

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We are trying to move away from py based conf to yml based conf. Could you inline the yml reading in this collector?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

@rshivane

Copy link
Copy Markdown

Could you rename the collector to go_expvar.py?

Comment thread collectors/0/go_expvar.py
pause_sum += pause_ns[index]
gc_count += 1
index = index - 1
_print_metric('memstats.PauseNs.sum', ts_seconds, pause_sum)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The name as per Metrics 2.0 convention would be memstats.Pause.total.nanos

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