Coder Social home page Coder Social logo

serverless-oneagent's Introduction

Dynatrace
OneAgent Serverless plugin


Depreciation note

Starting with Dynatrace OneAgent 1.207, Dynatrace offers a dedicated AWS Lambda layer to monitor Node.js based AWS Lambda functions. Please review the Dynatrace product news and documentation to learn more.

The new OneAgent deployment scheme voids the necessity of OneAgent Serverless plugin and its development and support will therefore be discontinued.


dynatrace-oneagent is a plugin for serverless framework which will add Dynatrace monitoring automatically to serverless deployments.

Disclaimer

This plugin is community contributed and not officially supported by Dynatrace. In case of problems, feature requests, or questions submit a ticket on GitHub

Configuration

The Dynatrace OneAgent serverless plugin will configure serverless and serverless-webpack to bundle Dynatrace npm module for PaaS.

In regular serverless projects, the plugin will npm install and tailor Dynatrace npm module for PaaS during serverless packaging process. It will also reconfigure the function handler definition to load Dynatrace OneAgent at function instance startup.

In serverless-webpack case, the plugin will configure webpack to include Dynatrace npm module for PaaS into the bundle. The resulting deployment zip file will contain the Javascript file for the handler function and a node_modules folder with Dynatrace OneAgent.

Enabling your serverless project for Dynatrace OneAgent is a two steps process:

  1. add plugin to serverless.yml
  2. specify OneAgent options

Add plugin to serverless.yml

Extend the plugins list of the projects serverless.yml file with @dynatrace/serverless-oneagent plugin.

service: dynatrace-oneagent-sample

plugins:
  - '@dynatrace/serverless-oneagent'

provider:
  name: aws
  runtime: nodejs10.x

functions:
  hello:
    handler: index.hello
    events:
      - http:
          method: GET
          path: hello

Specify OneAgent options

OneAgent options can be specified in serverless.yml file or serverless (sls) command line.

The option string can be obtained from serverless configuration screen (Deploy Dynatrace > Setup Serverless integration).

Add following to serverless.yml:

custom:
  serverless-oneagent:
    options: '{"server":"...","tenant":"...", "tenanttoken":"..."}'

If you do not want to add OneAgent options to the serverless.yml , the options can be specified as a command line argument to serverless (sls) command.

serverless deploy --dt-oneagent-options='{"dynatraceTagPropertyPath":"headers.x-dynatrace","server":"...","tenant":"...","tenanttoken":"..."}'

Options summary

serverless.yml command line description
options --dt-oneagent-options=<option string> Specifies OneAgent options
npmModuleVersion --dt-oneagent-module-version=<version> Specifies the version of OneAgent for PaaS module. Default is latest, specify next for @next version.
verbose --verbose enables extended output of plugin processing. --verbose enables verbose mode for all plugins, while verbose option in serverless.yml enables verbose output for this plugin only.
exclude --dt-exclude exclude given list of functions from instrumentation. Separate function names with comma on command line.
skipUninstall --dt-skip-uninstall de-installation of @dynatrace/oneagent module after packaging might interfere with alternative dependency management tools like lerna. This option suppresses the de-installation of @dynatrace/oneagent npm module.
...
functions:
  lambdaTest1:
    handler: test/first.handler

  lambdaTest2:
    handler: test/second.handler
...
custom:
  serverless-oneagent:
    # enable serverless-oneagent plugin verbose mode
    verbose: true
    # specify @next Dynatrace OneAgent npm module
    npmModuleVersion: next
    exclude:
      - lambdaTest2
serverless deploy --dt-oneagent-module-version=next --dt-oneagent-options='{"dynatraceTagPropertyPath":"headers.x-dynatrace","server":"...","tenant":"...","tenanttoken":"..."}' --verbose --dt-exclude=lambdaTest2

Yarn configuration

Serverless plugin installs automatically @dynatrace/oneagent dependency at build time which causes a Yarn build error. To work around that build error, manually add @dynatrace/oneagent in the package.json file

