-
Notifications
You must be signed in to change notification settings - Fork 31
feat(server): observability improvements and startup/retry fixes #159
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
Changes from all commits
b5ec327
474a05b
90a4d40
fa14a12
56dfed9
b907b46
b7556a3
afcd4ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| import logging | ||
|
|
||
| _log = logging.getLogger(__name__) | ||
|
|
||
| try: | ||
| from prometheus_client import CONTENT_TYPE_LATEST, CollectorRegistry, Counter, Gauge, Histogram, generate_latest | ||
| from twisted.web.resource import Resource | ||
| from twisted.web.server import Site | ||
|
|
||
| _registry = CollectorRegistry(auto_describe=True) | ||
|
|
||
| connections_active = Gauge( | ||
| "recceiver_connections_active", | ||
| "Active uploading IOC connections", | ||
| registry=_registry, | ||
| ) | ||
| connections_waiting = Gauge( | ||
| "recceiver_connections_waiting", | ||
| "IOC connections waiting for an upload slot", | ||
| registry=_registry, | ||
| ) | ||
| connections_limit = Gauge( | ||
| "recceiver_connections_limit", | ||
| "Maximum concurrent active connections (maxActive)", | ||
| registry=_registry, | ||
| ) | ||
| known_iocs = Gauge( | ||
| "recceiver_known_iocs", | ||
| "IOCs with channels currently registered in CF", | ||
| registry=_registry, | ||
| ) | ||
| tracked_channels = Gauge( | ||
| "recceiver_tracked_channels", | ||
| "Unique channel names tracked by the CF processor", | ||
| registry=_registry, | ||
| ) | ||
| cf_commits_total = Counter( | ||
| "recceiver_cf_commits_total", | ||
| "CF push attempts by result", | ||
| ["result"], | ||
| registry=_registry, | ||
| ) | ||
| cf_commit_duration_seconds = Histogram( | ||
| "recceiver_cf_commit_duration_seconds", | ||
| "CF push duration in seconds", | ||
| buckets=[0.1, 0.5, 1.0, 2.5, 5.0, 10.0, 30.0, 60.0], | ||
| registry=_registry, | ||
| ) | ||
|
|
||
|
jacomago marked this conversation as resolved.
|
||
| class _MetricsResource(Resource): | ||
| isLeaf = True | ||
|
|
||
| def render_GET(self, request): | ||
| request.setHeader(b"Content-Type", CONTENT_TYPE_LATEST.encode()) | ||
| return generate_latest(_registry) | ||
|
|
||
| def make_site(): | ||
| return Site(_MetricsResource()) | ||
|
|
||
| available = True | ||
|
|
||
| except ImportError: | ||
| available = False | ||
|
|
||
| class _Noop: | ||
| def set(self, v=None): | ||
| pass # no-op: prometheus_client not installed | ||
|
|
||
| def inc(self, v=1): | ||
| pass # no-op: prometheus_client not installed | ||
|
|
||
| def labels(self, **_kw): | ||
| return self | ||
|
|
||
| def observe(self, v): | ||
| pass # no-op: prometheus_client not installed | ||
|
|
||
| connections_active = _Noop() | ||
| connections_waiting = _Noop() | ||
| connections_limit = _Noop() | ||
| known_iocs = _Noop() | ||
| tracked_channels = _Noop() | ||
| cf_commits_total = _Noop() | ||
| cf_commit_duration_seconds = _Noop() | ||
|
|
||
| def make_site(): | ||
| raise RuntimeError("prometheus_client is not installed") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -278,6 +278,7 @@ def flush(self): | |
| return | ||
|
|
||
| transaction, self.transaction = self.transaction, Transaction(self.ep, id(self)) | ||
| self.transaction.client_infos = dict(transaction.client_infos) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this really work with an IOC?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix is only applicable for large IOCs, with more than 5k (trlimit) records. The copy to subsequent transaction applies also to smaller IOCs but does not matter for those as they will flush all (incl client_infos) on first transaction. But for >5k, the subsequent transaction starts with empty client infos. Keep in mind that reccaster proto is ordered: (all) AddInfo goes before AddRecord. |
||
| self.dirty = False | ||
|
|
||
| def commit(_ignored): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.