bitfab 0.38.2 → 0.38.3

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: 29901e7611834921e9378870830af40c08e5af02d1ca0708585a02b169b12e6e
4
- data.tar.gz: b42984a3710e9399159fd44af3aaac7b76e3155bd3121eaa5482aa27570fbb2e
3
+ metadata.gz: 28a82b98d8327aead543061c18b95a22b2100f89e0289ffdd6ad85a262e08447
4
+ data.tar.gz: 18c101e18d509cc2a5fb880210d3d5cfaee0f9311c7521abeaa2716bdeca563f
5
5
  SHA512:
6
- metadata.gz: 576a44cbe7e2fdf7270f14af3d8a98541bb2e15cd2b02289c18d58f033688d6797b2b3a0cfc8153f1ba8adbf0d72f9b9b9241e1bfd5fbd3ffcc687a4cb9adb44
7
- data.tar.gz: ce3586fbdc541ffad387d87ca4299ee34df5e0c61a5c01a6b5112ee11084cb7900d6616f9e3db45ec0386fc019bc1712f267ea3c5799809880ae3611d3d30cb9
6
+ metadata.gz: 960e4f390e26e953cb555a1a359fd7e3b505172a74e513fe69f281dc7e1111b03e8ac93451154d632dd225e36cdf33f5c54dc3dc59dbd7379a7af3672f7fb87b
7
+ data.tar.gz: ac599caf319a0dc2814147faee28efd5940609bdc2200d696db4bcb3581fc72fafe443bb50f65204ffb46eea5fa8f0ff9806dd78c42a8d3599e1429263d2ab71
data/lib/bitfab/client.rb CHANGED
@@ -8,6 +8,7 @@ require_relative "http_client"
8
8
  require_relative "replay"
9
9
  require_relative "span_context"
10
10
  require_relative "serialize"
11
+ require_relative "timestamp"
11
12
  require_relative "warn_once"
12
13
 
13
14
  module Bitfab
@@ -333,7 +334,7 @@ module Bitfab
333
334
  span_id = SecureRandom.uuid
334
335
  parent_span_id = parent&.dig(:span_id)
335
336
  is_root_span = parent_span_id.nil?
336
- started_at = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%3NZ")
337
+ started_at = Bitfab.now_iso_timestamp
337
338
  resolved_test_run_id = replay_ctx&.dig(:test_run_id)
338
339
  resolved_input_source_span_id = replay_ctx&.dig(:input_source_span_id)
339
340
  resolved_input_source_trace_id = replay_ctx&.dig(:input_source_trace_id)
@@ -412,7 +413,7 @@ module Bitfab
412
413
  finalized = true
413
414
 
414
415
  begin
415
- ended_at = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%3NZ")
416
+ ended_at = Bitfab.now_iso_timestamp
416
417
 
417
418
  send_span(
418
419
  trace_function_key:,
@@ -889,7 +890,7 @@ module Bitfab
889
890
  def send_mocked_span(trace_function_key:, trace_id:, span_id:, parent_span_id:,
890
891
  span_name:, span_type:, function_name:, args:, kwargs:, mocked_output:,
891
892
  started_at:, test_run_id:, input_source_span_id:, mock_source:)
892
- ended_at = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%3NZ")
893
+ ended_at = Bitfab.now_iso_timestamp
893
894
  send_span(
894
895
  trace_function_key:,
895
896
  trace_id:,
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "timestamp"
4
+
3
5
  module Bitfab
4
6
  # Handle to the current active span, allowing context to be added.
5
7
  class CurrentSpan
@@ -171,7 +173,7 @@ module Bitfab
171
173
  def create(trace_id, test_run_id: nil, input_source_trace_id: nil)
172
174
  @states_mutex.synchronize do
173
175
  @states[trace_id] ||= begin
174
- started_at = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%3NZ")
176
+ started_at = Bitfab.now_iso_timestamp
175
177
  {
176
178
  trace_id:,
177
179
  started_at:,
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "time"
4
+
5
+ module Bitfab
6
+ @timestamp_mutex = Mutex.new
7
+ @last_timestamp_us = 0
8
+
9
+ def self.now_iso_timestamp
10
+ wall_clock_us = (Time.now.to_r * 1_000_000).to_i
11
+ timestamp_us = @timestamp_mutex.synchronize do
12
+ @last_timestamp_us = [wall_clock_us, @last_timestamp_us + 1].max
13
+ end
14
+ Time.at(Rational(timestamp_us, 1_000_000)).utc.strftime("%Y-%m-%dT%H:%M:%S.%6NZ")
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitfab
4
- VERSION = "0.38.2"
4
+ VERSION = "0.38.3"
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.38.2
4
+ version: 0.38.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvest Team
@@ -153,6 +153,7 @@ files:
153
153
  - lib/bitfab/replay_registry.rb
154
154
  - lib/bitfab/serialize.rb
155
155
  - lib/bitfab/span_context.rb
156
+ - lib/bitfab/timestamp.rb
156
157
  - lib/bitfab/traceable.rb
157
158
  - lib/bitfab/transport.rb
158
159
  - lib/bitfab/version.rb