logtail-rack 0.2.6 → 0.2.7

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: 2e925613f03cc44c9e8b160ca4afefbe3c1716bb4c376d2407af771e9458c76b
4
- data.tar.gz: f2f8f87d6daa1e6d58e1067c3ebbfa189f2261924e011e9d67906ccea9846ac0
3
+ metadata.gz: 9f416be58cf3b8f82cdd582233d0de6e3b88653f11fbfdc76800dd60aadb9f55
4
+ data.tar.gz: 59cfce37f93ffbee0442c8a2d257d444e578a604f7685c3dc0371e4fee2b97c2
5
5
  SHA512:
6
- metadata.gz: 9433eec385c84eb941a88ef2b8d029100562f56a1bef97a16cae4992645bcb880484820ce8f3eee81e386cbc0cba10d03657400b772a1cd225672577e33a408f
7
- data.tar.gz: f98d540b220f588313e0746333a029aba46ed7004546370de7d33d64da08e09af9b65496e8d989280192a9c128022358876a4bda1b17d78b4445ef498b91abfc
6
+ metadata.gz: c70fddaa55215c0c43ca728cee93d7c6c77d07b2ee69e85b2923dc72cdd572e674f795cd2f2f1da543a1f0364308e94e51385fbaaa03879741a45430fd62523c
7
+ data.tar.gz: a074cb26984e9d0802b9aae58cd7961a0e894ae0095655ffc6f7e9d4aec7f4c7a428f7b359b13ac3fe99d079c01e917e74594d93a1afe5509d385fbefe57b96c
@@ -2,6 +2,8 @@ name: build
2
2
 
3
3
  on:
4
4
  push:
5
+ branches: [main]
6
+ pull_request:
5
7
  schedule:
6
8
  - cron: '20 5 * * 1'
7
9
  workflow_dispatch:
@@ -9,12 +11,13 @@ on:
9
11
  jobs:
10
12
  test:
11
13
 
12
- runs-on: ubuntu-20.04
14
+ runs-on: ubuntu-24.04
13
15
 
14
16
  strategy:
15
17
  fail-fast: false
16
18
  matrix:
17
19
  ruby-version:
20
+ - "4.0"
18
21
  - "3"
19
22
  - "3.4"
20
23
  - "3.3"
@@ -24,16 +27,21 @@ jobs:
24
27
  - "2.7"
25
28
  - "2.6"
26
29
  - "2.5"
27
- - "2.4"
28
- - "2.3"
29
- - "jruby-9.4.3.0"
30
- - "jruby-9.2.14.0"
31
- - "truffleruby-23.0.0"
32
- - "truffleruby-22.1.0"
30
+ - "truffleruby"
33
31
  rack-version:
34
32
  - "" # default Rack version
35
33
 
34
+ exclude:
35
+ # RubyGems on Ruby 2.5 ignores rack's required_ruby_version and
36
+ # installs a Rack that no longer runs on 2.5 — test it with a
37
+ # compatible Rack pinned below instead
38
+ - ruby-version: "2.5"
39
+ rack-version: ""
40
+
36
41
  include:
42
+ - ruby-version: "2.5"
43
+ rack-version: "~>2.2"
44
+
37
45
  - ruby-version: "2.7"
38
46
  rack-version: "~>1.2.0"
39
47
  - ruby-version: "2.7"
@@ -61,7 +69,7 @@ jobs:
61
69
  rack-version: "~>3.0.0"
62
70
 
63
71
  steps:
64
- - uses: actions/checkout@v2
72
+ - uses: actions/checkout@v7
65
73
 
66
74
  - name: Set up Ruby ${{ matrix.ruby-version }}
67
75
  uses: ruby/setup-ruby@v1
