legionio 1.7.21 → 1.7.24

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: f1c44047319bdcf02eb061d73517101f695f380d976cb65ad9e2a0d2afb824b2
4
- data.tar.gz: e756182d3fdfea35882961412f7d3093884d7477954c3b67d2037039ad310189
3
+ metadata.gz: 8e469923d32f8ead43a892e473c93737139885622f40683a63aa0a757a0c282d
4
+ data.tar.gz: 2e88c8468007f617c075178410da534337931e37a3c50fb11a67fa3801807689
5
5
  SHA512:
6
- metadata.gz: 1178b2efaadc7801e37a68fd556add983eede7acd3f01dd1c744b029c8e048dc7ac681db0b578fc545419ca8d4f447cc518d3f7d5c2b351323350c1ae9ea908c
7
- data.tar.gz: c9f34008bef206a7108cbc4013213342c4bc25fa6396884fec1e471b3b6d46d7110027214a0829c05a0d59d59c348fad8726d089c03ffbb1b40ce5f7d9de10a7
6
+ metadata.gz: 4d7cd5a0513e26ca92bf5b909ac924a7041bbe2b74602d6a552357d155f9101c0d81b75c6d4db0c06b9748b08fd174363ad7d26ffa021f82001923d428ecd5ec
7
+ data.tar.gz: 252dc15217cf3d320fa9f96703967d9c9320f2d3e26d18d91c992a8819dbf34ced50eca926ddcba0a3c2be1a74619d3f6106d20ca9f09919ba6c32901b8d5197
data/CHANGELOG.md CHANGED
@@ -1,6 +1,21 @@
1
1
  # Legion Changelog
2
2
 
3
- ## [Unreleased]
3
+ ## [1.7.24] - 2026-04-06
4
+
5
+ ### Fixed
6
+ - `Routes::Events` SSE stream: qualify `stream_queue` call with `Routes::Events.` to fix NoMethodError on Legion::API instance
7
+
8
+ ### Added
9
+ - `Identity::Process.source` accessor — exposes provider source in identity hash (Wire Format Phase 3)
10
+ - `source:` key in `Identity::Process.identity_hash`, `bind!`, `bind_fallback!`, and `EMPTY_STATE`
11
+
12
+ ## [1.7.22] - 2026-04-06
13
+ ### Added
14
+ - Elastic APM integration for Sinatra API via `elastic-apm` gem
15
+ - Full APM config under `api.elastic_apm` settings: server_url, api_key, secret_token, api_buffer_size, api_request_size, api_request_time, capture_body, capture_headers, capture_env, disable_send, enabled, environment, hostname, ignore_url_patterns, pool_size, service_name, service_node_name, service_version, sample_rate
16
+ - `setup_apm` / `shutdown_apm` lifecycle in Service (boot, shutdown, reload)
17
+ - `ElasticAPM::Middleware` wired into API when available
18
+ - Health/ready endpoints excluded from APM tracing by default
4
19
 
5
20
  ## [1.7.21] - 2026-04-06
6
21
  ### Fixed
@@ -90,7 +90,7 @@ module Legion
90
90
  end
91
91
 
92
92
  stream do |out|
93
- stream_queue(out: out, queue: queue, listener: listener)
93
+ Routes::Events.stream_queue(out: out, queue: queue, listener: listener)
94
94
  end
95
95
  end
96
96
 
@@ -10,19 +10,45 @@ module Legion
10
10
 
11
11
  def call(env)
12
12
  method_path = "#{env['REQUEST_METHOD']} #{env['PATH_INFO']}"
13
- Legion::Logging.info "[api][request-start] #{method_path}"
13
+ client_info = build_client_info(env)
14
+ Legion::Logging.info "[api][request-start] #{method_path} #{client_info}"
14
15
  start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
15
16
  status, headers, body = @app.call(env)
16
17
  duration = ((::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start) * 1000).round(2)
17
18
 
