Skip to content

Commit

Permalink
Aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
valerauko committed Nov 20, 2023
1 parent 77eb84e commit 25df413
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/sleepy/dog.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@
(set! *warn-on-reflection* true)
(set! *unchecked-math* :warn-on-boxed)

;; just aliases

(defn active-span!
[]
(let [tracer (GlobalTracer/get)]
(when *continuation* (.activate *continuation*))
(.activeSpan tracer)))
(datadog/active-span!))

(defn set-resource!
[^String reg-name]
(let [span (active-span!)]
(datadog/tag-span! span DDTags/RESOURCE_NAME reg-name)))
[reg-name]
(datadog/set-resource! reg-name))

(defn report-error!
[span ex]
(datadog/report-error! span ex))

(defn root-of
[span]
(datadog/root-of span))

(defn http-headers
[]
Expand Down
12 changes: 12 additions & 0 deletions src/sleepy/internal.clj
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,26 @@
(add-tag!
[_ _ _]))

(defn active-span!
[]
(let [tracer (GlobalTracer/get)]
(when *continuation* (.activate *continuation*))
(.activeSpan tracer)))

;; agentが無効だとNoopSpanになるので何もしない実装も準備
(defprotocol Span
(tag-span! [span k v])
(root-of [span])
(report-error! [span ex]))

(extend-protocol Span
MutableSpan
(tag-span!
[span k v]
(add-tag! v span k))
(root-of
[span]
(.getLocalRootSpan span))
(report-error!
[span ex]
(.setError span true)
Expand All @@ -66,6 +76,8 @@
NoopSpan
(tag-span!
[_ _ _])
(root-of
[_])
(report-error!
[_ _]))

Expand Down

0 comments on commit 25df413

Please # to comment.