visionary-sdk 0.6.1 → 0.7.0

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: 6d95e211f7f5591efaac13e0e00759cc4c67ccc1ec91d3f3af95c57db723e1b6
4
- data.tar.gz: 255cacea757b5f5ee0309edc0a2d56d7b8fb85df5beaf6105dba6ad583e1d419
3
+ metadata.gz: 2901c8417cdf340ca0f964c83a822e48604aacc975d9dee28f8b2f001d360f29
4
+ data.tar.gz: '08813447808f1203aa991ce8aad1b240e647873b9a7136f4b366435d820df20a'
5
5
  SHA512:
6
- metadata.gz: cd2c3ea92ca6ec2af63f784ab6e4fd6adcfcc09400cdf6f306088ec54fbf8756bc77f3234227b6481b4c6f4e312247b55e0024b2f186ef6fab21eef281faa022
7
- data.tar.gz: 7e6642c41f878bec38bfde91e080cf1415b7dc54dd86032107e3f27dd1b8b182c6839a089c8b7599a61e21f54065d67e2ef47328a7fab1546133876a25f2afa4
6
+ metadata.gz: e8e1a1b3106edd9a8dca26981fba7533a97efddfd7600e4d4eb6388a9a8495c95e1b941659891aac59abd740cacfaded2dde57da831424e11644fcaf3fbf6625
7
+ data.tar.gz: b29b98ed8359c61738ec077382b5a5d1c9a7e0222ba78efcc653bdfd13609235e60a2c4d0d54fff73b086ce07e4c0b4e7dff426636077eb66546955b4dadd695
data/README.md CHANGED
@@ -186,9 +186,10 @@ profile:
186
186
  - `routes`: the milliseconds that the requests finishing during the profile
187
187
  took, per `METHOD route`.
188
188
 
189
- A turn is skipped when no request arrived since the last one. A profile is
190
- dropped when no request finished during it, or when it has fewer than 20
191
- samples (about 200 ms of CPU).
189
+ A turn is skipped when no request arrived since the last one. A scheduled
190
+ profile is dropped when it has fewer than 20 samples (about 200 ms of CPU), and
191
+ kept otherwise even when no request finished during it (`routes` is then
192
+ `{}`). A **Profile now** one is kept with any samples.
192
193
 
193
194
  **Cost:** nothing while profiling is off apart from the settings read every
194
195
  30 s. While a profile runs, the sampler takes some tens of stack walks per
@@ -8,8 +8,11 @@ module Visionary
8
8
  # Profiling, kept in visionary_settings). One background thread reads the
9
9
  # settings every 30 s and, while profiling is on, samples the stacks of the
10
10
  # threads that are running every 10 ms for profile.duration_ms every
11
- # profile.interval_s. Each profile is one profiles row: folded stacks plus
12
- # the time each route's requests took while it ran.
11
+ # profile.interval_s, skipping a turn when no request arrived since the
12
+ # last. A scheduled profile is kept with at least MIN_SAMPLES samples, a
13
+ # "Profile now" one with any, whether or not a request finished while it
14
+ # ran. Each profile is one profiles row: folded stacks plus the time each
15
+ # route's requests took while it ran ({} when none finished).
13
16
  #
14
17
  # Ruby has no CPU-time sampler without a native extension, so this walks
15
18
  # Thread.list and keeps the threads whose status is "run". Threads that
@@ -412,8 +415,8 @@ module Visionary
412
415
  end
413
416
 
414
417
  # Samples for duration_ms and queues the profile. Returns the row, or
415
- # nil when it was dropped (too few samples, no finished request).
416
- def capture
418
+ # nil when it was dropped (fewer than min_samples, or cut short by close).
419
+ def capture(min_samples = MIN_SAMPLES)
417
420
  @last_started = Tally.started
418
421
  duration_s = @settings.duration_ms / 1000.0
419
422
  counts = Hash.new(0)
@@ -448,7 +451,7 @@ module Visionary
448
451
  elapsed_ms = ((mono - t0) * 1000).round(3)
449
452
  folded, samples = Profiler.fold(counts)
450
453
  routes = busy.transform_values { |ms| [ms.round, 1].max }
451
- return nil if samples < MIN_SAMPLES || routes.empty?
454
+ return nil if samples < min_samples || stopped?
452
455
 
453
456
  row = [Visionary.timestamp(started_at), @cfg.service, @instance, @cfg.version, "ruby",
454
457
  elapsed_ms, samples, JSON.generate(routes), folded]
@@ -478,7 +481,7 @@ module Visionary
478
481
  next_poll = mono + POLL_S
479
482
  if poll
480
483
  @logger.info("visionary: taking a CPU profile now (asked for in the dashboard)")
481
- capture
484
+ capture(1)
482
485
  next_profile = mono + @settings.interval_s if next_profile
483
486
  end
484
487
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Visionary
4
- VERSION = "0.6.1"
4
+ VERSION = "0.7.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visionary-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - styropyr0
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-22 00:00:00.000000000 Z
11
+ date: 2026-10-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  The Ruby collector for Visionary. A Rack middleware (with a Railtie for Rails)