apirelio-rails 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 315db73ba6a8c542405b654fd06f14eeb266094261d7fc8eb5e99c6a3740b338
4
+ data.tar.gz: d6abf278b2edf175d4f97e3050e7aee75f7ce1c4a71e72d0d200e4412830f9d5
5
+ SHA512:
6
+ metadata.gz: 7ca3413f28871ccdac677b8167aed1477704fcb8470e69bad170a90b95aaf7ca6ab6602bfb41d6de0c434ca2548540992ff021970cda574d17e0ba63fe6eac0e
7
+ data.tar.gz: c623fe0d570cc43db9514c9fc8a17f4d5c81b2e3dac4e393060131d55a50c1e3d5ce1b16edb1d7e545eb27cd2137206cd32cd7de0edb3e8f19aa77fbb1f9dcf8
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 - 2026-08-12
4
+
5
+ - Add automatic Rails middleware registration through a Railtie.
6
+ - Add Rails configuration, customer/application resolvers and request context.
7
+ - Capture matched Action Dispatch route patterns, controller actions and exceptions.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Apirelio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Apirelio Rails
2
+
3
+ [Documentation](https://apirelio.com/docs/ruby/rails) · [RubyGems](https://rubygems.org/gems/apirelio-rails) · [Apirelio](https://apirelio.com)
4
+
5
+ Automatic customer-aware API analytics for Rails 7.1 and 8.x.
6
+
7
+ ```bash
8
+ bundle add apirelio-rails
9
+ ```
10
+
11
+ ```ruby
12
+ # config/initializers/apirelio.rb
13
+ Apirelio::Rails.configure do |config|
14
+ config.api_key = ENV.fetch("APIRELIO_API_KEY", "")
15
+ config.service = "billing-api"
16
+ config.customer_resolver = ->(env) {
17
+ account = env["current_account"]
18
+ account && { id: account.id.to_s, name: account.name, plan: account.plan }
19
+ }
20
+ end
21
+ ```
22
+
23
+ The Railtie registers middleware automatically. It records matched Rails routes, controller actions, status, duration and stable customer/application identity. Bodies, query strings, credentials, cookies and client IP addresses are never captured.
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apirelio
4
+ module Rails
5
+ class Configuration
6
+ attr_accessor :api_key, :service, :endpoint, :environment, :release, :enabled,
7
+ :batch_size, :flush_interval, :max_queue_size, :timeout, :max_retries,
8
+ :metadata_keys, :include_routes, :exclude_routes, :customer_resolver,
9
+ :application_resolver, :error_code_resolver, :metadata_resolver,
10
+ :api_version_header, :capture_headers, :transport
11
+
12
+ def initialize
13
+ @api_key = ENV.fetch("APIRELIO_API_KEY", "")
14
+ @service = ENV.fetch("APIRELIO_SERVICE", "rails-api")
15
+ @endpoint = ENV.fetch("APIRELIO_ENDPOINT", "https://apirelio.com")
16
+ @environment = ENV.fetch("RAILS_ENV", "production")
17
+ @release = ENV["APIRELIO_RELEASE"]
18
+ @enabled = true
19
+ @batch_size = 100
20
+ @flush_interval = 5.0
21
+ @max_queue_size = 10_000
22
+ @timeout = 2.0
23
+ @max_retries = 2
24
+ @metadata_keys = []
25
+ @include_routes = []
26
+ @exclude_routes = []
27
+ @customer_resolver = nil
28
+ @application_resolver = nil
29
+ @error_code_resolver = nil
30
+ @metadata_resolver = nil
31
+ @api_version_header = "HTTP_X_API_VERSION"
32
+ @capture_headers = %w[HTTP_X_SDK_VERSION HTTP_USER_AGENT]
33
+ @transport = nil
34
+ end
35
+
36
+ def client_options
37
+ {
38
+ api_key: api_key,
39
+ service: service,
40
+ endpoint: endpoint,
41
+ environment: environment,
42
+ release: release,
43
+ enabled: enabled,
44
+ batch_size: batch_size,
45
+ flush_interval: flush_interval,
46
+ max_queue_size: max_queue_size,
47
+ timeout: timeout,
48
+ max_retries: max_retries,
49
+ metadata_keys: metadata_keys,
50
+ transport: transport
51
+ }
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apirelio
4
+ module Rails
5
+ class Middleware
6
+ def initialize(app, configuration = Apirelio::Rails.configuration)
7
+ @configuration = configuration
8
+ @client = Apirelio::Client.new(**configuration.client_options)
9
+ @middleware = Apirelio::Rack::Middleware.new(
10
+ app,
11
+ client: @client,
12
+ include_routes: configuration.include_routes,
13
+ exclude_routes: configuration.exclude_routes,
14
+ customer_resolver: configuration.customer_resolver,
15
+ application_resolver: configuration.application_resolver,
16
+ error_code_resolver: configuration.error_code_resolver,
17
+ metadata_resolver: configuration.metadata_resolver,
18
+ api_version_header: configuration.api_version_header,
19
+ capture_headers: configuration.capture_headers,
20
+ sdk: "rails",
21
+ sdk_version: VERSION
22
+ )
23
+ end
24
+
25
+ def call(env)
26
+ @middleware.call(env)
27
+ end
28
+
29
+ attr_reader :client
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apirelio
4
+ module Rails
5
+ class Railtie < ::Rails::Railtie
6
+ initializer "apirelio.middleware" do |app|
7
+ app.middleware.use Apirelio::Rails::Middleware, Apirelio::Rails.configuration
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apirelio
4
+ module Rails
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "apirelio"
4
+ require "active_support"
5
+ require "rails/railtie"
6
+ require_relative "rails/version"
7
+ require_relative "rails/configuration"
8
+ require_relative "rails/middleware"
9
+
10
+ module Apirelio
11
+ module Rails
12
+ class << self
13
+ def configuration
14
+ @configuration ||= Configuration.new
15
+ end
16
+
17
+ def configure
18
+ yield configuration
19
+ end
20
+
21
+ def reset_configuration!
22
+ @configuration = Configuration.new
23
+ end
24
+
25
+ def context(env)
26
+ Apirelio::Rack.context(env)
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ require_relative "rails/railtie"
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apirelio-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Apirelio
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: apirelio
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 0.1.0
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: 0.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: 0.1.0
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: 0.2.0
32
+ - !ruby/object:Gem::Dependency
33
+ name: railties
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '7.1'
39
+ - - "<"
40
+ - !ruby/object:Gem::Version
41
+ version: '9'
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '7.1'
49
+ - - "<"
50
+ - !ruby/object:Gem::Version
51
+ version: '9'
52
+ - !ruby/object:Gem::Dependency
53
+ name: actionpack
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '7.1'
59
+ - - "<"
60
+ - !ruby/object:Gem::Version
61
+ version: '9'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '7.1'
69
+ - - "<"
70
+ - !ruby/object:Gem::Version
71
+ version: '9'
72
+ - !ruby/object:Gem::Dependency
73
+ name: minitest
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '5.20'
79
+ - - "<"
80
+ - !ruby/object:Gem::Version
81
+ version: '6'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '5.20'
89
+ - - "<"
90
+ - !ruby/object:Gem::Version
91
+ version: '6'
92
+ - !ruby/object:Gem::Dependency
93
+ name: rake
94
+ requirement: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '13.1'
99
+ - - "<"
100
+ - !ruby/object:Gem::Version
101
+ version: '14'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '13.1'
109
+ - - "<"
110
+ - !ruby/object:Gem::Version
111
+ version: '14'
112
+ description: Automatic, fail-safe Apirelio request instrumentation for Rails API applications.
113
+ email:
114
+ - info@apirelio.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - CHANGELOG.md
120
+ - LICENSE
121
+ - README.md
122
+ - lib/apirelio/rails.rb
123
+ - lib/apirelio/rails/configuration.rb
124
+ - lib/apirelio/rails/middleware.rb
125
+ - lib/apirelio/rails/railtie.rb
126
+ - lib/apirelio/rails/version.rb
127
+ homepage: https://apirelio.com
128
+ licenses:
129
+ - MIT
130
+ metadata:
131
+ homepage_uri: https://apirelio.com
132
+ source_code_uri: https://github.com/pryznar/apirelio-rails
133
+ changelog_uri: https://github.com/pryznar/apirelio-rails/blob/main/CHANGELOG.md
134
+ documentation_uri: https://apirelio.com/docs/ruby/rails
135
+ rubygems_mfa_required: 'true'
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '3.1'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubygems_version: 4.0.16
151
+ specification_version: 4
152
+ summary: Customer-aware API analytics for Ruby on Rails.
153
+ test_files: []