e.g.

"dependencies": {
        "@dynatrace/oneagent": "latest"
},
"devDependencies": {
        "@dynatrace/serverless-oneagent": "xxx"
}

Samples

The samples folder contains ready to go serverless projects.

  • AWS Lambda with Node.js runtime serverless
  • AWS Lambda with Node.js runtime and serverless-webpack serverless

Supported provider and runtime environments

  • The current plugin version supports following deployments
    • AWS Lambda with Node.js runtime version 8.x, 10.x and 12.x

Support

In case of problems, feature requests, or questions submit a ticket.

serverless-oneagent's People

Contributors

charanroot avatar ddprrt avatar dtphilippraab avatar dyladan avatar hollerberg avatar ingohackl avatar tcarrio avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

serverless-oneagent's Issues

serverless-onagent && OpenTelemetry

Where will serverless framework OpenTelemetry support be added here?
Has work started on the serverless framework plugin for dynatrace opentelemetry?

Best,
/jhd

serverless monitoring

hi

i have servelress framework called openfaas and with lot of functions and i started installing the Dyantrace as we use dynatrace for all monitoring. .
i am getting errors installing on our serveless. do you have any proper documentation steps for installing the agent . My current setup is kubernetes and serverlss runs on top of it as containers ?

Data from Lambda not reaching Dynatrace

After implementing the serverless-oneagent plugin and deploying the data never shows up in the Dynatrace UI. Upon looking at the lambda logs the following warning is present

2019-01-08 00:28:41.633 UTC [6b4d089f] info [native] Server/Collector ............ http://localhost:8020/communication
2019-01-08 00:28:41.634 UTC [6b4d089f] info [native] URL http://localhost:8020/communication not working (Failed to connect to localhost port 8020: Connection refused)

It looks like the plugin isn't picking up the server value that we're providing via the DT_LAMBDA_OPTIONS.

I've tried a few variations of providing the options but all had the same result (localhost):

  • SSM with SecureString in custom/serverless-oneagent/options
  • SSM in Environment Variables (like this)
  • sls deploy with --dt-options
  • Hard-coded in serverless.yml in custom/serverless-oneagent/options

Currently using versions:

  • "@dynatrace/oneagent": "1.157.186-1.0.0",
  • "@dynatrace/serverless-oneagent": "1.0.5"

Serverless and Dynatrace Integration not working with internal folder structures

I am trying to integrate Dynatrace with Serverless Webpack Node 10.x and facing weird issue folder structures.

my current structure is app/src/handler/handler.ts file

Cloud formation template for Handler is
"Handler": "node_modules/@dynatrace/oneagent/index.src/handler/HealthHandler$health",

{
    "errorType": "Runtime.MalformedHandlerName",
    "errorMessage": "Bad handler",
    "stack": [
        "Runtime.MalformedHandlerName: Bad handler",
        "    at _splitHandlerString (/var/runtime/UserFunction.js:43:11)",
        "    at Object.module.exports.load (/var/runtime/UserFunction.js:138:31)",
        "    at Object.<anonymous> (/var/runtime/index.js:45:30)",
        "    at Module._compile (internal/modules/cjs/loader.js:778:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)",
        "    at Module.load (internal/modules/cjs/loader.js:653:32)",
        "    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:585:3)",
        "    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)",
        "    at startup (internal/bootstrap/node.js:283:19)"
    ]
}

if I change my handler to top-level and it's working fine
Updated structure is app/handler.ts file

Cloud formation template for Handler is
"Handler": "node_modules/@dynatrace/oneagent/index.HealthHandler$health",

AWS lambda strictly checks the total path in Node 10.x version. if the path is wrong it will throw an error.
https://gist.github.com/brianleroux/26e4d9795350047c6ae2efcbe57e1291#file-userfunction-js-L40.

Thanks.

"@dynatrace/oneagent" may not be added to forcedIncludes

if (!forcedIncludes.some((mn) => mn !== this.qualifiedNpmModuleName)) {
this.logVerbose(`adding ${this.qualifiedNpmModuleName} to ${forcedIncludes}`);
forcedIncludes.push(this.qualifiedNpmModuleName);
} else {
this.logVerbose(`adding ${this.qualifiedNpmModuleName} already in ${forcedIncludes}`);
}

I believe this logic has a bug in it that if "@dynatrace/oneagent" is not already in the list it is not added but should be.

Suggestion:

 if (forcedIncludes.includes(this.qualifiedNpmModuleName)) { 
 	this.logVerbose(`adding ${this.qualifiedNpmModuleName} already in ${forcedIncludes}`); 
 } else { 
 	this.logVerbose(`adding ${this.qualifiedNpmModuleName} to ${forcedIncludes}`); 
 	forcedIncludes.push(this.qualifiedNpmModuleName); 
 } 

if Array.prototype.includes cannot be used (pre node 6?) then Array.prototype.some can still be used but the log needs to be slightly different; e.g.:

 if (forcedIncludes.some((mn) => mn === this.qualifiedNpmModuleName)) { 
 	this.logVerbose(`adding ${this.qualifiedNpmModuleName} already in ${forcedIncludes}`); 
 } else { 
 	this.logVerbose(`adding ${this.qualifiedNpmModuleName} to ${forcedIncludes}`); 
 	forcedIncludes.push(this.qualifiedNpmModuleName); 
 } 

Error Removing .webpack

Every time I try to do a serverless deploy with this module included, I get the following error:

  Error --------------------------------------------------
 
  Error: EBUSY: resource busy or locked, rmdir 'C:\source\repos\b2cs\user-services\api\.webpack\dependencies'
      at Object.rmdirSync (fs.js:684:3)
      at rmdirSync (C:\source\repos\b2cs\user-services\api\node_modules\fs-extra\lib\remove\rimraf.js:276:13)
      at rimrafSync (C:\source\repos\b2cs\user-services\api\node_modules\fs-extra\lib\remove\rimraf.js:252:7)
      at options.readdirSync.forEach.f (C:\source\repos\b2cs\user-services\api\node_modules\fs-extra\lib\remove\rimraf.js:291:39)
      at Array.forEach (<anonymous>)
      at rmkidsSync (C:\source\repos\b2cs\user-services\api\node_modules\fs-extra\lib\remove\rimraf.js:291:26)
      at rmdirSync (C:\source\repos\b2cs\user-services\api\node_modules\fs-extra\lib\remove\rimraf.js:281:7)
      at Object.rimrafSync (C:\source\repos\b2cs\user-services\api\node_modules\fs-extra\lib\remove\rimraf.js:252:7)
      at processConfig (C:\source\repos\b2cs\user-services\api\node_modules\serverless-webpack\lib\validate.js:161:13)
      at ServerlessWebpack.validate (C:\source\repos\b2cs\user-services\api\node_modules\serverless-webpack\lib\validate.js:229:14)
      at ServerlessWebpack.tryCatcher (C:\source\repos\b2cs\user-services\api\node_modules\bluebird\js\release\util.js:16:23)
      at Promise._settlePromiseFromHandler (C:\source\repos\b2cs\user-services\api\node_modules\bluebird\js\release\promise.js:517:31)
      at Promise._settlePromise (C:\source\repos\b2cs\user-services\api\node_modules\bluebird\js\release\promise.js:574:18)
      at Promise._settlePromiseCtx (C:\source\repos\b2cs\user-services\api\node_modules\bluebird\js\release\promise.js:611:10)
      at _drainQueueStep (C:\source\repos\b2cs\user-services\api\node_modules\bluebird\js\release\async.js:142:12)
      at _drainQueue (C:\source\repos\b2cs\user-services\api\node_modules\bluebird\js\release\async.js:131:9)
      at Async._drainQueues (C:\source\repos\b2cs\user-services\api\node_modules\bluebird\js\release\async.js:147:5)
      at Immediate.Async.drainQueues [as _onImmediate] (C:\source\repos\b2cs\user-services\api\node_modules\bluebird\js\release\async.js:17:14)
      at runCallback (timers.js:705:18)
      at tryOnImmediate (timers.js:676:5)
      at processImmediate (timers.js:658:5)
      at process.topLevelDomainCallback (domain.js:126:23)
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          win32
     Node Version:              10.16.0
     Framework Version:         1.53.0
     Plugin Version:            3.1.1
     SDK Version:               2.1.1
     Components Core Version:   1.1.1
     Components CLI Version:    1.2.3

I turned on verbose and I think the issue is because it uses this configuration:


Serverless: Using configuration:
{
  "includeModules": {
    "forceInclude": [
      "@dynatrace/oneagent"
    ]
  },
  "webpackConfig": "webpack.config.js",
  "packager": "npm",
  "packagerOptions": {},
  "keepOutputDirectory": false
}

Any way to change keepOutputDirectory to true? And if so, would that fix my issue?

when will this project support node 12+?

We currently have to hold other dependencies (such as a serverless warmup plugin) at a lower version since this project doesn't appear to support anything above node 10. thanks!

Serverless dynatrace - Known issues Handler functions in sub-folders

Hi i am integrating serverless aws using nodejs 10.0 with dynatrace managed. I have followed the documentation and encountered a known error "Handler functions in sub-folders"

image

We found in the documentation that it is a known error "Handler functions in sub-folders" and we applied the indicated recommendation,

link:

https://www.dynatrace.com/support/help/technology-support/cloud-platforms/amazon-web-services/installation/integrate-nodejs-lambda-functions/

apply the settings indicated in the documentation

DT_LAMBDA_HANDLER = lib/index.handler
function definition =_modules/@dynatrace/oneagent/index.handler

shows the following error:

START RequestId: 22d89c65-2c58-4eb0-ad33-9883648e3f89 Version: $LATEST
FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.
1: 0x55fb1f38b1d3 node::Abort() [/var/lang/bin/node]
2: 0x55fb1f38b22f [/var/lang/bin/node]
3: 0x55fb1f5cd309 v8::Utils::ReportApiFailure(char const*, char const*) [/var/lang/bin/node]
4: 0x7f73f914283d [/var/task/node_modules/@dynatrace/oneagent-dependency/agent/bin/1.187.155.20200304-124853/linux-x86-64/oneagentnode_64.node]
5: 0x7f73f91416b5 [/var/task/node_modules/@dynatrace/oneagent-dependency/agent/bin/1.187.155.20200304-124853/linux-x86-64/oneagentnode_64.node]
6: 0x55fb1fb82338 v8::internal::PropertyCallbackArguments::CallNamedGetter(v8::internal::Handlev8::internal::InterceptorInfo, v8::internal::Handlev8::internal::Name) [/var/lang/bin/node]
7: 0x55fb1fb8413b [/var/lang/bin/node]
8: 0x55fb1fbb4d47 v8::internal::Object::GetProperty(v8::internal::LookupIterator*) [/var/lang/bin/node]
9: 0x55fb1fadfe64 v8::internal::LoadIC::Load(v8::internal::Handlev8::internal::Object, v8::internal::Handlev8::internal::Name) [/var/lang/bin/node]
10: 0x55fb1fae02fc v8::internal::KeyedLoadIC::Load(v8::internal::Handlev8::internal::Object, v8::internal::Handlev8::internal::Object) [/var/lang/bin/node]
11: 0x55fb1fae098b v8::internal::Runtime_KeyedLoadIC_Miss(int, v8::internal::Object*, v8::internal::Isolate) [/var/lang/bin/node]
12: 0x2b0973a5be1d
END RequestId: 22d89c65-2c58-4eb0-ad33-9883648e3f89
REPORT RequestId: 22d89c65-2c58-4eb0-ad33-9883648e3f89 Duration: 3414.64 ms Billed Duration: 3500 ms Memory Size: 512 MB Max Memory Used: 69 MB
RequestId: 22d89c65-2c58-4eb0-ad33-9883648e3f89 Error: Runtime exited with error: signal: aborted (core dumped)
Runtime.ExitError