18
19
  level = duration > 5000 ? :warn : :info
19
- Legion::Logging.send(level, "[api] #{method_path} #{status} #{duration}ms")
20
+ Legion::Logging.send(level, "[api] #{method_path} #{status} #{duration}ms #{client_info}")
20
21
  [status, headers, body]
21
22
  rescue StandardError => e
22
23
  duration = ((::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start) * 1000).round(2)
23
- Legion::Logging.error "[api] #{method_path} 500 #{duration}ms - #{e.message}"
24
+ Legion::Logging.error "[api] #{method_path} 500 #{duration}ms #{client_info} - #{e.message}"
24
25
  raise
25
26
  end
27
+
28
+ private
29
+
30
+ def build_client_info(env)
31
+ ip = env['HTTP_X_FORWARDED_FOR'] || env['REMOTE_ADDR'] || '-'
32
+ ua = env['HTTP_USER_AGENT'] || '-'
33
+ origin = env['HTTP_ORIGIN'] || '-'
34
+ referer = env['HTTP_REFERER'] || '-'
35
+ auth = env['HTTP_AUTHORIZATION'] ? 'Bearer(present)' : 'none'
36
+ content_type = env['CONTENT_TYPE'] || '-'
37
+ content_length = env['CONTENT_LENGTH'] || '-'
38
+ query = env['QUERY_STRING'] && env['QUERY_STRING'].empty? ? nil : env['QUERY_STRING']
39
+
40
+ parts = [
41
+ "ip=#{ip}",
42
+ "ua=#{ua}",
43
+ "origin=#{origin}",
44
+ "referer=#{referer}",
45
+ "auth=#{auth}",
46
+ "content_type=#{content_type}",
47
+ "content_length=#{content_length}"
48
+ ]
49
+ parts << "query=#{query}" if query
50
+ parts.join(' ')
51
+ end
26
52
  end
27
53
  end
28
54
  end
@@ -11,6 +11,7 @@ module Legion
11
11
  id: nil,
12
12
  canonical_name: nil,
13
13
  kind: nil,
14
+ source: nil,
14
15
  persistent: false,
15
16
  groups: [].freeze,
16
17
  metadata: {}.freeze
@@ -53,11 +54,16 @@ module Legion
53
54
  @state.get[:persistent] == true
54
55
  end
55
56
 
57
+ def source
58
+ @state.get[:source]
59
+ end
60
+
56
61
  def identity_hash
57
62
  {
58
63
  id: id,
59
64
  canonical_name: canonical_name,
60
65
  kind: kind,
66
+ source: source,
61
67
  mode: mode,
62
68
  queue_prefix: queue_prefix,
63
69
  resolved: resolved?,
@@ -69,10 +75,12 @@ module Legion
69
75
 
70
76
  def bind!(provider, identity_hash)
71
77
  @provider = provider
78
+ provider_source = provider.respond_to?(:provider_name) ? provider.provider_name : nil
72
79
  @state.set({
73
80
  id: identity_hash[:id],
74
81
  canonical_name: identity_hash[:canonical_name],
75
82
  kind: identity_hash[:kind],
83
+ source: identity_hash.key?(:source) ? identity_hash[:source] : provider_source,
76
84
  persistent: identity_hash.fetch(:persistent, true),
77
85
  groups: Array(identity_hash[:groups]).compact.freeze,
78
86
  metadata: identity_hash[:metadata].is_a?(Hash) ? identity_hash[:metadata].dup.freeze : {}.freeze
@@ -86,6 +94,7 @@ module Legion
86
94
  id: nil,
87
95
  canonical_name: user,
88
96
  kind: :human,
97
+ source: :system,
89
98
  persistent: false,
90
99
  groups: [].freeze,
91
100
  metadata: {}.freeze
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Legion
4
- VERSION = '1.7.21'
4
+ VERSION = '1.7.24'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legionio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.21
4
+ version: 1.7.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity