bitfab 0.36.6 → 0.36.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd73e07889e4f74cd94c6ca534e423a7aa95e3ce6f1e1ba306e9fe33df8de8df
4
- data.tar.gz: fb2eb3cd99066d8338f6ad03d18bc3a8de9f3955659aa66835c83066a95d3595
3
+ metadata.gz: f18189ba0b9b7a2c8cd23ee6672f927af7f9f6400457d71d86b90c13a61698e9
4
+ data.tar.gz: 61f38c9eb03166eeef759aca2914a015e92fe89247c163541c786331ed8fa26d
5
5
  SHA512:
6
- metadata.gz: b7155a3d0426c00f57668975485f2ba722bd3f0555dd897024f586290b36265f5851d49cc88242eb552421758b9d624b31e21edfb8290e68f693110e8b93cd32
7
- data.tar.gz: 87ae26a27f8864294f431b80d87f0a7f768fdb2a2f09786929dad90d61316ce7c1106e75fe9271c63260cebe3545a2e73676e94295aa281f4d24c0d101184b0f
6
+ metadata.gz: 8940e1f95426c3fa3343d48a340b3b4b2d2adec10c714b9e204ac7fdcfa348fba28b6bf4ed1820c1acd67536883a21701ccf401bc547cf2c3bd4c9b929169f6f
7
+ data.tar.gz: 88935462030c7997ab153444e327666cc0040a0baed397c19322bfd1cedff2c9ef6624b64ce227aba02cad471d6ad05c639b1cdfbdb6a69f3a6e2f1346dca395
data/lib/bitfab/otel.rb CHANGED
@@ -19,6 +19,7 @@ module Bitfab
19
19
  module Otel
20
20
  OPERATION_ATTRIBUTE = "bitfab.operation"
21
21
  PAYLOAD_ATTRIBUTE = "bitfab.payload"
22
+ CARRIER_REF_IVAR = :@bitfab_carrier_ref
22
23
  MAX_REQUEST_BYTES_ENV = "BITFAB_OTEL_MAX_REQUEST_BYTES"
23
24
  EXPORT_CONCURRENCY_ENV = "BITFAB_OTEL_EXPORT_CONCURRENCY"
24
25
  MAX_EXPORT_REQUEST_BYTES = 3_000_000
@@ -164,24 +165,6 @@ module Bitfab
164
165
  end
165
166
  end
166
167
 
167
- # Bounded, because the only thing that removes an entry is the encode
168
- # that consumes it: a span the processor drops under backpressure never
169
- # reaches encode, and its ref would otherwise sit here for the life of the
170
- # process. The queue is the ceiling on how many spans can be waiting at
171
- # once, so anything older than that is already unreachable. Evicting a
172
- # live one costs an ack, and the barrier falls back to asking the server.
173
- def record_carrier_ref(span_id, ref)
174
- ensure_process_state
175
- submission_mutex.synchronize do
176
- carrier_refs[span_id] = ref
177
- carrier_refs.shift while carrier_refs.size > MAX_QUEUE_SIZE
178
- end
179
- end
180
-
181
- def take_carrier_ref(span_id)
182
- submission_mutex.synchronize { carrier_refs.delete(span_id) }
183
- end
184
-
185
168
  def monotonic_now
186
169
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
187
170
  end
@@ -198,10 +181,8 @@ module Bitfab
198
181
  reset_state_after_fork
199
182
  end
200
183
 
201
- # Carrier refs belong to the parent's run, never the child's.
202
184
  def reset_state_after_fork
203
185
  @state_pid = Process.pid
204
- @carrier_refs = {}
205
186
  end
206
187
 
207
188
  private
@@ -217,14 +198,6 @@ module Bitfab
217
198
  def live_transports_mutex
218
199
  @live_transports_mutex ||= Mutex.new
219
200
  end
220
-
221
- def submission_mutex
222
- @submission_mutex ||= Mutex.new
223
- end
224
-
225
- def carrier_refs
226
- @carrier_refs ||= {}
227
- end
228
201
  end
229
202
 
230
203
  # Encodes carrier spans as OTLP/JSON and posts them straight to Bitfab.
@@ -551,6 +524,7 @@ module Bitfab
551
524
  payload,
552
525
  max_carrier_bytes: PayloadBudget::MAX_COMPRESSIBLE_SPAN_CARRIER_BYTES
553
526
  )
527
+ encoded_payload.instance_variable_set(CARRIER_REF_IVAR, meta.ref) if meta.ref
554
528
  started_at = meta.started_at || Time.now
555
529
  ended_at = meta.ended_at || Time.now
556
530
  errored = meta.errored
@@ -573,7 +547,6 @@ module Bitfab
573
547
  },
574
548
  start_timestamp: started_at
575
549
  )
576
- Otel.record_carrier_ref(span.context.hex_span_id, meta.ref) if meta.ref
577
550
  span.status = OpenTelemetry::Trace::Status.error if errored
578
551
  span.finish(end_timestamp: ended_at)
579
552
  end
@@ -709,7 +682,9 @@ module Bitfab
709
682
  class << self
710
683
  def encode_span(span)
711
684
  encoded = JSON.generate(span_to_otlp(span))
712
- EncodedSpan.new(encoded, encoded.bytesize, Otel.take_carrier_ref(span.hex_span_id))
685
+ payload = span.attributes&.fetch(PAYLOAD_ATTRIBUTE, nil)
686
+ ref = payload&.instance_variable_get(CARRIER_REF_IVAR)
687
+ EncodedSpan.new(encoded, encoded.bytesize, ref)
713
688
  end
714
689
 
715
690
  def trim_span(span)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitfab
4
- VERSION = "0.36.6"
4
+ VERSION = "0.36.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitfab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.36.6
4
+ version: 0.36.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvest Team