Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 73f343c

Browse files
authored
feat(index.js): add support for general wrapper (#99)
1 parent e8a5bfb commit 73f343c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Available options:
102102
|`ignoredKeys` |Optional |`-` |May contain strings (will perform a loose match, so that First Name also matches first_name) |
103103
|`urlsToIgnore` |Optional |`-` |Ignore HTTP calls to specific domains |
104104
|`labels` |Optional |`[]` |Global labels applied to all traces. For example "[['key', 'val']]". (Not available for Python) |
105+
|`wrapper`|Optional |`lambda_wrapper/lambdaWrapper` - The wrapper to use to wrap this function. See [wrappers](#wrappers)| |
105106

106107
### Function Level Options
107108
These options are defined at the function level, under the `epsagon` member of your function in the `serverless.yml` file.
@@ -131,10 +132,12 @@ Available options:
131132
* `lambda_wrapper` - regular lambda wrapper
132133
* `step_lambda_wrapper` - Used to wrap step functions
133134
* `python_wrapper` - Used to wrap regular Python functions (doesn't have to run on Lambda)
135+
* `tencent_function_wrapper` - Wrapper for Tencent Cloud Serverless Cloud Functions
134136
* Node.js functions:
135137
* `lambdaWrapper` - regular lambda wrapper
136138
* `stepLambdaWrapper` - Used to wrap step functions
137139
* `nodeWrapper` - Used to wrap regular Node functions (doesn't have to run on Lambda)
140+
* `tencentFunctionWrapper` - Wrapper for Tencent Cloud Serverless Cloud Functions
138141

139142
## Troubleshooting
140143

src/index.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export default class ServerlessEpsagonPlugin {
9393
ignoredKeys: { type: 'string' },
9494
urlsToIgnore: { type: 'string' },
9595
labels: { type: 'string' },
96+
wrapper: { type: 'string' },
9697
},
9798
additionalProperties: false,
9899
},
@@ -221,7 +222,7 @@ export default class ServerlessEpsagonPlugin {
221222
return result;
222223
}
223224

224-
const language = SUPPORTED_LANGUAGES.find((lang => runtime.match(lang)));
225+
const language = SUPPORTED_LANGUAGES.find((lang => runtime.toLowerCase().match(lang)));
225226
if (!language) {
226227
this.log(`Runtime "${runtime}" is not supported yet, skipping function ${key}`);
227228
return result;
@@ -254,6 +255,14 @@ export default class ServerlessEpsagonPlugin {
254255
}
255256
}
256257
await Promise.all(this.funcs.map(async (func) => {
258+
if (this.config().wrapper) {
259+
if (!func.epsagon) {
260+
// eslint-disable-next-line no-param-reassign
261+
func.epsagon = {};
262+
}
263+
// eslint-disable-next-line no-param-reassign
264+
func.epsagon.wrapper = this.config().wrapper;
265+
}
257266
const handlerCode = generateWrapperCode(func, this.config());
258267
await writeFile(
259268
join(

0 commit comments

Comments
 (0)