Skip to content

Commit 4a1d0da

Browse files
authored
Fix Solana healthcheck (#10)
1 parent 892f1d6 commit 4a1d0da

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/collectors/solana.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def is_connected(self) -> bool:
2828
response = requests.get(self.health_uri, timeout=cfg.response_timeout)
2929
response.raise_for_status()
3030
except (IOError, requests.HTTPError) as err:
31-
logger.error("Health check failed for {}.".format(strip_url(self.health_uri)))
31+
logger.error("Health check failed for {}: {}".format(strip_url(self.health_uri), err))
3232
return False
3333
return response.ok
3434

src/exporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _instantiate_conflux(self):
3939

4040
def _instantiate_solana(self):
4141
for item in cfg.endpoints:
42-
logger.info("Initializing solana node {}".format(strip_url(item['ws_url'])))
42+
logger.info("Initializing solana node {}".format(strip_url(item['https_url'])))
4343
self.collectors.append(solana_collector(item['ws_url'], item['https_url'], item['provider']))
4444
self.labels = self.collectors[0].labels
4545

src/helpers.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import urllib.parse
22

33
def strip_url(url):
4-
return urllib.parse.urlparse(url).netloc
4+
"""This function strips the url from all parameters, usernames and passwords.
5+
It is used to safely log errors without exposing keys and authentication parameters."""
6+
return urllib.parse.urlparse(url).hostname
57

6-
7-
def url_join(url, path):
8-
return urllib.parse.urljoin(url, path)
8+
def url_join(url, target_path):
9+
"""Function takes url, and returns url + target path. This function also preserves
10+
all of the url parameters if they are present.
11+
This is important since different RPCs use different auth mechanisms (path or parameter)"""
12+
scheme, netloc, path, params, query, fragment = urllib.parse.urlparse(url)
13+
path = path + target_path
14+
path = path.replace('//', '/')
15+
return urllib.parse.urlunparse((scheme, netloc, path, params, query, fragment))

0 commit comments

Comments
 (0)