salopulse 0.5.1 → 0.6.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 +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/salopulse/client.rb +9 -1
- data/lib/salopulse/configuration.rb +2 -1
- data/lib/salopulse/instrumentation/rack_middleware.rb +5 -1
- data/lib/salopulse/request_context.rb +4 -0
- data/lib/salopulse/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 117862e3efa386fee0b9f774bd386b5e31c760664c5dda6c20d8336a8acc3aa2
|
|
4
|
+
data.tar.gz: 7d3fa367d755b1383b1add002c21834dca1fcfcdb095eb3d4c417d441458f686
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5ac1d738a9ab88dc631589ea84acb8622f8618940fb09d8492c8b2f09c0e71b901ae2060092c41fc13e311e9f0db0cf51a65266abd625abdbb6cf1adab64cb7e
|
|
7
|
+
data.tar.gz: 05302edf2fde41c7f177c01c293e7e4bcb7a60ba793b686911eb80f1d564d3c36e5baadcf5f0e67fd59085ed89b5b386c2c905fea6e174958fa7f7080f837dc8
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
4
4
|
|
|
5
|
+
## [0.6.0] - 2026-06-11
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Performance events now carry request context the backend's request-trace view
|
|
9
|
+
needs: client `ip`, scrubbed `request_headers` and `request_params` (reusing
|
|
10
|
+
the same sanitizer as exception capture), and a `span_count` (captured SQL
|
|
11
|
+
queries plus the request span).
|
|
12
|
+
- SQL events now carry a 1-based `sequence` recording capture order, so the
|
|
13
|
+
backend can reconstruct a request's query order (a single enqueue timestamp
|
|
14
|
+
is shared across the batch and can't disambiguate it).
|
|
15
|
+
- New `config.service_name` is emitted as `envelope["service"]` on every event.
|
|
16
|
+
|
|
5
17
|
## [0.5.1] - 2026-06-10
|
|
6
18
|
|
|
7
19
|
### Changed
|
data/lib/salopulse/client.rb
CHANGED
|
@@ -127,7 +127,8 @@ module Salopulse
|
|
|
127
127
|
enqueue(build_event(type: "error", data: data, ctx: ctx))
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
-
def capture_performance(endpoint:, http_method:, duration_ms:, status_code:, cpu_usage: nil, memory_usage: nil
|
|
130
|
+
def capture_performance(endpoint:, http_method:, duration_ms:, status_code:, cpu_usage: nil, memory_usage: nil,
|
|
131
|
+
ip: nil, request_headers: nil, request_params: nil)
|
|
131
132
|
return if disabled?
|
|
132
133
|
return unless sample?
|
|
133
134
|
|
|
@@ -140,6 +141,12 @@ module Salopulse
|
|
|
140
141
|
}
|
|
141
142
|
data["cpu_usage"] = cpu_usage if cpu_usage
|
|
142
143
|
data["memory_usage"] = memory_usage if memory_usage
|
|
144
|
+
data["ip"] = ip if ip
|
|
145
|
+
data["request_headers"] = request_headers if request_headers
|
|
146
|
+
data["request_params"] = request_params if request_params
|
|
147
|
+
# Spans the SDK recorded for this request: the captured SQL queries plus the
|
|
148
|
+
# request span itself. Grows as more instrumentation (HTTP, cache) is added.
|
|
149
|
+
data["span_count"] = ctx[:sql_events].length + 1 if ctx
|
|
143
150
|
|
|
144
151
|
enqueue(build_event(type: "performance", data: data, ctx: ctx))
|
|
145
152
|
end
|
|
@@ -255,6 +262,7 @@ module Salopulse
|
|
|
255
262
|
envelope = {
|
|
256
263
|
"request_id" => ctx&.dig(:request_id),
|
|
257
264
|
"release" => @configuration.release,
|
|
265
|
+
"service" => @configuration.service_name,
|
|
258
266
|
"sdk" => { "version" => Salopulse::VERSION, "platform" => "ruby" },
|
|
259
267
|
"timestamp" => Time.now.utc.iso8601(3)
|
|
260
268
|
}.merge(extra_envelope).compact
|
|
@@ -2,7 +2,7 @@ require "logger"
|
|
|
2
2
|
|
|
3
3
|
module Salopulse
|
|
4
4
|
class Configuration
|
|
5
|
-
attr_accessor :dsn, :release, :environment, :sample_rate,
|
|
5
|
+
attr_accessor :dsn, :release, :environment, :service_name, :sample_rate,
|
|
6
6
|
:flush_interval, :flush_batch_size, :n1_threshold,
|
|
7
7
|
:before_send, :logger, :enabled, :max_buffer_size,
|
|
8
8
|
:app_root, :deploys, :release_metadata
|
|
@@ -10,6 +10,7 @@ module Salopulse
|
|
|
10
10
|
def initialize
|
|
11
11
|
@release = nil
|
|
12
12
|
@environment = nil
|
|
13
|
+
@service_name = nil
|
|
13
14
|
@sample_rate = 1.0
|
|
14
15
|
@flush_interval = 5
|
|
15
16
|
@flush_batch_size = 100
|
|
@@ -25,11 +25,15 @@ module Salopulse
|
|
|
25
25
|
raise
|
|
26
26
|
ensure
|
|
27
27
|
begin
|
|
28
|
+
snapshot = env_snapshot(env)
|
|
28
29
|
@client.capture_performance(
|
|
29
30
|
endpoint: endpoint,
|
|
30
31
|
http_method: http_method,
|
|
31
32
|
duration_ms: Salopulse::RequestContext.elapsed_ms,
|
|
32
|
-
status_code: status
|
|
33
|
+
status_code: status,
|
|
34
|
+
ip: snapshot["ip"],
|
|
35
|
+
request_headers: snapshot["headers"],
|
|
36
|
+
request_params: snapshot["params"]
|
|
33
37
|
)
|
|
34
38
|
@client.flush_request_scope_events
|
|
35
39
|
rescue StandardError
|
|
@@ -46,6 +46,10 @@ module Salopulse
|
|
|
46
46
|
def record_sql_event(event, fingerprint)
|
|
47
47
|
ctx = current
|
|
48
48
|
return false unless ctx
|
|
49
|
+
# 1-based position in capture order, so the backend can reconstruct the
|
|
50
|
+
# exact query sequence within a request (created_at alone is ambiguous —
|
|
51
|
+
# the whole batch shares one enqueue timestamp).
|
|
52
|
+
event[:data]["sequence"] = ctx[:sql_events].length + 1 if event[:data].is_a?(Hash)
|
|
49
53
|
ctx[:sql_events] << [event, fingerprint]
|
|
50
54
|
ctx[:sql_fingerprint_counts][fingerprint] += 1
|
|
51
55
|
true
|
data/lib/salopulse/version.rb
CHANGED