logtail 0.1.17 → 0.1.19

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: d044ba470b7e68b4da31ecd63bf00d4e35be44cd58ab0af0cb3b3837335692d3
4
- data.tar.gz: 58052b27afea62453f35eb9807144554ebc798eec805939b6f5b29a7d7d3156a
3
+ metadata.gz: cd895e734e1d553b0dfdf1011f0a46b6f043a50c391d27822ee015a517759650
4
+ data.tar.gz: 964ab22275d822db5df10f3a4616e25d500b0d9292057ea26f4467be40786e63
5
5
  SHA512:
6
- metadata.gz: aac98143909431c687db15b2b33090f899e044660df8bcd0246b82d3cd62a32c713840189f94e6b9761fbe43953a6cd95e429906a90ba512711efff01fb2e649
7
- data.tar.gz: 1cfd8815639f7e1c27483d254a99c2ceedd9884630c4e2fefb3e59f8bb2510166a74f8687038078955679fd55099c6422d4a79baccedd52b461e6af6e8f05de6
6
+ metadata.gz: 6556a1a6135a0c12070fab2080f43800e48fc0c7acfebab062d70ccc99999dadcbcb913145312d3fd61a0a5ad9f3ab411e6017a2cfe5cb55988867f882a748ec
7
+ data.tar.gz: 10e8559ff2347820d3e7d0af52c019fbdd84c82507653f232b33e1bfdd9cd35382ba04a109537e6c537b429df857e0383bd2b3930cd60f576d121fb1e1f0f5ab
@@ -2,19 +2,22 @@ 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:
8
10
 
9
11
  jobs:
10
12
  test:
11
- runs-on: ubuntu-20.04
13
+ runs-on: ubuntu-24.04
12
14
 
13
15
  strategy:
14
16
  fail-fast: false
15
17
 
16
18
  matrix:
17
19
  ruby-version:
20
+ - "4.0"
18
21
  - "3"
19
22
  - "3.4"
20
23
  - "3.3"
@@ -24,13 +27,10 @@ jobs:
24
27
  - "2.7"
25
28
  - "2.6"
26
29
  - "2.5"
27
- - "jruby-9.4.3.0"
28
- - "jruby-9.2.14.0"
29
- - "truffleruby-23.0.0"
30
- - "truffleruby-22.1.0"
30
+ - "truffleruby"
31
31
 
32
32
  steps:
33
- - uses: actions/checkout@v2
33
+ - uses: actions/checkout@v7
34
34
 
35
35
  - name: Set up Ruby ${{ matrix.ruby-version }}
36
36
  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
@@ -1,4 +1,3 @@
1
- require "base64"
2
1
  require "msgpack"
3
2
  require "net/https"
4
3
  require "zlib"
@@ -30,10 +29,8 @@ module Logtail
30
29
  # options control when the flush happens, `:batch_byte_size` and `:flush_interval`.
31
30
  # If either of these are surpassed, the buffer will be flushed.
32
31
  #
33
- # By default, the buffer will apply back pressure when the rate of log messages exceeds
34
- # the maximum delivery rate. If you don't want to sacrifice app performance in this case
35
- # you can drop the log messages instead by passing a {DroppingSizedQueue} via the
36
- # `:request_queue` option.
32
+ # By default, the buffer will drop log messages when the rate of log messages exceeds
33
+ # the maximum delivery rate. You can change this with the `:request_queue` option.
37
34
  #
38
35
  # @param source_token [String] The API key provided to you after you add your source to
39
36
  # [Better Stack](https://telemetry.betterstack.com).
@@ -122,13 +119,13 @@ module Logtail
122
119
  # Closes the log device, cleans up, and attempts one last delivery.
123
120
  def close
124
121
  # Kill the flush thread immediately since we are about to flush again.
125
- @flush_thread.kill if @flush_thread
122
+ @flush_thread.kill.join if @flush_thread
126
123
 
127
124
  # Flush all remaining messages
128
125
  flush
129
126
 
130
127
  # Kill the request queue thread. Flushing ensures that no requests are pending.
131
- @request_outlet_thread.kill if @request_outlet_thread
128
+ @request_outlet_thread.kill.join if @request_outlet_thread
132
129
  end
133
130
 
134
131
  def deliver_one(msg)
@@ -1,3 +1,3 @@
1
1
  module Logtail
2
- VERSION = "0.1.17"
2
+ VERSION = "0.1.19"
3
3
  end
data/logtail.gemspec CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ["lib"]
27
27
 
28
28
  spec.add_dependency('msgpack', '~> 1.0')
29
+ spec.add_dependency('logger', '~> 1.0')
29
30
 
30
31
  spec.add_development_dependency('bundler-audit', '>= 0')
31
32
  spec.add_development_dependency('rails_stdout_logging', '>= 0')
@@ -57,10 +57,8 @@ describe Logtail::LogDevices::HTTP do
57
57
  http.send(:ensure_flush_threads_are_started)
58
58
  http.close
59
59
  thread = http.instance_variable_get(:@flush_thread)
60
- sleep 0.1 # too fast!
61
60
  expect(thread).to_not be_alive
62
61
  thread = http.instance_variable_get(:@request_outlet_thread)
63
- sleep 0.1 # too fast!
64
62
  expect(thread).to_not be_alive
65
63
  end
66
64
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logtail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Better Stack
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-03-10 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: msgpack
@@ -24,6 +23,20 @@ dependencies:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
25
  version: '1.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: logger
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.0'
27
40
  - !ruby/object:Gem::Dependency
28
41
  name: bundler-audit
29
42
  requirement: !ruby/object:Gem::Requirement
@@ -122,7 +135,6 @@ dependencies:
122
135
  - - "~>"
123
136
  - !ruby/object:Gem::Version
124
137
  version: '2.3'
125
- description:
126
138
  email:
127
139
  - hello@betterstack.com
128
140
  executables: []
@@ -130,6 +142,8 @@ extensions: []
130
142
  extra_rdoc_files: []
131
143
  files:
132
144
  - ".github/workflows/main.yml"
145
+ - ".github/workflows/no-closing-keywords.yml"
146
+ - ".github/workflows/release.yml"
133
147
  - ".gitignore"
134
148
  - ".rspec"
135
149
  - Gemfile
@@ -193,7 +207,6 @@ metadata:
193
207
  changelog_uri: https://github.com/logtail/logtail-ruby/tree/master/CHANGELOG.md
194
208
  homepage_uri: https://github.com/logtail/logtail-ruby
195
209
  source_code_uri: https://github.com/logtail/logtail-ruby
196
- post_install_message:
197
210
  rdoc_options: []
198
211
  require_paths:
199
212
  - lib
@@ -208,20 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
221
  - !ruby/object:Gem::Version
209
222
  version: '0'
210
223
  requirements: []
211
- rubygems_version: 3.3.7
212
- signing_key:
224
+ rubygems_version: 3.6.9
213
225
  specification_version: 4
214
226
  summary: Query logs like you query your database. https://logs.betterstack.com/
215
- test_files:
216
- - spec/README.md
217
- - spec/logtail/current_context_spec.rb
218
- - spec/logtail/events/controller_call_spec.rb
219
- - spec/logtail/events/error_spec.rb
220
- - spec/logtail/log_devices/http_spec.rb
221
- - spec/logtail/log_entry_spec.rb
222
- - spec/logtail/logger_spec.rb
223
- - spec/spec_helper.rb
224
- - spec/support/logtail.rb
225
- - spec/support/socket_hostname.rb
226
- - spec/support/timecop.rb
227
- - spec/support/webmock.rb
227
+ test_files: []