Skip to content

Commit 05722a6

Browse files
committed
Fix numeric labels
It looks like Elastic APM can store numeric labels after all. It just stores them under `numeric_labels` instead of `labels`.
1 parent eafd09e commit 05722a6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/clojure_elastic_apm/core.clj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
(.setLabel span-or-tx (name k) (str v)))
1515

1616
(defn set-label [^Span span-or-tx k v]
17-
(.setLabel span-or-tx (name k) (str v)))
17+
(cond
18+
(number? v) (.setLabel span-or-tx (name k) ^Number v)
19+
(boolean? v) (.setLabel span-or-tx (name k) ^boolean v)
20+
:else (.setLabel span-or-tx (name k) (str v))))
1821

1922
(defn set-name [^Span span-or-tx name]
2023
(.setName span-or-tx name))

test/clojure_elastic_apm/core_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
(let [tx-details (es-find-first-document (str "(processor.event:transaction%20AND%20transaction.id:" @transaction-id ")"))]
3232
(is (= "TestTransaction" (get-in tx-details [:transaction :name])))
3333
(is (= "1" (get-in tx-details [:labels :t1])))
34-
(is (= "2" (get-in tx-details [:labels :t2])))
34+
(is (= 2 (get-in tx-details [:numeric_labels :t2])))
3535
(is (= "true" (get-in tx-details [:labels :t3])))
3636
(is (= "Label 4" (get-in tx-details [:labels :t4])))
3737
(is (= "test-result" (get-in tx-details [:transaction :result])))

0 commit comments

Comments
 (0)