newrelic-lambda-cli 0.9.16__tar.gz → 0.9.18__tar.gz
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.
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/PKG-INFO +7 -1
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/README.md +6 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/cli/layers.py +41 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/layers.py +134 -33
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/subscriptions.py +8 -2
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/types.py +5 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli.egg-info/PKG-INFO +7 -1
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/setup.py +1 -1
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/tests/test_layers.py +691 -21
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/CODE_OF_CONDUCT.md +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/CONTRIBUTING.md +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/LICENSE +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/MANIFEST.in +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/THIRD_PARTY_NOTICES.md +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/__init__.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/api.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/apm.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/cli/__init__.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/cli/apm.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/cli/decorators.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/cli/functions.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/cli/integrations.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/cli/otel_ingestions.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/cli/subscriptions.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/cliutils.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/functions.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/integrations.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/otel_ingestions.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/permissions.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/templates/import-template.yaml +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/templates/license-key-secret.yaml +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/templates/nr-lambda-integration-role.yaml +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/utils.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli.egg-info/SOURCES.txt +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli.egg-info/dependency_links.txt +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli.egg-info/entry_points.txt +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli.egg-info/not-zip-safe +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli.egg-info/requires.txt +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli.egg-info/top_level.txt +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/pyproject.toml +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/setup.cfg +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/tests/test_api.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/tests/test_functions.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/tests/test_integrations.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/tests/test_new_relic_gql.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/tests/test_permissions.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/tests/test_subscriptions.py +0 -0
- {newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: newrelic-lambda-cli
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.18
|
|
4
4
|
Summary: A CLI to install the New Relic AWS Lambda integration and layers.
|
|
5
5
|
Home-page: https://github.com/newrelic/newrelic-lambda-cli
|
|
6
6
|
Author: New Relic
|
|
@@ -208,6 +208,8 @@ newrelic-lambda layers install \
|
|
|
208
208
|
| `--disable-extension-function-logs` or `--disable-function-logs` | No | Disable sending Lambda function logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension).|
|
|
209
209
|
| `--send-extension-logs` | No | Enable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |
|
|
210
210
|
| `--disable-extension-logs` | No | Disable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension).|
|
|
211
|
+
| `--send-platform-logs` | No | Enable sending Lambda platform logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Sets `NEW_RELIC_EXTENSION_SEND_PLATFORM_LOGS` to `true`. Disabled by default. |
|
|
212
|
+
| `--disable-platform-logs` | No | Disable sending Lambda platform logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Sets `NEW_RELIC_EXTENSION_SEND_PLATFORM_LOGS` to `false`. |
|
|
211
213
|
| `--aws-profile` or `-p` | No | The AWS profile to use for this command. Can also use `AWS_PROFILE`. Will also check `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables if not using AWS CLI. |
|
|
212
214
|
| `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
|
|
213
215
|
| `--nr-api-key` or `-k` | No | Your [New Relic User API Key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key). Can also use the `NEW_RELIC_API_KEY` environment variable. Only used if `--enable-extension` is set and there is no New Relic license key in AWS Secrets Manager. |
|
|
@@ -216,7 +218,11 @@ newrelic-lambda layers install \
|
|
|
216
218
|
| `--nr-env-delimite` | No | Set `NR_ENV_DELIMITER` environment variable for your Lambda Function |
|
|
217
219
|
| `--nr-tags` | No | Set `NR_TAGS` environment variable for your Lambda Function |
|
|
218
220
|
| `--java_handler_method` or `-j` | No | For java runtimes only to specify an aws implementation method. Defaults to RequestHandler. Optional inputs are: handleRequest, handleStreamsRequest `--java_handler_method handleStreamsRequest`. |
|
|
221
|
+
| `--java-agent` | No | For Java runtimes only (`java17`, `java21`). Attaches the New Relic Java Agent layer (`NewRelicAgentJava`) instead of the default OpenTracing layer. Sets `AWS_LAMBDA_EXEC_WRAPPER=/opt/newrelic-java-handler` and leaves the function handler unchanged. Use `--java-agent true` to enable. |
|
|
219
222
|
| `--esm` | No | For Node.js functions using ES Modules (ESM), enable the specific ESM wrapper during installation (e.g., using the --esm flag). This sets the Lambda handler to `/opt/nodejs/node_modules/newrelic-esm-lambda-wrapper/index.handler`. |
|
|
223
|
+
| `--extension-logs-enabled` | No | Set `NEW_RELIC_EXTENSION_LOGS_ENABLED=true` to enable `[NR_EXT]` extension log output in CloudWatch. This is the default extension behaviour.|
|
|
224
|
+
| `--extension-logs-disabled` | No | Set `NEW_RELIC_EXTENSION_LOGS_ENABLED=false` to suppress `[NR_EXT]` extension log output in CloudWatch. |
|
|
225
|
+
| `--app-name` | No | Set the `NEW_RELIC_APP_NAME` environment variable on instrumented functions. If a different value is passed during an upgrade (`--upgrade`), the existing `NEW_RELIC_APP_NAME` will be updated to the new value. |
|
|
220
226
|
|
|
221
227
|
#### Uninstall Layer
|
|
222
228
|
|
|
@@ -182,6 +182,8 @@ newrelic-lambda layers install \
|
|
|
182
182
|
| `--disable-extension-function-logs` or `--disable-function-logs` | No | Disable sending Lambda function logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension).|
|
|
183
183
|
| `--send-extension-logs` | No | Enable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |
|
|
184
184
|
| `--disable-extension-logs` | No | Disable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension).|
|
|
185
|
+
| `--send-platform-logs` | No | Enable sending Lambda platform logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Sets `NEW_RELIC_EXTENSION_SEND_PLATFORM_LOGS` to `true`. Disabled by default. |
|
|
186
|
+
| `--disable-platform-logs` | No | Disable sending Lambda platform logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Sets `NEW_RELIC_EXTENSION_SEND_PLATFORM_LOGS` to `false`. |
|
|
185
187
|
| `--aws-profile` or `-p` | No | The AWS profile to use for this command. Can also use `AWS_PROFILE`. Will also check `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables if not using AWS CLI. |
|
|
186
188
|
| `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
|
|
187
189
|
| `--nr-api-key` or `-k` | No | Your [New Relic User API Key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key). Can also use the `NEW_RELIC_API_KEY` environment variable. Only used if `--enable-extension` is set and there is no New Relic license key in AWS Secrets Manager. |
|
|
@@ -190,7 +192,11 @@ newrelic-lambda layers install \
|
|
|
190
192
|
| `--nr-env-delimite` | No | Set `NR_ENV_DELIMITER` environment variable for your Lambda Function |
|
|
191
193
|
| `--nr-tags` | No | Set `NR_TAGS` environment variable for your Lambda Function |
|
|
192
194
|
| `--java_handler_method` or `-j` | No | For java runtimes only to specify an aws implementation method. Defaults to RequestHandler. Optional inputs are: handleRequest, handleStreamsRequest `--java_handler_method handleStreamsRequest`. |
|
|
195
|
+
| `--java-agent` | No | For Java runtimes only (`java17`, `java21`). Attaches the New Relic Java Agent layer (`NewRelicAgentJava`) instead of the default OpenTracing layer. Sets `AWS_LAMBDA_EXEC_WRAPPER=/opt/newrelic-java-handler` and leaves the function handler unchanged. Use `--java-agent true` to enable. |
|
|
193
196
|
| `--esm` | No | For Node.js functions using ES Modules (ESM), enable the specific ESM wrapper during installation (e.g., using the --esm flag). This sets the Lambda handler to `/opt/nodejs/node_modules/newrelic-esm-lambda-wrapper/index.handler`. |
|
|
197
|
+
| `--extension-logs-enabled` | No | Set `NEW_RELIC_EXTENSION_LOGS_ENABLED=true` to enable `[NR_EXT]` extension log output in CloudWatch. This is the default extension behaviour.|
|
|
198
|
+
| `--extension-logs-disabled` | No | Set `NEW_RELIC_EXTENSION_LOGS_ENABLED=false` to suppress `[NR_EXT]` extension log output in CloudWatch. |
|
|
199
|
+
| `--app-name` | No | Set the `NEW_RELIC_APP_NAME` environment variable on instrumented functions. If a different value is passed during an upgrade (`--upgrade`), the existing `NEW_RELIC_APP_NAME` will be updated to the new value. |
|
|
194
200
|
|
|
195
201
|
#### Uninstall Layer
|
|
196
202
|
|
|
@@ -144,6 +144,16 @@ def register(group):
|
|
|
144
144
|
is_flag=True,
|
|
145
145
|
help="Disable sending Lambda function logs via the New Relic Lambda Extension",
|
|
146
146
|
)
|
|
147
|
+
@click.option(
|
|
148
|
+
"--send-platform-logs",
|
|
149
|
+
is_flag=True,
|
|
150
|
+
help="Enable sending Lambda platform logs via the New Relic Lambda Extension",
|
|
151
|
+
)
|
|
152
|
+
@click.option(
|
|
153
|
+
"--disable-platform-logs",
|
|
154
|
+
is_flag=True,
|
|
155
|
+
help="Disable sending Lambda platform logs via the New Relic Lambda Extension",
|
|
156
|
+
)
|
|
147
157
|
@click.option(
|
|
148
158
|
"--java_handler_method",
|
|
149
159
|
"-j",
|
|
@@ -158,6 +168,37 @@ def register(group):
|
|
|
158
168
|
is_flag=True,
|
|
159
169
|
help="Nodejs runtimes only - nodejs implementation runtime handler to /opt/nodejs/node_modules/newrelic-esm-lambda-wrapper/index.handler",
|
|
160
170
|
)
|
|
171
|
+
@click.option(
|
|
172
|
+
"--extension-logs-enabled",
|
|
173
|
+
"extension_logs_enabled",
|
|
174
|
+
flag_value="true",
|
|
175
|
+
help="Set NEW_RELIC_EXTENSION_LOGS_ENABLED=true to enable [NR_EXT] extension "
|
|
176
|
+
"log output in CloudWatch (default extension behaviour)",
|
|
177
|
+
)
|
|
178
|
+
@click.option(
|
|
179
|
+
"--extension-logs-disabled",
|
|
180
|
+
"extension_logs_enabled",
|
|
181
|
+
flag_value="false",
|
|
182
|
+
help="Set NEW_RELIC_EXTENSION_LOGS_ENABLED=false to suppress [NR_EXT] extension "
|
|
183
|
+
"log output in CloudWatch, reducing CloudWatch log volume without affecting "
|
|
184
|
+
"telemetry delivery to New Relic",
|
|
185
|
+
)
|
|
186
|
+
@click.option(
|
|
187
|
+
"--app-name",
|
|
188
|
+
"app_name",
|
|
189
|
+
help="Set the NEW_RELIC_APP_NAME environment variable on instrumented functions. "
|
|
190
|
+
"If a different value is passed during an upgrade (--upgrade), the existing "
|
|
191
|
+
"NEW_RELIC_APP_NAME will be updated to the new value.",
|
|
192
|
+
metavar="<name>",
|
|
193
|
+
default=None,
|
|
194
|
+
)
|
|
195
|
+
@click.option(
|
|
196
|
+
"--java-agent",
|
|
197
|
+
"java_agent",
|
|
198
|
+
default=False,
|
|
199
|
+
type=bool,
|
|
200
|
+
help="Java runtimes only - Use New Relic Java Agent layer (sets AWS_LAMBDA_EXEC_WRAPPER, keeps original handler)",
|
|
201
|
+
)
|
|
161
202
|
@click.pass_context
|
|
162
203
|
def install(ctx, **kwargs):
|
|
163
204
|
"""Install New Relic AWS Lambda Layers"""
|
|
@@ -17,9 +17,13 @@ from newrelic_lambda_cli.utils import catch_boto_errors
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
NEW_RELIC_ENV_VARS = (
|
|
20
|
+
"AWS_LAMBDA_EXEC_WRAPPER",
|
|
20
21
|
"NEW_RELIC_ACCOUNT_ID",
|
|
22
|
+
"NEW_RELIC_APP_NAME",
|
|
23
|
+
"NEW_RELIC_EXTENSION_LOGS_ENABLED",
|
|
21
24
|
"NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS",
|
|
22
25
|
"NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS",
|
|
26
|
+
"NEW_RELIC_EXTENSION_SEND_PLATFORM_LOGS",
|
|
23
27
|
"NEW_RELIC_LAMBDA_EXTENSION_ENABLED",
|
|
24
28
|
"NEW_RELIC_LAMBDA_HANDLER",
|
|
25
29
|
"NEW_RELIC_LICENSE_KEY",
|
|
@@ -55,10 +59,20 @@ def layer_selection(
|
|
|
55
59
|
existing_layer_arn=None,
|
|
56
60
|
slim=False,
|
|
57
61
|
):
|
|
62
|
+
layer_options = [
|
|
63
|
+
layer["LatestMatchingVersion"]["LayerVersionArn"] for layer in available_layers
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
if slim:
|
|
67
|
+
for arn in layer_options:
|
|
68
|
+
if "-slim:" in arn:
|
|
69
|
+
success("Layer %s selected (slim)" % arn)
|
|
70
|
+
return arn
|
|
71
|
+
|
|
58
72
|
if upgrade and existing_layer_arn:
|
|
59
73
|
base_arn = existing_layer_arn.rsplit(":", 1)[0]
|
|
60
74
|
|
|
61
|
-
for
|
|
75
|
+
for layer in available_layers:
|
|
62
76
|
candidate_arn = layer["LatestMatchingVersion"]["LayerVersionArn"]
|
|
63
77
|
candidate_base_arn = candidate_arn.rsplit(":", 1)[0]
|
|
64
78
|
if candidate_base_arn == base_arn:
|
|
@@ -67,14 +81,6 @@ def layer_selection(
|
|
|
67
81
|
if len(available_layers) == 1:
|
|
68
82
|
return available_layers[0]["LatestMatchingVersion"]["LayerVersionArn"]
|
|
69
83
|
|
|
70
|
-
layer_options = [
|
|
71
|
-
layer["LatestMatchingVersion"]["LayerVersionArn"] for layer in available_layers
|
|
72
|
-
]
|
|
73
|
-
if slim:
|
|
74
|
-
for arn in layer_options:
|
|
75
|
-
if "-slim:" in arn:
|
|
76
|
-
success("Layer %s selected (slim)" % arn)
|
|
77
|
-
return arn
|
|
78
84
|
if sys.stdout.isatty():
|
|
79
85
|
output = "\n".join(
|
|
80
86
|
[
|
|
@@ -124,9 +130,14 @@ def _add_new_relic(input, config, nr_license_key):
|
|
|
124
130
|
handler = config["Configuration"]["Handler"]
|
|
125
131
|
runtime_handler = utils.RUNTIME_CONFIG.get(runtime, {}).get("Handler")
|
|
126
132
|
|
|
133
|
+
use_java_agent = input.java_agent and "java" in runtime
|
|
134
|
+
|
|
127
135
|
if "java" in runtime:
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
if use_java_agent:
|
|
137
|
+
runtime_handler = None
|
|
138
|
+
else:
|
|
139
|
+
postfix = input.java_handler_method or "handleRequest"
|
|
140
|
+
runtime_handler = runtime_handler + postfix
|
|
130
141
|
if "nodejs" in runtime:
|
|
131
142
|
prefix = (
|
|
132
143
|
"/opt/nodejs/node_modules/newrelic-esm-lambda-wrapper/index"
|
|
@@ -141,7 +152,20 @@ def _add_new_relic(input, config, nr_license_key):
|
|
|
141
152
|
if layer["Arn"].startswith(utils.get_arn_prefix(aws_region))
|
|
142
153
|
]
|
|
143
154
|
|
|
144
|
-
|
|
155
|
+
has_log_flags = any(
|
|
156
|
+
[
|
|
157
|
+
input.send_function_logs,
|
|
158
|
+
input.disable_function_logs,
|
|
159
|
+
input.enable_extension_function_logs,
|
|
160
|
+
input.disable_extension_function_logs,
|
|
161
|
+
input.send_extension_logs,
|
|
162
|
+
input.disable_extension_logs,
|
|
163
|
+
input.send_platform_logs,
|
|
164
|
+
input.disable_platform_logs,
|
|
165
|
+
]
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
if not input.upgrade and existing_newrelic_layer and not has_log_flags:
|
|
145
169
|
success(
|
|
146
170
|
"Already installed on function '%s'. Pass --upgrade (or -u) to allow "
|
|
147
171
|
"upgrade or reinstall to latest layer version."
|
|
@@ -164,6 +188,20 @@ def _add_new_relic(input, config, nr_license_key):
|
|
|
164
188
|
# discover compatible layers...
|
|
165
189
|
available_layers = index(aws_region, runtime, architecture)
|
|
166
190
|
|
|
191
|
+
if "java" in runtime:
|
|
192
|
+
if use_java_agent:
|
|
193
|
+
available_layers = [
|
|
194
|
+
l
|
|
195
|
+
for l in available_layers
|
|
196
|
+
if l.get("LayerName", "").lower().startswith("newrelicagent")
|
|
197
|
+
]
|
|
198
|
+
else:
|
|
199
|
+
available_layers = [
|
|
200
|
+
l
|
|
201
|
+
for l in available_layers
|
|
202
|
+
if not l.get("LayerName", "").lower().startswith("newrelicagent")
|
|
203
|
+
]
|
|
204
|
+
|
|
167
205
|
if not available_layers:
|
|
168
206
|
failure(
|
|
169
207
|
"No Lambda layers published for %s (%s) runtime: %s"
|
|
@@ -202,11 +240,32 @@ def _add_new_relic(input, config, nr_license_key):
|
|
|
202
240
|
if runtime_handler:
|
|
203
241
|
update_kwargs["Handler"] = runtime_handler
|
|
204
242
|
|
|
243
|
+
if use_java_agent:
|
|
244
|
+
update_kwargs["Environment"]["Variables"][
|
|
245
|
+
"AWS_LAMBDA_EXEC_WRAPPER"
|
|
246
|
+
] = "/opt/newrelic-java-handler"
|
|
247
|
+
original_handler = update_kwargs["Environment"]["Variables"].pop(
|
|
248
|
+
"NEW_RELIC_LAMBDA_HANDLER", None
|
|
249
|
+
)
|
|
250
|
+
if original_handler:
|
|
251
|
+
update_kwargs["Handler"] = original_handler
|
|
252
|
+
elif "java" in runtime:
|
|
253
|
+
update_kwargs["Environment"]["Variables"].pop("AWS_LAMBDA_EXEC_WRAPPER", None)
|
|
254
|
+
|
|
205
255
|
# Update the account id
|
|
206
256
|
update_kwargs["Environment"]["Variables"]["NEW_RELIC_ACCOUNT_ID"] = str(
|
|
207
257
|
input.nr_account_id
|
|
208
258
|
)
|
|
209
259
|
|
|
260
|
+
if input.app_name:
|
|
261
|
+
update_kwargs["Environment"]["Variables"]["NEW_RELIC_APP_NAME"] = str(
|
|
262
|
+
input.app_name
|
|
263
|
+
)
|
|
264
|
+
success(
|
|
265
|
+
"Successfully set NEW_RELIC_APP_NAME to '%s' for the function"
|
|
266
|
+
% input.app_name
|
|
267
|
+
)
|
|
268
|
+
|
|
210
269
|
# Update the NEW_RELIC_LAMBDA_HANDLER envvars only when it's a new install.
|
|
211
270
|
if runtime_handler and handler != runtime_handler:
|
|
212
271
|
if "nodejs" in runtime:
|
|
@@ -236,11 +295,7 @@ def _add_new_relic(input, config, nr_license_key):
|
|
|
236
295
|
"NEW_RELIC_LAMBDA_EXTENSION_ENABLED"
|
|
237
296
|
] = "true"
|
|
238
297
|
|
|
239
|
-
if
|
|
240
|
-
update_kwargs["Environment"]["Variables"][
|
|
241
|
-
"NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
|
|
242
|
-
] = "false"
|
|
243
|
-
elif input.enable_extension_function_logs or input.send_function_logs:
|
|
298
|
+
if input.enable_extension_function_logs or input.send_function_logs:
|
|
244
299
|
update_kwargs["Environment"]["Variables"][
|
|
245
300
|
"NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
|
|
246
301
|
] = "true"
|
|
@@ -254,12 +309,12 @@ def _add_new_relic(input, config, nr_license_key):
|
|
|
254
309
|
success(
|
|
255
310
|
"Successfully disabled NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS tag to the function"
|
|
256
311
|
)
|
|
257
|
-
|
|
258
|
-
if not input.upgrade:
|
|
312
|
+
elif not input.upgrade:
|
|
259
313
|
update_kwargs["Environment"]["Variables"][
|
|
260
|
-
"
|
|
314
|
+
"NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
|
|
261
315
|
] = "false"
|
|
262
|
-
|
|
316
|
+
|
|
317
|
+
if input.send_extension_logs:
|
|
263
318
|
update_kwargs["Environment"]["Variables"][
|
|
264
319
|
"NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
|
|
265
320
|
] = "true"
|
|
@@ -273,6 +328,42 @@ def _add_new_relic(input, config, nr_license_key):
|
|
|
273
328
|
success(
|
|
274
329
|
"Successfully disabled NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS tag to the function"
|
|
275
330
|
)
|
|
331
|
+
elif not input.upgrade:
|
|
332
|
+
update_kwargs["Environment"]["Variables"][
|
|
333
|
+
"NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
|
|
334
|
+
] = "false"
|
|
335
|
+
|
|
336
|
+
if input.send_platform_logs:
|
|
337
|
+
update_kwargs["Environment"]["Variables"][
|
|
338
|
+
"NEW_RELIC_EXTENSION_SEND_PLATFORM_LOGS"
|
|
339
|
+
] = "true"
|
|
340
|
+
success(
|
|
341
|
+
"Successfully enabled NEW_RELIC_EXTENSION_SEND_PLATFORM_LOGS tag to the function"
|
|
342
|
+
)
|
|
343
|
+
elif input.disable_platform_logs:
|
|
344
|
+
update_kwargs["Environment"]["Variables"][
|
|
345
|
+
"NEW_RELIC_EXTENSION_SEND_PLATFORM_LOGS"
|
|
346
|
+
] = "false"
|
|
347
|
+
success(
|
|
348
|
+
"Successfully disabled NEW_RELIC_EXTENSION_SEND_PLATFORM_LOGS tag to the function"
|
|
349
|
+
)
|
|
350
|
+
elif not input.upgrade:
|
|
351
|
+
update_kwargs["Environment"]["Variables"][
|
|
352
|
+
"NEW_RELIC_EXTENSION_SEND_PLATFORM_LOGS"
|
|
353
|
+
] = "false"
|
|
354
|
+
|
|
355
|
+
if input.extension_logs_enabled is not None:
|
|
356
|
+
update_kwargs["Environment"]["Variables"][
|
|
357
|
+
"NEW_RELIC_EXTENSION_LOGS_ENABLED"
|
|
358
|
+
] = input.extension_logs_enabled
|
|
359
|
+
if input.extension_logs_enabled == "true":
|
|
360
|
+
success(
|
|
361
|
+
"Successfully enabled NEW_RELIC_EXTENSION_LOGS_ENABLED for the function"
|
|
362
|
+
)
|
|
363
|
+
else:
|
|
364
|
+
success(
|
|
365
|
+
"Successfully disabled NEW_RELIC_EXTENSION_LOGS_ENABLED for the function"
|
|
366
|
+
)
|
|
276
367
|
|
|
277
368
|
if input.nr_tags:
|
|
278
369
|
update_kwargs["Environment"]["Variables"]["NR_TAGS"] = input.nr_tags
|
|
@@ -461,19 +552,29 @@ def _remove_new_relic(input, config):
|
|
|
461
552
|
|
|
462
553
|
handler = config["Configuration"]["Handler"]
|
|
463
554
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
555
|
+
is_java_agent = (
|
|
556
|
+
"java" in runtime
|
|
557
|
+
and config["Configuration"]
|
|
558
|
+
.get("Environment", {})
|
|
559
|
+
.get("Variables", {})
|
|
560
|
+
.get("AWS_LAMBDA_EXEC_WRAPPER")
|
|
561
|
+
== "/opt/newrelic-java-handler"
|
|
562
|
+
)
|
|
468
563
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
564
|
+
if not is_java_agent:
|
|
565
|
+
# For java runtimes we need to remove the method name before
|
|
566
|
+
# validating because method names are variable
|
|
567
|
+
if "java" in runtime:
|
|
568
|
+
handler = handler.split("::", 1)[0] + "::"
|
|
569
|
+
|
|
570
|
+
# Detect non-New Relic handler and error if necessary.
|
|
571
|
+
if not utils.is_valid_handler(runtime, handler):
|
|
572
|
+
failure(
|
|
573
|
+
"New Relic installation (via layers) not auto-detected for the specified "
|
|
574
|
+
"function '%s'. Unrecognized handler in deployed function."
|
|
575
|
+
% config["Configuration"]["FunctionArn"]
|
|
576
|
+
)
|
|
577
|
+
return False
|
|
477
578
|
|
|
478
579
|
env_handler = (
|
|
479
580
|
config["Configuration"]
|
{newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli/subscriptions.py
RENAMED
|
@@ -133,7 +133,10 @@ def create_log_subscription(input, function_name):
|
|
|
133
133
|
"Found log subscription for '%s', verifying configuration" % function_name
|
|
134
134
|
)
|
|
135
135
|
newrelic_filter = newrelic_filters[0]
|
|
136
|
-
if
|
|
136
|
+
if (
|
|
137
|
+
newrelic_filter["filterPattern"] != input.filter_pattern
|
|
138
|
+
or newrelic_filter["destinationArn"] != destination_arn
|
|
139
|
+
):
|
|
137
140
|
return _remove_subscription_filter(
|
|
138
141
|
input.session, function_name, newrelic_filter["filterName"]
|
|
139
142
|
) and _create_subscription_filter(
|
|
@@ -189,7 +192,10 @@ def create_otel_log_subscription(input, function_name):
|
|
|
189
192
|
"Found log subscription for '%s', verifying configuration" % function_name
|
|
190
193
|
)
|
|
191
194
|
newrelic_filter = newrelic_filters[0]
|
|
192
|
-
if
|
|
195
|
+
if (
|
|
196
|
+
newrelic_filter["filterPattern"] != input.filter_pattern
|
|
197
|
+
or newrelic_filter["destinationArn"] != destination_arn
|
|
198
|
+
):
|
|
193
199
|
return _remove_subscription_filter(
|
|
194
200
|
input.session, function_name, newrelic_filter["filterName"]
|
|
195
201
|
) and _create_subscription_filter(
|
|
@@ -115,9 +115,14 @@ LAYER_INSTALL_KEYS = [
|
|
|
115
115
|
"disable_function_logs",
|
|
116
116
|
"send_extension_logs",
|
|
117
117
|
"disable_extension_logs",
|
|
118
|
+
"send_platform_logs",
|
|
119
|
+
"disable_platform_logs",
|
|
118
120
|
"java_handler_method",
|
|
121
|
+
"java_agent",
|
|
119
122
|
"esm",
|
|
120
123
|
"slim",
|
|
124
|
+
"extension_logs_enabled",
|
|
125
|
+
"app_name",
|
|
121
126
|
]
|
|
122
127
|
|
|
123
128
|
LAYER_UNINSTALL_KEYS = [
|
{newrelic_lambda_cli-0.9.16 → newrelic_lambda_cli-0.9.18}/newrelic_lambda_cli.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: newrelic-lambda-cli
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.18
|
|
4
4
|
Summary: A CLI to install the New Relic AWS Lambda integration and layers.
|
|
5
5
|
Home-page: https://github.com/newrelic/newrelic-lambda-cli
|
|
6
6
|
Author: New Relic
|
|
@@ -208,6 +208,8 @@ newrelic-lambda layers install \
|
|
|
208
208
|
| `--disable-extension-function-logs` or `--disable-function-logs` | No | Disable sending Lambda function logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension).|
|
|
209
209
|
| `--send-extension-logs` | No | Enable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |
|
|
210
210
|
| `--disable-extension-logs` | No | Disable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension).|
|
|
211
|
+
| `--send-platform-logs` | No | Enable sending Lambda platform logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Sets `NEW_RELIC_EXTENSION_SEND_PLATFORM_LOGS` to `true`. Disabled by default. |
|
|
212
|
+
| `--disable-platform-logs` | No | Disable sending Lambda platform logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Sets `NEW_RELIC_EXTENSION_SEND_PLATFORM_LOGS` to `false`. |
|
|
211
213
|
| `--aws-profile` or `-p` | No | The AWS profile to use for this command. Can also use `AWS_PROFILE`. Will also check `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables if not using AWS CLI. |
|
|
212
214
|
| `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
|
|
213
215
|
| `--nr-api-key` or `-k` | No | Your [New Relic User API Key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key). Can also use the `NEW_RELIC_API_KEY` environment variable. Only used if `--enable-extension` is set and there is no New Relic license key in AWS Secrets Manager. |
|
|
@@ -216,7 +218,11 @@ newrelic-lambda layers install \
|
|
|
216
218
|
| `--nr-env-delimite` | No | Set `NR_ENV_DELIMITER` environment variable for your Lambda Function |
|
|
217
219
|
| `--nr-tags` | No | Set `NR_TAGS` environment variable for your Lambda Function |
|
|
218
220
|
| `--java_handler_method` or `-j` | No | For java runtimes only to specify an aws implementation method. Defaults to RequestHandler. Optional inputs are: handleRequest, handleStreamsRequest `--java_handler_method handleStreamsRequest`. |
|
|
221
|
+
| `--java-agent` | No | For Java runtimes only (`java17`, `java21`). Attaches the New Relic Java Agent layer (`NewRelicAgentJava`) instead of the default OpenTracing layer. Sets `AWS_LAMBDA_EXEC_WRAPPER=/opt/newrelic-java-handler` and leaves the function handler unchanged. Use `--java-agent true` to enable. |
|
|
219
222
|
| `--esm` | No | For Node.js functions using ES Modules (ESM), enable the specific ESM wrapper during installation (e.g., using the --esm flag). This sets the Lambda handler to `/opt/nodejs/node_modules/newrelic-esm-lambda-wrapper/index.handler`. |
|
|
223
|
+
| `--extension-logs-enabled` | No | Set `NEW_RELIC_EXTENSION_LOGS_ENABLED=true` to enable `[NR_EXT]` extension log output in CloudWatch. This is the default extension behaviour.|
|
|
224
|
+
| `--extension-logs-disabled` | No | Set `NEW_RELIC_EXTENSION_LOGS_ENABLED=false` to suppress `[NR_EXT]` extension log output in CloudWatch. |
|
|
225
|
+
| `--app-name` | No | Set the `NEW_RELIC_APP_NAME` environment variable on instrumented functions. If a different value is passed during an upgrade (`--upgrade`), the existing `NEW_RELIC_APP_NAME` will be updated to the new value. |
|
|
220
226
|
|
|
221
227
|
#### Uninstall Layer
|
|
222
228
|
|
|
@@ -6,7 +6,7 @@ README = open(os.path.join(os.path.dirname(__file__), "README.md"), "r").read()
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name="newrelic-lambda-cli",
|
|
9
|
-
version="0.9.
|
|
9
|
+
version="0.9.18",
|
|
10
10
|
python_requires=">=3.3",
|
|
11
11
|
description="A CLI to install the New Relic AWS Lambda integration and layers.",
|
|
12
12
|
long_description=README,
|