@@ -0,0 +1,28 @@
1
+ # Issues in this repo are synced with Linear. A GitHub closing keyword ("Closes #123",
2
+ # "Fixes owner/repo#123") closes the issue the moment the PR merges, while Linear's PR
3
+ # automation moves the linked Linear issue to Self QA at the same time. The two automations
4
+ # then fight: the GitHub issue is closed, reopened, and the Linear issue lands in Triage.
5
+ # Reference the issue with "Refs #123" instead and close it from Linear once the fix is
6
+ # released.
7
+ name: no closing keywords
8
+ on:
9
+ pull_request:
10
+ types: [opened, edited, reopened, synchronize]
11
+ permissions:
12
+ pull-requests: read
13
+ jobs:
14
+ check:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - name: Reject GitHub closing keywords in the PR description
18
+ env:
19
+ BODY: ${{ github.event.pull_request.body }}
20
+ run: |
21
+ pattern='\b(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\b:?[[:space:]]+(#[0-9]+|[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+#[0-9]+|https?://github\.com/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+/issues/[0-9]+)'
22
+ if matches=$(printf '%s' "$BODY" | grep -inoE "$pattern"); then
23
+ echo "::error::The PR description contains a GitHub closing keyword, which would close the issue on merge and desync it from Linear:"
24
+ echo "$matches"
25
+ echo "Use 'Refs #123' instead and close the issue from Linear once the fix is released."
26
+ exit 1
27
+ fi
28
+ echo "No closing keywords found."
@@ -0,0 +1,215 @@
1
+ # Publishes the gem to RubyGems.org from GitHub Actions with trusted publishing (OIDC), the way
2
+ # logtail-js releases the @logtail/* packages to npm. No RubyGems.org API key exists anywhere:
3
+ # the gem on rubygems.org trusts exactly this workflow file, run from this repository in the
4
+ # "rubygems" environment, and the shared account's multi-factor authentication stays as it is.
5
+ #
6
+ # One-time setup on rubygems.org, signed in as the gem's owner: the gem's page → Trusted publishers
7
+ # → GitHub Actions, with the repository owner "logtail", this repository's name, the workflow
8
+ # "release.yml" and the environment "rubygems".
9
+ #
10
+ # Repository settings this relies on: the "rubygems" environment with deployment branches limited
11
+ # to main and no required reviewers (add reviewers there if releases should need an approval; a
12
+ # job that references a missing environment would create it WITHOUT protection), and the GitHub
13
+ # Actions app among the actors allowed to bypass the pull request requirement of main, which the
14
+ # version commit needs.
15
+ #
16
+ # Release: Actions → Release → Run workflow from main, pick patch or minor. The workflow runs the
17
+ # tests, bumps the version in lib/*/version.rb, builds the gem, commits "vX.Y.Z", tags it, pushes
18
+ # both, pushes the gem to RubyGems.org and creates a GitHub release with auto-generated notes for
19
+ # the tag; edit the notes afterwards if needed.
20
+ #
21
+ # Retry: if a release failed after the version commit was pushed, run "retry" from main. It bumps
22
+ # nothing, checks out the tag of the version in lib/*/version.rb and rebuilds that commit, pushes
23
+ # the gem if RubyGems.org is still missing it and creates the GitHub release if it is still
24
+ # missing. Running patch or minor again would release the next version instead.
25
+ #
26
+ # Dry run: bumps in place without committing, builds the gem and, on main, exchanges the
27
+ # workflow's OIDC token with RubyGems.org, which proves that the trusted publisher matches this
28
+ # workflow. Nothing is pushed. Every push that touches this file is a dry run, so a change to the
29
+ # workflow proves itself on its pull request before it reaches main, and the push that merges it
30
+ # performs the token exchange as well, because the "rubygems" environment only admits main. A dry
31
+ # run can also be dispatched from any branch.
32
+ name: Release
33
+
34
+ on:
35
+ workflow_dispatch:
36
+ inputs:
37
+ release:
38
+ description: "patch or minor: bump, tag and publish. retry: finish a release that failed halfway."
39
+ type: choice
40
+ options: [patch, minor, retry]
41
+ required: true
42
+ dry_run:
43
+ description: "Dry run: bump and build, verify RubyGems.org accepts this workflow, publish nothing"
44
+ type: boolean
45
+ default: false
46
+ push:
47
+ paths:
48
+ - .github/workflows/release.yml
49
+
50
+ permissions:
51
+ contents: read
52
+
53
+ concurrency:
54
+ group: release
55
+ cancel-in-progress: false
56
+
57
+ env:
58
+ DRY_RUN: ${{ github.event_name == 'push' || inputs.dry_run }}
59
+ RELEASE: ${{ inputs.release || 'patch' }}
60
+
61
+ jobs:
62
+ verify:
63
+ name: Test
64
+ runs-on: ubuntu-24.04
65
+ steps:
66
+ - uses: actions/checkout@v7
67
+
68
+ - name: Set up Ruby
69
+ uses: ruby/setup-ruby@v1
70
+ with:
71
+ ruby-version: "3"
72
+ bundler-cache: true
73
+
74
+ - name: Run tests
75
+ run: bundle exec rspec
76
+
77
+ build:
78
+ name: Bump and build
79
+ needs: verify
80
+ runs-on: ubuntu-24.04
81
+ permissions:
82
+ contents: write # pushes the version commit and the tag
83
+ outputs:
84
+ version: ${{ steps.version.outputs.version }}
85
+ gem: ${{ steps.build.outputs.gem }}
86
+
87
+ steps:
88
+ - name: Releases run from main only
89
+ if: ${{ env.DRY_RUN != 'true' && github.ref != 'refs/heads/main' }}
90
+ run: |
91
+ echo "::error::Dispatch the release from main, not from $GITHUB_REF_NAME."
92
+ exit 1
93
+
94
+ - uses: actions/checkout@v7
95
+ with:
96
+ fetch-depth: 0 # the version check looks at the tags on HEAD
97
+
98
+ - name: Set up Ruby
99
+ uses: ruby/setup-ruby@v1
100
+ with:
101
+ ruby-version: "3"
102
+
103
+ - name: Bump version
104
+ id: version
105
+ run: |
106
+ ruby - <<'EOF'
107
+ release, dry_run = ENV.fetch("RELEASE"), ENV["DRY_RUN"] == "true"
108
+ path = Dir["lib/**/version.rb"].fetch(0)
109
+ source = File.read(path)
110
+ current = source[/VERSION = "(\d+\.\d+\.\d+)"/, 1] || abort("no VERSION constant in #{path}")
111
+ tagged = `git tag --points-at HEAD`.split.include?("v#{current}")
112
+
113
+ if release == "retry"
114
+ # main may have moved on since the version commit, so build what the tag points at
115
+ abort("retry only finishes a release whose version v#{current} is tagged") unless system("git", "rev-parse", "-q", "--verify", "refs/tags/v#{current}", out: File::NULL)
116
+ system("git", "checkout", "-q", "v#{current}") || abort("could not check out v#{current}")
117
+ version = current
118
+ else
119
+ abort("HEAD is already released as v#{current}, there is nothing new to release") if tagged && !dry_run
120
+ major, minor, patch = current.split(".").map(&:to_i)
121
+ version = release == "minor" ? "#{major}.#{minor + 1}.0" : "#{major}.#{minor}.#{patch + 1}"
122
+ File.write(path, source.sub(%("#{current}"), %("#{version}")))
123
+ end
124
+
125
+ puts "#{current} -> #{version}"
126
+ File.open(ENV.fetch("GITHUB_OUTPUT"), "a") { |output| output.puts "version=#{version}" }
127
+ EOF
128
+
129
+ - name: Build the gem
130
+ id: build
131
+ env:
132
+ VERSION: ${{ steps.version.outputs.version }}
133
+ run: |
134
+ git diff --stat
135
+ gem build *.gemspec
136
+ gem=$(ls *.gem)
137
+ case "$gem" in
138
+ *-"$VERSION".gem) ;;
139
+ *) echo "::error::Built $gem, expected version $VERSION."; exit 1 ;;
140
+ esac
141
+ echo "gem=$gem" >> "$GITHUB_OUTPUT"
142
+
143
+ - name: Commit and tag
144
+ if: ${{ env.DRY_RUN != 'true' && env.RELEASE != 'retry' }}
145
+ env:
146
+ VERSION: ${{ steps.version.outputs.version }}
147
+ run: |
148
+ git config user.name "github-actions[bot]"
149
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
150
+ git commit -am "v$VERSION"
151
+ git tag -a "v$VERSION" -m "v$VERSION"
152
+ git push origin main "v$VERSION"
153
+
154
+ - uses: actions/upload-artifact@v7
155
+ with:
156
+ name: gem
157
+ path: "*.gem"
158
+ if-no-files-found: error
159
+
160
+ release:
161
+ name: Publish
162
+ needs: build
163
+ # The rubygems environment only admits main, so dry runs from other branches stop after the build
164
+ if: ${{ github.ref == 'refs/heads/main' }}
165
+ runs-on: ubuntu-24.04
166
+ environment: rubygems
167
+ permissions:
168
+ contents: write # creates the GitHub release
169
+ id-token: write # OIDC token exchange with RubyGems.org
170
+ env:
171
+ VERSION: ${{ needs.build.outputs.version }}
172
+ GEM: ${{ needs.build.outputs.gem }}
173
+
174
+ steps:
175
+ - uses: actions/download-artifact@v8
176
+ with:
177
+ name: gem
178
+
179
+ - name: Set up Ruby
180
+ uses: ruby/setup-ruby@v1
181
+ with:
182
+ ruby-version: "3"
183
+
184
+ # Exchanges the job's OIDC token for a short-lived RubyGems.org API key and hands it to
185
+ # `gem push`. Fails when no trusted publisher on rubygems.org matches this workflow.
186
+ - uses: rubygems/configure-rubygems-credentials@v2.1.0
187
+
188
+ - name: Dry run
189
+ if: ${{ env.DRY_RUN == 'true' }}
190
+ run: |
191
+ ls -l "$GEM"
192
+ echo "RubyGems.org accepted the OIDC token: the trusted publisher matches this workflow. Nothing is pushed."
193
+
194
+ - name: Push to RubyGems.org
195
+ if: ${{ env.DRY_RUN != 'true' }}
196
+ run: |
197
+ name="${GEM%-$VERSION.gem}"
198
+ if gem specification --remote "$name" --version "$VERSION" > /dev/null 2>&1; then
199
+ echo "$name $VERSION is on rubygems.org already, finishing the release."
200
+ else
201
+ gem push "$GEM"
202
+ fi
203
+
204
+ - name: Create GitHub release
205
+ if: ${{ env.DRY_RUN != 'true' }}
206
+ env:
207
+ GH_TOKEN: ${{ github.token }}
208
+ GH_REPO: ${{ github.repository }}
209
+ run: |
210
+ if gh release view "v$VERSION" > /dev/null 2>&1; then
211
+ echo "Release v$VERSION already exists."
212
+ else
213
+ # --verify-tag: only ever attach to the tag the build job pushed, never create one here.
214
+ gh release create "v$VERSION" --verify-tag --generate-notes
215
+ fi
data/Gemfile CHANGED
@@ -3,3 +3,5 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  gem "base64" if RUBY_VERSION >= "3.4.0"
6
+ # No longer a default gem on Ruby 4.0 and TruffleRuby 40, and logtail 0.1.17 requires it undeclared
7
+ gem "logger"
@@ -15,6 +15,8 @@ module Logtail
15
15
  # response events. The {Events::HTTPRequest} and {Events::HTTPResponse} events