it is possible that it is the agent version, I am using the latest version (1.187.155-1.0.1) maybe this version has some incompatibility, I am thinking of using an older version (1.185.137-1.0.1).

Thanks

semver dependency missing?

We see this error on Lambda about missing semver. When added as a dependency, it works.

Lambda execution failed with status 200 due to customer function error: Error: Cannot find module 'semver'
Require stack:

  • /var/task/node_modules/@dynatrace/oneagent-dependency/agent/bin/1.185.131.20200210-080232/any/nodejs/nodejsagent.js

Automatic `npm uninstall` may fail depending on project tooling

This plugin performs an uninstall of itself using npm by default. This can cause issues with certain tools that manage monorepositories such as lerna. In the case of Lerna, this tooling is not compatible with npm for managing packages due to how it manages internal dependencies of packages, and is a common issue.

Due to this, the serverless-oneagent plugin will fail during the npm uninstall stage.

I would suggest an option in the plugin configuration within serverless.yml and a CLI argument be provided to disable the uninstall stage. This would allow any tooling that may not work with npm to disable the uninstall stage to bypass the issues, while not being vendor-specific.

Lambda functions asynchronous applications

Hello, I have the following case, I have a lambda function that uses an SNS to enqueue a message that is then consumed by another lambda, the image that the architecture is the following

imagen

I have found in the dynatrace documentation a similar example in the following link
https://github.com/Dynatrace/serverless-hotday-2019/tree/master/labs/lab6

Following the documentation I have modified the lambda UE1COMTESTPOCDYNATRACE004 to propagate the Dynatrace tag via SNS metadata, I attach the sources

const DSDK = require('@dynatrace/oneagent-sdk');
const dsdk = DSDK.createInstance();
const tracer = dsdk.traceOutgoingRemoteCall({

        serviceEndpoint: 'SNS',
        serviceMethod: 'publish',
        serviceName: 'POC-DYNATRACE001',
        channelType: DSDK.ChannelType.TCP_IP,
    });
    const dtTag = tracer.getDynatraceStringTag();
    console.log(dtTag);
    console.log("Iniciando envío de mensaje vía SNS")
    var params = {

        Message: JSON.stringify(args),
        MessageAttributes: {
            'x-dynatrace': {
                DataType: 'String',
                StringValue: dtTag,
            },
        },
        TopicArn: process.env.ARN_TOPICO_LEAD
    };
    console.log("Params => ",params)
    return new AWS.SNS({apiVersion: '2010-03-31' }).publish(params).promise()
        .then(resp => {
            console.log("then sns => ",resp)
        })

        .catch(err => {

            console.log("catch sns => ",err)

        })

we have the error that the x-dynatrace is empty
//////////////////////////////////
MessageAttributes: { 'x-dynatrace': { DataType: 'String', StringValue: '' } },
TopicArn: 'arn:aws:sns:us-east-2:477542548955:POC-DYNATRACE001' }
2020-09-30T23:28:47.658Z af63e7a0-243b-4072-9495-755799b17df0 INFO catch sns => { ParameterValueInvalid: The message attribute 'x-dynatrace' must contain non-empty message attribute value for message attribute type 'String'.
at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/query.js:50:29)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:688:14)
at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:690:12)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
message:
'The message attribute 'x-dynatrace' must contain non-empty message attribute value for message attribute type 'String'.',

//////////////////////////////////////

We require your support to resolve the error presented.

Build size increase for exclude functions

Hi,

I Don't need Dynatrace for few lambda in my service so I used exclude option.
In verbose I see that Dyntrace excluded function
Serverless: [Dynatrace OneAgent] function hello2 has been excluded from monitoring

