diff --git a/src/sleepy/dog.clj b/src/sleepy/dog.clj index 9f62d18..1cf18e9 100644 --- a/src/sleepy/dog.clj +++ b/src/sleepy/dog.clj @@ -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 [] diff --git a/src/sleepy/internal.clj b/src/sleepy/internal.clj index f7276c2..f59b15b 100644 --- a/src/sleepy/internal.clj +++ b/src/sleepy/internal.clj @@ -47,9 +47,16 @@ (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 @@ -57,6 +64,9 @@ (tag-span! [span k v] (add-tag! v span k)) + (root-of + [span] + (.getLocalRootSpan span)) (report-error! [span ex] (.setError span true) @@ -66,6 +76,8 @@ NoopSpan (tag-span! [_ _ _]) + (root-of + [_]) (report-error! [_ _]))