16
16
  # respectively.
17
17
  class HTTPEvents < Middleware
18
+ DEFAULT_HTTP_HEADER_FILTERS = ["Authorization", "Proxy-Authorization", "Cookie", "Set-Cookie"].freeze
19
+
18
20
  class << self
19
21
  # Allows you to capture the HTTP request body, default is off (false).
20
22
  #
@@ -107,8 +109,11 @@ module Logtail
107
109
  #
108
110
  # Filtered HTTP header values will be sent to Better Stack as "[FILTERED]"
109
111
  #
112
+ # {DEFAULT_HTTP_HEADER_FILTERS} are filtered out of the box. Setting this replaces
113
+ # the whole list, pass an empty list to log every header.
114
+ #
110
115
  # @example
111
- # Logtail::Integrations::Rack::HTTPEvents.http_header_filters = ["Authorization"]
116
+ # Logtail::Integrations::Rack::HTTPEvents.http_header_filters = Logtail::Integrations::Rack::HTTPEvents::DEFAULT_HTTP_HEADER_FILTERS + ["X-Api-Key"]
112
117
  def http_header_filters=(value)
113
118
  @http_header_filters = value.map { |header_name| normalize_header_name(header_name) }
114
119
  end
@@ -123,6 +128,8 @@ module Logtail
123
128
  end