Final build of the excluded functions contains all the dynatrace dependency. can we remove these dependency ?

Sample Project
https://github.com/CharanRoot/Dynatrace_AWS_Serverless
In the above repo I exclude hello2 lambda but final build have all the dynatrace dependency
image

Reduce Lambda Final Bundle size.

Dynatrace is Increasing Lambda Bundle size drastically. I observed that on Average bundle zip size increased by 19+ MB in Node 10.x.

Before Dynatrace our lambda bundle size is 2MB
After adding Dynatrace its increased by 21 MB.

My environment is Nodejs 10.x and final package build was tailor to --AwsLambdaV10

I observed that Dynatrace final bundle zip have non minified code, lot of unnecessary package and unnecessary files.
example :- By default AWS lambda provide aws-sdk in Runtime environment but Dynatrace include in the node_modules.

Is their way or config to reduce and remove unnecessary package from node_modules.

image

Yarn deploy fails using serverless-oneagent

Hi @Hollerberg, Claro is a customer that is trying to deploy the OneAgent with their lambda function.
However, they use Yarn as their package manager, which is causing error during deploying time.

The instructions that we followed were based on npmjs documentation,
as well as adding the Yarn configuration in this link

What seems to be happening is that npm install the oneagent dependency again, even after Yarn installing it, thus breaking the deploy.
We tried to execute your comment here on the other ticket, but the error is the same. Also, they use a CI/CD pipeline which makes manual commands harder to implement.

Is there maybe any way/flag to ignore the oneagent install through npm again (as yarn already handles it)?

When using only the npm, everything worked fine and we could see transactions in Dynatrace as well.

The debug log with the error is found below:

yarn run v1.21.0
$ sls deploy --stage development --claroenv prod --nockintercept false
Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command dynamodb
Serverless: Load command dynamodb:migrate
Serverless: Load command dynamodb:seed
Serverless: Load command dynamodb:start
Serverless: Load command dynamodb:noStart
Serverless: Load command dynamodb:remove
Serverless: Load command dynamodb:install
Serverless: Load command offline
Serverless: Load command offline:start
Serverless: Load command create_domain
Serverless: Load command delete_domain
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Load command dev
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: [Dynatrace OneAgent] Installing Dynatrace oneagent npm module: @dynatrace/oneagent
+ @dynatrace/[email protected]
removed 27 packages, updated 1 package and audited 1827 packages in 8.766s

34 packages are looking for funding
  run `npm fund` for details

found 2 vulnerabilities (1 low, 1 moderate)
  run `npm audit fix` to fix them, or `npm audit` for details
Serverless: [Dynatrace OneAgent] tailoring OneAgent module in ./
Serverless: Packaging service...
Serverless: Excluding development dependencies...
 
  Error --------------------------------------------------
 
  Error: ENOENT: no such file or directory, open '/Users/nelson.prado/repositorios/monorepo/minha-claro/app-backend/node_modules/libcipm/node_modules/.bin/lock-verify'
      at Package.getFileContent (/Users/nelson.prado/repositorios/monorepo/minha-claro/app-backend/node_modules/serverless/lib/plugins/package/lib/zipService.js:137:15)
      at Package.getFileContentAndStat (/Users/nelson.prado/repositorios/monorepo/minha-claro/app-backend/node_modules/serverless/lib/plugins/package/lib/zipService.js:126:12)
      at Array.map (<anonymous>)
      at WriteStream.output.on (/Users/nelson.prado/repositorios/monorepo/minha-claro/app-backend/node_modules/serverless/lib/plugins/package/lib/zipService.js:95:46)
      at WriteStream.emit (events.js:198:13)
      at WriteStream.EventEmitter.emit (domain.js:448:20)
      at /Users/nelson.prado/repositorios/monorepo/minha-claro/app-backend/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:306:14
      at /Users/nelson.prado/repositorios/monorepo/minha-claro/app-backend/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:333:16
      at /Users/nelson.prado/repositorios/monorepo/minha-claro/app-backend/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:258:16
      at FSReqWrap.args [as oncomplete] (fs.js:140:20)
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              10.20.1
     Framework Version:         1.58.0
     Plugin Version:            3.6.13
     SDK Version:               2.3.1
     Components Core Version:   1.1.2
     Components CLI Version:    1.4.0
 
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

