Skip to content

Commit

Permalink
don't bother publishing the traces that won't be complete
Browse files Browse the repository at this point in the history
  • Loading branch information
dwwoelfel committed Jan 14, 2025
1 parent 758c263 commit 903dd90
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion server/src/instant/flags.clj
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
(contains? (:rate-limited-apps (query-result))
app-id))

(defn e2e-encourage-honeycomb-publish? [^Long tx-id]
(defn e2e-should-honeycomb-publish? [^Long tx-id]
(zero? (mod tx-id (or (get-in (query-result)
[:e2e-logging :invalidator-every-n])
10000))))
33 changes: 17 additions & 16 deletions server/src/instant/util/e2e_tracer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,10 @@

(def context-field ^Field (get-field SdkSpan "context"))

(defn encourage-publish-attrs
"Attrs that will make honeycomb more likely to skip sampling on this event
to give us a better chance of seeing all spans in the trace."
[^Long tx-id]
(when (flags/e2e-encourage-honeycomb-publish? tx-id)
{:entropy tx-id}))

(defn make-invalidator-tracking-span [^Long tx-id attrs]
(let [span (binding [tracer/*span* nil] ;; make sure this is a top-level span
(tracer/new-span! {:name "e2e/invalidator/tracking-span"
:attributes (merge {:tx-id tx-id}
(encourage-publish-attrs tx-id)
attrs)}))
context (.getSpanContext ^SdkSpan span)
modified-context (SpanContext/create (tx-id->trace-id tx-id)
Expand All @@ -60,14 +52,23 @@
span))

(defn start-invalidator-tracking! [{:keys [^Long tx-id app-id]}]
(tracer/end-span! (make-invalidator-tracking-span tx-id {:app-id app-id})))
(when (flags/e2e-should-honeycomb-publish? tx-id)
(let [span (make-invalidator-tracking-span tx-id {:app-id app-id
;; encourage honeycomb not
;; to skip this span
:entropy tx-id})]
(tracer/end-span! span))))

(defn invalidator-tracking-step! [{:keys [^Long tx-id name] :as span-opts}]

Check warning on line 62 in server/src/instant/util/e2e_tracer.clj

View workflow job for this annotation

GitHub Actions / lint

unused binding name
;; Create a new span with a stable trace-id and span-id for the parent
(binding [tracer/*span* (make-invalidator-tracking-span tx-id nil)]
(tracer/record-info! (-> span-opts
(update :name (fn [s] (format "e2e/invalidator/%s" s)))
(update :attributes (fn [a]
(merge a
(encourage-publish-attrs tx-id)
{:tx-id tx-id})))))))
(when (flags/e2e-should-honeycomb-publish? tx-id)
(binding [tracer/*span* (make-invalidator-tracking-span tx-id nil)]
(tracer/record-info!
(-> span-opts
(update :name (fn [s] (format "e2e/invalidator/%s" s)))
(update :attributes (fn [a]
(merge a
{:tx-id tx-id
;; encourage honeycomb not
;; to skip this span
:entropy tx-id}))))))))

0 comments on commit 903dd90

Please sign in to comment.