lambda_loadout 0.0.2 → 0.0.4
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 +44 -1
- data/README.md +5 -1
- data/lib/lambda_loadout/logger.rb +1 -1
- data/lib/lambda_loadout/metrics.rb +1 -1
- data/lib/lambda_loadout/version.rb +1 -1
- data/lib/lambda_loadout.rb +26 -5
- metadata +27 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9eb2fc830c68b4e24d33e22c674efeeadcd9fb99d6098bf85a5e05b76a0f1993
|
|
4
|
+
data.tar.gz: e9967acf7e49ea6b9addd212d8cee2f67c3f66bd3f273310f1cde191205a81e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d33bc3a26d7e4029338997d89ca3d2940bb28b3351a95925223c053f34ba55902ffb30f7a6dfec4051f5e6c8bce57c3deab6bb0364fe49d8cbfe85eeef137510
|
|
7
|
+
data.tar.gz: 41de982dbc56ed8aa6f12528b2d18b70e7dc04ab4cc8f9167896eb09ed3aa26d762fe139c530942574e8679bb174de5aa5fb5c88b310e2fc41f9c3dc83675b0d
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.0.4] - 2026-10-30
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- The Lambda layer supports `ruby4.0` as well as `ruby3.4`. The zip carries a gem directory
|
|
14
|
+
for each runtime (`ruby/gems/3.4.0`, `ruby/gems/4.0.0`) and is published with both
|
|
15
|
+
compatible runtimes, so one layer version serves both.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- The `json` dependency allows json 3.x (`>= 2, < 4`). Lambda Loadout only calls
|
|
19
|
+
`JSON.generate` and `JSON.pretty_generate`, which behave the same in json 3.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
- `rake layer:build` installs the gem inside `public.ecr.aws/sam/build-ruby<version>`
|
|
23
|
+
rather than with the host's Ruby. Before, native extensions (`json`, `bigdecimal`) were
|
|
24
|
+
compiled for whatever machine ran the build, which might not load on Lambda.
|
|
25
|
+
Building the layer now requires Docker.
|
|
26
|
+
- The layer is published with `--compatible-architectures x86_64`, matching how the
|
|
27
|
+
extensions are built.
|
|
28
|
+
- `cold_start` in log lines was `true` on every invocation: `cold_start?` did
|
|
29
|
+
`@cold_start ||= true`, which turned `false` back into `true`. Cold start is now keyed
|
|
30
|
+
to the first invocation's request id, so every log line in that invocation says `true`
|
|
31
|
+
and later invocations say `false`. The `ColdStart` metric fires on the cold invocation
|
|
32
|
+
even when the handler logged first (previously the first log line used up the flag).
|
|
33
|
+
`LambdaLoadout.cold_start?` takes an optional context; `LambdaLoadout.reset_cold_start!`
|
|
34
|
+
clears the state for tests.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## [0.0.3] - 2026-10-23
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
- Ruby 4.0 support. CI now tests Ruby 3.2, 3.3, 3.4 and 4.0.
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
- Declare `logger` as a runtime dependency. `logger` is a bundled (not default) gem
|
|
44
|
+
in Ruby 4.0, so under Bundler `require 'logger'` only resolves if the gem is in the
|
|
45
|
+
bundle. It worked before because `aws-sdk-core` depends on `logger` transitively;
|
|
46
|
+
now we don't rely on that.
|
|
47
|
+
|
|
48
|
+
### Notes
|
|
49
|
+
- The Lambda layer (`rake layer:build` / `layer:publish`) still targets `ruby3.4`.
|
|
50
|
+
Apps that bundle the gem (including all Belt apps) are unaffected.
|
|
51
|
+
|
|
10
52
|
## [0.0.1] - 2026-06-09
|
|
11
53
|
|
|
12
54
|
### Added
|
|
@@ -46,5 +88,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
46
88
|
- GitHub Actions CI (test matrix Ruby 3.2/3.3/3.4, lint, security, auto-tag release)
|
|
47
89
|
- Comprehensive documentation and examples
|
|
48
90
|
|
|
49
|
-
[Unreleased]: https://github.com/stowzilla/lambda-loadout/compare/v0.0.
|
|
91
|
+
[Unreleased]: https://github.com/stowzilla/lambda-loadout/compare/v0.0.4...HEAD
|
|
92
|
+
[0.0.4]: https://github.com/stowzilla/lambda-loadout/compare/v0.0.3...v0.0.4
|
|
50
93
|
[0.0.1]: https://github.com/stowzilla/lambda-loadout/releases/tag/v0.0.1
|
data/README.md
CHANGED
|
@@ -366,7 +366,11 @@ bundle exec rake layer:publish
|
|
|
366
366
|
bundle exec rake layer:clean
|
|
367
367
|
```
|
|
368
368
|
|
|
369
|
-
|
|
369
|
+
`layer:build` needs Docker. It installs the gem inside the AWS SAM build image for each supported runtime, so native extensions (`json`, `bigdecimal`) are compiled for Lambda instead of your machine.
|
|
370
|
+
|
|
371
|
+
One layer version works on both `ruby3.4` and `ruby4.0`. Each runtime only loads layer gems from its own directory (`/opt/ruby/gems/3.4.0` or `/opt/ruby/gems/4.0.0`), so the zip contains both. Moving a function from 3.4 to 4.0 doesn't require a new layer ARN. The layer is x86_64 only.
|
|
372
|
+
|
|
373
|
+
After publishing, add the returned `LayerVersionArn` to your Lambda function configuration.
|
|
370
374
|
|
|
371
375
|
### Shell Scripts (alternative)
|
|
372
376
|
|
|
@@ -239,7 +239,7 @@ module LambdaLoadout
|
|
|
239
239
|
'function_version' => @lambda_context.function_version,
|
|
240
240
|
'function_memory_size' => @lambda_context.memory_limit_in_mb,
|
|
241
241
|
'function_request_id' => @lambda_context.aws_request_id,
|
|
242
|
-
'cold_start' => LambdaLoadout.cold_start?
|
|
242
|
+
'cold_start' => LambdaLoadout.cold_start?(@lambda_context)
|
|
243
243
|
}.compact
|
|
244
244
|
rescue StandardError
|
|
245
245
|
{}
|
|
@@ -151,7 +151,7 @@ module LambdaLoadout
|
|
|
151
151
|
# @return [void]
|
|
152
152
|
def add_cold_start_metric(context)
|
|
153
153
|
return if @cold_start_captured
|
|
154
|
-
return unless LambdaLoadout.cold_start?
|
|
154
|
+
return unless LambdaLoadout.cold_start?(context)
|
|
155
155
|
|
|
156
156
|
@cold_start_captured = true
|
|
157
157
|
|
data/lib/lambda_loadout.rb
CHANGED
|
@@ -91,11 +91,32 @@ module LambdaLoadout
|
|
|
91
91
|
|
|
92
92
|
# Get cold start status
|
|
93
93
|
#
|
|
94
|
+
# With a Lambda context, the first invocation this process sees is the cold
|
|
95
|
+
# start, and every call made during that invocation returns true; later
|
|
96
|
+
# invocations return false. Without a context it answers true exactly once.
|
|
97
|
+
#
|
|
98
|
+
# @param context [Object, nil] Lambda context
|
|
94
99
|
# @return [Boolean] true if this is a cold start
|
|
95
|
-
def self.cold_start?
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
def self.cold_start?(context = nil)
|
|
101
|
+
request_id = context.aws_request_id if context.respond_to?(:aws_request_id)
|
|
102
|
+
return consume_cold_start unless request_id
|
|
103
|
+
|
|
104
|
+
@cold_start_request_id ||= request_id
|
|
105
|
+
@cold_start_request_id == request_id
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Forget cold start state, so the next invocation counts as cold again
|
|
109
|
+
#
|
|
110
|
+
# @return [void]
|
|
111
|
+
def self.reset_cold_start!
|
|
112
|
+
@cold_start_request_id = nil
|
|
113
|
+
@cold_start_consumed = false
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def self.consume_cold_start
|
|
117
|
+
return false if @cold_start_consumed || @cold_start_request_id
|
|
118
|
+
|
|
119
|
+
@cold_start_consumed = true
|
|
100
120
|
end
|
|
121
|
+
private_class_method :consume_cold_start
|
|
101
122
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lambda_loadout
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Davis
|
|
@@ -27,16 +27,36 @@ dependencies:
|
|
|
27
27
|
name: json
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
|
-
- - "
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2'
|
|
33
|
+
- - "<"
|
|
31
34
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
35
|
+
version: '4'
|
|
33
36
|
type: :runtime
|
|
34
37
|
prerelease: false
|
|
35
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
39
|
requirements:
|
|
37
|
-
- - "
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '2'
|
|
43
|
+
- - "<"
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '4'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: logger
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '1.4'
|
|
53
|
+
type: :runtime
|
|
54
|
+
prerelease: false
|
|
55
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
38
58
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '
|
|
59
|
+
version: '1.4'
|
|
40
60
|
- !ruby/object:Gem::Dependency
|
|
41
61
|
name: rake
|
|
42
62
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -85,14 +105,14 @@ dependencies:
|
|
|
85
105
|
requirements:
|
|
86
106
|
- - "~>"
|
|
87
107
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '
|
|
108
|
+
version: '1.2'
|
|
89
109
|
type: :development
|
|
90
110
|
prerelease: false
|
|
91
111
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
112
|
requirements:
|
|
93
113
|
- - "~>"
|
|
94
114
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '
|
|
115
|
+
version: '1.2'
|
|
96
116
|
description: Structured logging, CloudWatch metrics (EMF), error handling, and alerting
|
|
97
117
|
for AWS Lambda functions. Implement serverless best practices with minimal overhead.
|
|
98
118
|
email:
|