"custom" gets overwritten if it points to an external source (e.g. file)

Bug
In the serverless.yml we specify the following for our custom attribute:

custom: ${file(environment/${self:provider.stage}.js)}

This lets us grab configurations based on the stage we want to operate on.

When adding the the plugin, it determines that we are using the webpack plugin and then calls preProcessServerlessWebPackDeployment which in turn will set service.custom.webpack.includeModules.forceInclude on this.serverless wiping out the file path above.

This results in the configuration not being processed, and several errors:

Serverless Warning --------------------------------------
A valid service attribute to satisfy the declaration 'self:custom.environment.region' could not be found.

Expected Behavior
Allow the custom attribute to resolve before trying to append data allowing the configuration to interpolate correctly.

If it's not possible to do this programatically adding the configuration that this method is adding is minimal work and can be left to the consumer.

error Couldn't find any versions for "@dynatrace/oneagent" that matches "*"

When trying to deploy via serverless (sls deploy) it looks like the plugin tries to install @dynatrace/oneagent based on what I provide in npmModuleVersion.

This error comes up when npmModuleVersion is undefined, when I define it as next, or an actual version number.

Running sls webpack does not result in the same error - it appears to package fine.

dt-oneagent-tailor step fails on oneagent 1.185+

Context:
When running sls deploy or sls package, the serverless-oneagent plugin runs the dt-oneagent-tailor on the @dynatrace/oneagent dependency in order to pull out unnecessary code for the target node runtime. It should be noted that webpack is also being used.

These steps are running inside a build docker container based on lambci/lambda:build-nodejs10.x

Expected results:
For all versions of @dynatrace/oneagent, the tailoring completes successfully and the unnecessary versions are removed from the final zip package that is uploaded to AWS Lambda.

Actual results:
On versions 1.185 and 1.187 of @dynatrace/oneagent, the following output is returned from the sls package/deploy command. Subsequently, the package is not size-optimized for lambda deployment.

Serverless: [Dynatrace OneAgent] tailoring OneAgent module in /<path-to-service-src>/.webpack/health
Serverless: [Dynatrace OneAgent] executing /<path-to-service-src>/.webpack/health/node_modules/.bin/dt-oneagent-tailor --AwsLambdaV10
Serverless: [Dynatrace OneAgent] /usr/bin/env: node\r: No such file or directory
Serverless: [Dynatrace OneAgent] could not determine serverless-webpack intermediate files to tailor OneAgentnpm module(things will work, but zip package will contain files not need for selected Node.js runtime version

Note that this was also tested outside the docker container on Windows 10 where it was successful and on Mac OS X 10.14.6 where the same error occurred as above.

Impact:
Our organization must pin to 1.181 which is the latest available version that does not manifest the issue. We would like to continue to use latest and greatest but size impact of 1.185+ is not worth the cost of the size increase at this time.

Possible root cause:
Based on the \r output in the error message and it working on Windows, it appears this might be related to some kind of line ending parsing issue that is not cross-platform.

What should I expect ?

Hi,

I just installed this serverless plugin on one of my stacks with no webpack involved.
Now I made some requests to my service, but I'm not sure what I should expect to see on Dynatrace's dashboard. For now, there is nothing new from what I can see.

Where can I trace those requests on Dynatrace's dashboard? How do I know if it's working at all?

My config looks like this (please tell me if it's wrong) :

  • server: I tried "" (empty) and "mytenantid.live.dynatrace.com"
  • tenant: mytenantid
  • tenanttoken: a PaaS token generated on the dashboard

I have no other option set.

Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.