124
129
  end
125
130
 
131
+ self.http_header_filters = DEFAULT_HTTP_HEADER_FILTERS
132
+
126
133
  CONTENT_LENGTH_KEY = 'Content-Length'.freeze
127
134
 
128
135
  def call(env)
@@ -271,7 +278,7 @@ module Logtail
271
278
  def filter_http_headers(headers)
272
279
  headers.map do |name, value|
273
280
  normalized_name = self.class.normalize_header_name(name)
274
- is_filtered = self.class.http_header_filters&.include?(normalized_name)
281
+ is_filtered = self.class.http_header_filters.include?(normalized_name)
275
282
  [name, is_filtered ? "[FILTERED]" : value]
276
283
  end.to_h
277
284
  end
@@ -1,7 +1,7 @@
1
1
  module Logtail
2
2
  module Integrations
3
3
  module Rack
4
- VERSION = "0.2.6"
4
+ VERSION = "0.2.7"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logtail-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Better Stack
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-02-11 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: logtail
@@ -86,7 +85,6 @@ dependencies:
86
85
  - - "~>"
87
86
  - !ruby/object:Gem::Version
88
87
  version: '3.0'
89
- description:
90
88
  email:
91
89
  - hello@betterstack.com
92
90
  executables: []
@@ -94,6 +92,8 @@ extensions: []
94
92
  extra_rdoc_files: []
95
93
  files:
96
94
  - ".github/workflows/main.yml"
95
+ - ".github/workflows/no-closing-keywords.yml"
96
+ - ".github/workflows/release.yml"
97
97
  - ".gitignore"
98
98
  - ".rspec"
99
99
  - Gemfile
@@ -126,7 +126,6 @@ metadata:
126
126
  homepage_uri: https://github.com/logtail/logtail-ruby-rack
127
127
  source_code_uri: https://github.com/logtail/logtail-ruby-rack
128
128
  changelog_uri: https://github.com/logtail/logtail-ruby-rack/blob/master/README.md
129
- post_install_message:
130
129
  rdoc_options: []
131
130
  require_paths:
132
131
  - lib
@@ -141,8 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
140
  - !ruby/object:Gem::Version
142
141
  version: '0'
143
142
  requirements: []
144
- rubygems_version: 3.3.7
145
- signing_key:
143
+ rubygems_version: 3.6.9
146
144
  specification_version: 4
147
145
  summary: Logtail integration for Rack
148
146
  test_files: []