-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to sentry-clj. Getting rid of raven lib.
- Loading branch information
Arthur Aliiev
authored and
Arthur Aliiev
committed
Mar 7, 2024
1 parent
e442ea2
commit f6bc78b
Showing
5 changed files
with
85 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
(ns spootnik.reporter.sentry | ||
(:require | ||
[clojure.string :as str] | ||
[clojure.java.shell :as sh])) | ||
|
||
(def hostname-refresh-interval | ||
"How often to allow reading /etc/hostname, in seconds." | ||
60) | ||
|
||
(defn get-hostname | ||
"Get the current hostname by shelling out to 'hostname'" | ||
[] | ||
(or | ||
(try | ||
(let [{:keys [exit out]} (sh/sh "hostname")] | ||
(when (= exit 0) | ||
(str/trim out))) | ||
(catch Exception _)) | ||
"<unknown>")) | ||
|
||
(defn hostname | ||
"Fetches the hostname by shelling to 'hostname', whenever the given age | ||
is stale enough. If the given age is recent, as defined by | ||
hostname-refresh-interval, returns age and val instead." | ||
[[age val]] | ||
(if (and val (<= (* 1000 hostname-refresh-interval) | ||
(- (System/currentTimeMillis) age))) | ||
[age val] | ||
[(System/currentTimeMillis) (get-hostname)])) | ||
|
||
(let [cache (atom [nil nil])] | ||
(defn localhost | ||
"Returns the local host name." | ||
[] | ||
(if (re-find #"^Windows" (System/getProperty "os.name")) | ||
(or (System/getenv "COMPUTERNAME") "localhost") | ||
(or (System/getenv "HOSTNAME") | ||
(second (swap! cache hostname)))))) |