Coder Social home page Coder Social logo

arabold / serverless-sentry-plugin Goto Github PK

View Code? Open in Web Editor NEW
154.0 154.0 27.0 801 KB

This plugin adds automatic forwarding of errors and exceptions to Sentry (https://sentry.io) and Serverless (https://serverless.com)

License: MIT License

TypeScript 99.46% Shell 0.54%
aws aws-lambda raven sentry serverless serverless-framework serverless-plugin

serverless-sentry-plugin's People

Contributors

aaronbannin avatar aheissenberger avatar arabold avatar botond-veress avatar dependabot[bot] avatar dominik-meissner avatar dryror avatar jonmast avatar sifrenette avatar trptcolin avatar viniciusfxavier avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

serverless-sentry-plugin's Issues

Add support for KMS

We should encrypt at least the DSN when setting the environment variables. This would have to be supported in the platform specific libraries as well.

[bug] [regression] Error: Sentry: Error deploying release - Error: Too Many Requests

Hello!

We started to getting "too many requests" error from Sentry after last update.
"You are attempting to use this endpoint too frequently. Limit is 40 requests in 1 seconds"

I can assume it may happen because of latest change 5140c0d

Two things I can propose here:

  • To decrease it to more reasonable standard value.
  • To parameterize it to have more control on it (put 999 if I am sure what I am doing or 1 if want to disable parallelism completely).

For me concurrency 5 was reasonable default, why it was changed to 50, did it really give meaningful performance gain?

1.0.0-rc.4

Hi,

Any chance you could release 1.0.0-rc.4 from master?

I need the "use strict"; at the top of src/git-rev.js and this isn't in the latest release.

Cannot catch unhandled promise rejections

This is my endpoint code (using Serverless Framework):

import serverless from 'serverless-http';
import app from './app'; // express app
import withSentry from 'serverless-sentry-lib';

export const handler = withSentry(serverless(app));

I figured this would work since this plugin is meant for serverless, but unfortunately it doesn't handle unexpected/uncaught errors. Is there something else I need to do?

Feature request: Automatically warn on memory consumption

Additionally to warn as soon as half of the available timeout time has been used, it would be also critical to add an automatic warning, when 3/4 or some other configurable percentage of the provided lambda memory has been consumed, as it's hard to find out if the assigned memory is nearing the limit over time.
This happens especially when using Babel or other transformations that change their behavior on updates and create faster but more memory hungry code.

Sentry: Error uploading sourcemap file - Error: connect EADDRNOTAVAIL 35.188.42.15:443 - Local

Hi,

A few days from now we started to get this error on our pipelines:

Error ---------------------------------------------------
 
  Error: Sentry: Error uploading sourcemap file - Error: connect EADDRNOTAVAIL 35.188.42.15:443 - Local (172.17.0.2:0)
      at SentryPlugin.<anonymous> (/builds/services/node_modules/serverless-sentry/dist/index.js:603:31)
      at step (/builds/services/node_modules/serverless-sentry/dist/index.js:44:23)
      at Object.throw (/builds/services/node_modules/serverless-sentry/dist/index.js:25:53)
      at rejected (/builds/services/node_modules/serverless-sentry/dist/index.js:17:65)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
 
     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:          linux
     Node Version:              14.19.3
     Framework Version:         2.72.3 (local)
     Plugin Version:            5.5.4
     SDK Version:               4.3.2
     Components Version:        3.18.2

This is what our dependencies look like at the moment:

    "@sentry/integrations": "^7.2.0",
    "@sentry/node": "^7.2.0",
    "serverless-sentry-lib": "^2.5.0",
    "serverless-sentry": "^2.5.0",

We even tried to disable this functionality by adding the environment variable SENTRY_SOURCEMAPS or adding the custom config:

sentry:
    sourceMaps: false

But it runs regardless and ignores the flag. Do you have any idea what is happening and how to work around this?

Uploading source maps to sentry when using serverless-plugin-typescript

Hi,

Just wondering if anyone has managed to get source map uploads to sentry working when using ts, and serverless-plugin-typescript to build and deploy ts lambdas. Serverless plugin typescript temporarily creates its outputs in a .build directory but I think this may be deleted after the packaing phase completes in sls and before the sentry plugin runs.

Uploading source map doesn't work when deploying function only

If I deploy all project sls deploy -s mystage it works fine as expected.
However, if I try to deploy only one function with sls deploy function -f myfunction -s mystage I am getting an error Error: Invalid filename on node_modules/adm-zip/adm-zip.js:57:19

caused by this line

const zip = new AdmZip(artifact);

Because file .serverless/myFunction.zip doesn't exist. In fact, whole directory is cleaned (dropped) when I run sls deploy function.

Serverless version 3.10.1, sentry plugin 2.5.3.

I guess it should work the following - if file exists, reuse it, if not - build and pack it (and only one function). (I use package.individually = true and serverless-bundle plugin).

Seems that serverless-bundle plugin uses serverless-webpack under the hood and I have checked that during sls deploy function command a ZIP file inside directory .serverless is actually created... however after that it is deleted before hook of sentry-plugin is called... I am still not sure which issue is it exactly, which of the plugin or the framework itself...

Issue not tracked in Sentry

Hi, I've followed the instructions and installed the plugin on Lambda.
However, when I then trigger a very obvious error, it's not picked up in Sentry.

Here's my code:

'use strict';
const SparkPost = require('sparkpost');
const { decrypt, } = require('../crypto.js');
const RavenLambdaWrapper = require("serverless-sentry-lib");

// Wrap handler for automated error and exception logging
const ravenConfig = {
  captureErrors: true,
  captureUnhandledRejections: true,
  captureMemoryWarnings: true,
  captureTimeoutWarnings: true,
  ravenClient: require("raven") // don't forget!
};

module.exports.index = RavenLambdaWrapper.handler(ravenConfig, (event, context, callback) => {
  context.callbackWaitsForEmptyEventLoop = true;
  const keys = event.requestContext.authorizer;
  const body = JSON.parse(event.body);
  console.log('event', JSON.stringify(body, 3));
  const response = {
    statusCode: 200,
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Credentials': true,
    },
    body: '',
  };

  const client = new SparkPost(keys.SparkPostKey);

  const RECIPIENT = body.RECIPIENT;
  const TEMPLATE_ID = body.TEMPLATE_ID;
  const CAMPAIGN_ID = body.CAMPAIGN_ID;
  const SUBSTITUTION_DATA = body.SUBSTITUTION_DATA;

  try {
    if (SUBSTITUTION_DATA && SUBSTITUTION_DATA.confirmation_link) {
      SUBSTITUTION_DATA.confirmation_link = decrypt(SUBSTITUTION_DATA.confirmation_link);
    }
  } catch (err) {
    console.log('to decryption err', err);
    response.statusCode = 400;
    response.body = JSON.stringify({
      status: 'Failed',
      error: 'Decryption error in \'confirmation_link\'',
    });
    return callback(null, response);
  }

  client.transmissions.send({
    options: {
      track_opens: true,
      track_clicks: true,
      transactional: true,
      ip_pool: "trans2"
    },
    campaign_id: CAMPAIGN_ID,
    content: {
      template_id: TEMPLATE_ID
    },
    substitution_data: SUBSTITUTION_DATA,
    recipients: RECIPIENT
  })
    .then(data => {
      console.log("Email has been sent. ", data);
      response.body = JSON.stringify({
        success: true,
        data: data,
      });
      callback(null, response);

    })
    .catch(err => {
      console.log(err);
      response.statusCode = 400;
      response.body = JSON.stringify({
        success: false,
        error: err,
      });
      callback(null, response);

    });

});

This is my serverless.yml file

service: saas-service

plugins:
  - serverless-webpack
  - serverless-sentry

provider:
  name: aws
  runtime: nodejs8.10
  region: ${self:custom.environment.AwsRegion}
  stage: ${opt:stage}
  timeout: 30
  memorySize: 512

custom:
  environment: ${file(./config.json):${opt:stage}}
  webpack:
    webpackConfig: webpack.config.js
    includeModules:
      forceExclude:
        - aws-sdk
        - crypto
  sentry:
    dsn: https://[email protected]/YYY # URL provided by Sentry

functions:
  Authorizer:
    handler: functions/authorizer/authorizer.index
    environment:
      Environment: ${opt:stage}

  ConfirmationEmail:
    handler: functions/mail/confirmation_email.index
    events:
    - http:
        path: confirmation_email/
        method: post
        cors: true
        authorizer:
          name: Authorizer
          resultTtlInSeconds: 0
          identitySource: method.request.header.Authorization
          type: token
    environment:
      Environment: ${opt:stage}

resources:
	Resources:
	  GatewayResponseDefault4XX:
	    Type: 'AWS::ApiGateway::GatewayResponse'
	    Properties:
	      ResponseParameters:
          gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
          gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
	      ResponseType: DEFAULT_4XX
	      RestApiId:
	        Ref: 'ApiGatewayRestApi'

If I send a wrong SUBSTITUTION_DATA.confirmation_link the Lambda functions breaks (correctly) and I can see the log in CloudWatch, but Sentry doesn't pick anything up.
Ideas?

Global Config

Great Plugin! I would like to ability to set options in the custom object in s-project.json instead of s-function.json Any guidance on how to do this?

Repository name capturing from remote is wrong

I have repository in Gitlab called [email protected]:org/group/subgroup/project.git.
When trying to use the plugin with releases configuration I am bad request from Sentry with similar message

{"refs":["Invalid repository names: subgroup / project"]}

Seems it's because of regular expression here

let repository = /[:/]([^/]+\/[^/]+?)(?:\.git)?$/i.exec(origin)?.[1];

I am not sure what was the motivation for such capturing group as ([^/]+\/[^/]+?), so me just putting (.+?) is enough and works... this expression allows only one / symbol, though it may be few of them in between. What I need is to extract full repository name like org/group/subgroup/project.

Is it a bug? Seems that putting repository name manually into serverless.yaml fixes it.

Plugin defines a validation schema that is invalid

I am trying to integrate Sentry with serverless:

Serverless Version:
Framework Core: 3.1.0 Plugin: 6.0.0 SDK: 4.3.0

Serverless Sentry Plugin Version:

Production Dependency:
"serverless-sentry-lib": "^2.4.0", "@sentry/node": "^6.17.9"

Dev Dependency:

"serverless-sentry": "^2.4.0",

It returns the following error:

At least one of the plugins defines a validation schema that is invalid. Try disabling plugins one by one to identify the problematic plugin and report it to the plugin maintainers.

If I remove the sentry plugin then it works fine.

Git version without Github

I would like to use git versions, but I can't since it populates automatically the refs option. My problem is that we're not using Github, but a private Gitlab (sob). So the configuration is rejected by Sentry saying it doesn't know the related Github repo.

Serverless: Sentry: Creating new release "v0.23.0-rc1"...
Serverless: Sentry: Received error response from Sentry:
{"refs": ["Invalid repository names: my_company/my_repo"]}

refs - If you have set up Sentry to collect commit data, you can use commit refs to associate your commits with your Sentry releases. Refer to the Sentry Documentation for details about how to use commit refs. If you set your version to git (or true), the refs options are populated automatically and don't need to be set.

Is there a way to enable the git version feature (i.e. using the git commit hash or version if any) without populating the refs ?

Function Timeouts lack of information

In case of a function timeout the information provided is very modest.

The information is as follows:
{ Records: [ [Object] ] }

It would be good to see the whole output as a string, is there a way to do so?

Thank you! Alex

Any progress on uploading source maps?

Are there still plans to work on this? If one of the repo maintainers wants to work together on this, I'm game. Right now I have to decide between using this plugin (which rocks), or the SentryWebpackPlugin (not quite as good) which does upload source maps.

READ.me file needs to be modified

Thank you for using a great plugin for error detection in Lambda functions via Sentry.

However, there seems to be a problem with the Releases part of the READ.me file.
I am wondering if it is correct to have a - character in front of the repository value among the settings of serverless.yml.

In my case, I'm using Circle.ci to deploy and I checked for build errors due to a - character, and I removed it and nothing happened.

It may be just my case, but if not, it would be nice to correct it.

Serverless deployment fails with "fatal: No names found, cannot describe anything."

Since the latest minor version change (from 2.3.0 to 2.4.0) the serverless deployment process on the project I am working on is failing with the following error message:

Error: Sentry: No Git available - Error: Command failed: git describe --exact-match --tags HEAD
fatal: No names found, cannot describe anything.

It appears that the cause is running git describe on a git repository that has no tags; the repo I'm working on has no tags.

And I can see from 612f76d#diff-1bcdce6971f2549017c3a649865c9921b7e765fb368eb43e78fbc373a779ba31 that this package is no longer suppressing errors.

Can you suggest how to proceed?

not injecting when using vandium

Started using vandium, sentry no longer injecting

executed :
sls function deploy -t -s dev
checked _tmp, code did not get modified

sample code :

'use strict';
const vandium = require('vandium');
const db = require('./db.js');
const factoryCommonData = require('./factory-common-data.js');

var _connection = {};

vandium.after(function () {
  return _connection.end();
});


module.exports.handler = vandium(main);

/***************MAIN IMPLEMENTATION********************/
 function main(event){    

  return db.GetConnection()
    .then(function (connection) {
      _connection = connection;

      return factoryCommonData.Countries(_connection);
    })
}

Error: Cannot find module 'raven'

After following the setup instructions and deploying a function, all requests return the following error:

{
  "errorMessage": "Cannot find module 'raven'",
  "errorType": "Error",
  "stackTrace": [
    "Function.Module._load (module.js:276:25)",
    "Module.require (module.js:353:17)",
    "require (internal/module.js:12:17)",
    "Object.<anonymous> (/var/task/properties/_serverless_handler.js:1550:19)",
    "Module._compile (module.js:409:26)",
    "Object.Module._extensions..js (module.js:416:10)",
    "Module.load (module.js:343:32)",
    "Function.Module._load (module.js:300:12)",
    "Module.require (module.js:353:17)"
  ]
}

Issue : For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

Following the instructions this is what I have:

serverless.yml
custom:
  variables: ${file(config/serverless/${self:provider.stage}.yml)}
  sentry:
      dsn: "https://[email protected]/xxxxxxxx"

plugins:
  - serverless-delete-loggroups
  - serverless-plugin-typescript
  - serverless-plugin-existing-s3
  - serverless-sentry
#  - serverless-sentry-lib

And this is how I am using the code to send the message to Sentry:

...
import * as Raven from 'raven';
Raven.config('https://[email protected]/xxxxxxxx').install();
Raven.captureException('test 7');

This is the error I am getting when run dev in local and in AWS:

sls invoke local --function functionName --stage dev --path tests/events/test.json --profile testprof

Error --------------------------------------------------
 
  data-pipeline-qa Unable to validate the following destination configurations
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

After I set the variable SLS_DEBUG to "*" like this:

  environment:
      SLS_DEBUG: "*"

I am still getting the same error.

But if I change the serverless.yml to:

plugins:
  - serverless-delete-loggroups
  - serverless-plugin-typescript
  - serverless-plugin-existing-s3
#  - serverless-sentry
  - serverless-sentry-lib
#  - serverless-plugin-optimize

It runs ok. I can see the message in Sentry.

But if I try do deploy for test inside AWS I get the error:

Error --------------------------------------------------
 
  data-pipeline-qa Unable to validate the following destination configurations
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable. 

AND if I set the value for SLS_DEBUG as required in the error to

  environment:
    SLS_DEBUG: "*"

It runs ok locally - I mean I can see the message inside Sentry,

But if I try to deploy in AWS i get the previous error again:

Error --------------------------------------------------
 
  data-pipeline-qa Unable to validate the following destination configurations
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

Data scrubbing/Trace sampling feature request

I am very happy with how simple this plugin made integrating Sentry with my backend however, after successfully integrating the plugin I realized that my project has a use case for scrubbing PII and there is no support for data scrubbing and trace sampling/filtering. (Please correct me if I'm wrong)

The Sentry SDK comes out the box with the two methods that are the beforeSend method and tracesSampler method to allow filtering of transactions and a way to delete specific data points from the event object before it is sent to Sentry.

Is this a feature that can be implemented?

setRelease is never called

Hi,

when we execute serverless deploy --package, function setRelease is never called, then cause an error at the end of the deploy

Serverless: Sentry: Creating new release "true"...
Serverless: Sentry: Deploying release "true"...
Serverless: Sentry: Received error response from Sentry:
{"detail": "The requested resource does not exist"}

because release true option in serverless.yml is never set.

It's a problem with --package option (skip packaging step) then don't call hooks after:package:init.
Thanks

Add Custom Tags

Is there a mechanism to add custom tags to the scope of the sentry object?

Create release failing on v2.0.0

Just testing out updating one of my projects to use the new v2.0.0 versions of your plugin and lib and have run into an error during deployment.

Looking into the code, it seems to be failing here in the compiled code:

return [4 /*yield*/, superagent_1.default
    .post("https://sentry.io/api/0/organizations/" + organization + "/releases/")
    .set("Authorization", "Bearer " + this.sentry.authToken)
    .send(payload)];

When I change superagent_1.default to just superagent_1 (remove .default) from the code, the deployment works. I suspect its just an issue with the build process, but I'm not familiar with typescript so that's just a guess.

The full stacktrace is:

Error: Sentry: Error uploading release - TypeError: Cannot read property 'post' of undefined
    at SentryPlugin.<anonymous> (/my-project/node_modules/serverless-sentry/dist/index.js:442:31)
    at step (/my-project/node_modules/serverless-sentry/dist/index.js:44:23)
    at Object.next (/my-project/node_modules/serverless-sentry/dist/index.js:25:53)
    at /my-project/node_modules/serverless-sentry/dist/index.js:19:71
    at new Promise (<anonymous>)
    at __awaiter (/my-project/node_modules/serverless-sentry/dist/index.js:15:12)
    at SentryPlugin.createSentryRelease (/my-project/node_modules/serverless-sentry/dist/index.js:408:16)
    at SentryPlugin.<anonymous> (/my-project/node_modules/serverless-sentry/dist/index.js:100:59)
    at step (/my-project/node_modules/serverless-sentry/dist/index.js:44:23)
    at Object.next (/my-project/node_modules/serverless-sentry/dist/index.js:25:53)
    at /my-project/node_modules/serverless-sentry/dist/index.js:19:71
    at new Promise (<anonymous>)
    at __awaiter (/my-project/node_modules/serverless-sentry/dist/index.js:15:12)
    at Object.after:deploy:deploy [as hook] (/my-project/node_modules/serverless-sentry/dist/index.js:97:57)
    at /my-project/node_modules/serverless/lib/classes/PluginManager.js:490:55
    at tryCatcher (/my-project/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
    at Object.gotValue (/my-project/node_modules/serverless/node_modules/bluebird/js/release/reduce.js:168:18)
    at Object.gotAccum (/my-project/node_modules/serverless/node_modules/bluebird/js/release/reduce.js:155:25)
    at Object.tryCatcher (/my-project/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/my-project/node_modules/serverless/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/my-project/node_modules/serverless/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/my-project/node_modules/serverless/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/my-project/node_modules/serverless/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/my-project/node_modules/serverless/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/my-project/node_modules/serverless/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/my-project/node_modules/serverless/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues (/my-project/node_modules/serverless/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)
    at process.topLevelDomainCallback (domain.js:137:15)

0.2 release breaks lambda

Hi,
after upgrading to 0.2 , lambda execution never completes (gives an error "Task timed out after")
downgrading back to 0.1.4, lambda function works fine .

feels like something is not being returned or callback not bing called

Cannot load config from an external file

Hello

I'm facing a problem using external .yml config files in my serverless.yml.

This works:

# serverless.yml
custom:
  sentry:	
    dsn: https://xxxx:[email protected]/zzzz
    organization: my-organziation
    project: my-project
    authToken: my-token
    release: true

This doesn't work:

# serverless.yml

custom: ${file(staging.yml)}
# staging.yml
sentry:	
  dsn: https://xxxx:[email protected]/zzzz
  organization: my-organziation
  project: my-project
  authToken: my-token
  release: true

This doesn't work either:

# serverless.yml

custom:
  env: ${file(staging.yml)}
  sentry: ${self:custom.env.sentry}
# staging.yml
sentry:	
  dsn: https://xxxx:[email protected]/zzzz
  organization: my-organziation
  project: my-project
  authToken: my-token
  release: true

The only solution is:

# serverless.yml

custom:
  env: ${file(staging.yml)}
  sentry:	
    dsn: ${self:custom.env.sentry.dsn}	
    environment: ${self:custom.env.sentry.environment}
    organization: ${self:custom.env.sentry.organization}
    project: ${self:custom.env.sentry.project}
    authToken: ${self:custom.env.sentry.authToken}
    release: ${self:custom.env.sentry.release}
# staging.yml
sentry:	
  dsn: https://xxxx:[email protected]/zzzz
  organization: my-organziation
  project: my-project
  authToken: my-token
  release: true

configPlugin() {
this.sentry = {};
if (_.has(this._custom, "sentry") && _.isPlainObject(this._custom.sentry)) {
_.assign(this.sentry, this._custom.sentry);
}
}

return this._serverless.variables.populateObject(this.sentry)
.then(populatedObject => {
this.sentry = populatedObject;

Maybe we could use this._serverless.variables.populateObject() directly on custom instead of custom.sentry (and only if sentry is an object) ?

The plugin shouldn't send latest git tag when i's not the latest commit

I have the following commits:

  • 5ec98be (HEAD -> serverless, origin/serverless) RCH-183 Try Sentry git version
  • 66b3337 (tag: v0.23.0-rc1) v0.23.0-rc1
  • 8b0db54 RCH-183 Add more lambda memory for more speed
  • ...

During serverless deployment, the release pushed to Sentry is v0.23.0-rc1, which corresponds to the latest tag. But that's not the latest commit.

Serverless: Sentry: Creating new release "v0.23.0-rc1"...
Serverless: Sentry: Received error response from Sentry:
{"refs": ["Invalid repository names: my_company/my_repo"]}

I think we should push the latest git tag only when it's on HEAD.

Add custom User Context

I am not using Cognito for Lambda authentication, but using custom authentication using Lambda NodeJS.

How I can set additional context such as:

  Raven.setContext({
    user: {
      email: '[email protected]',
      id: '123'
    }
  });

Thank your very much

Using random version make serverless configuration inconsistant

When configuring release version as "random", the underlying serverless configuration is invalid.

In invalid cloudformation-template-update-stack.json, we get something like:

    "Environment": {
      "Variables": {
        "NODE_ENV": "production",
        "SENTRY_DSN_CLIENT": "...",
        "SENTRY_DSN": "..."
        "SENTRY_RELEASE": {
          "isFulfilled": true,
          "isRejected": false,
          "fulfillmentValue": "206cad0e9012458e88835839fd8aab33"
        },

This fails on deployment because an environment variable cannot be (obviously) an object.

AWS Lamda Production not working

serverless-sentry-lib works for me in develop but not in production, my configuration of serverless.yml:

service: serverless-api
plugins:
  - serverless-sentry
  - serverless-webpack
  - serverless-offline
provider:
  name: aws
  region: us-east-1
  runtime: nodejs6.10
  stage: production
  environment: '${file(.env.yml):${self:custom.stage}}'
custom:
  stage: '${opt:stage, self:provider.stage}'
  serverless-offline:
    port: 4000
    babelOptions:
      presets:
        - es2015
        - es2017
  sentry:
    dsn: https://(SECRET):(SECRET)@sentry.io/(SECRET)
    filterLocal: true   
  .....

verify that the DSN is correct and that the issues are coming to me (local environment), but the mistakes that I am generating in production do not arrive

'use strict'

const response = require('../../helpers/response')
import User from '../../database/models/user'

var Raven = require('raven')
var RavenLambdaWrapper = require('serverless-sentry-lib')

module.exports.handler = RavenLambdaWrapper.handler(Raven,  (event, context, callback) => {

  context.callbackWaitsForEmptyEventLoop = false

  global.cb = callback

  const userid = event.pathParameters.userid

  User.findOne({ where: { userid: userid }}).then((user) => {
    if(user)
      response('user logged', 200, user)
    else
      response('user logged', 200, {error: true})

  }).catch(error => {
    response('user logged', 200, {error: true, message: error})
  })

})

Generate Error:

 UsesdfsdfdsrfindOne({ where: { userid: userid }}).then((user) => { // UsesdfsdfdsrfindOne is undefined (Exception)
    if(user)
      response('user logged', 200, user)
    else
      response('user logged', 200, {error: true})

  }).catch(error => {
    response('user logged', 200, {error: true, message: error})
  })

Packaje.json

"dependencies": {
    ....
    ....
    "raven": "2.2.1",
    "serverless-sentry-lib": "1.0.0-rc.2"
  },
  "devDependencies": {
    "serverless-sentry": "1.0.0-rc.4",
  }

Add enable config

Specifies whether this SDK should activate and send events to Sentry.
Disabling the SDK reduces all overhead from instrumentation, collecting breadcrumbs and capturing events.

Defaults to true.

JS example:
image

Feature Request: Break deploy when raven is missing as dependency

Rationale
The lambda code generated by the plugin is dependent on raven and will not ever start, but immediately break out with an exception, if the dependent module is missing. If you use the optimizer plugin, it is very hard so see what you did wrong. This is something that easily can happen when setting up a new lambda that uses the plugin.
Dependencies introduced by plugins that make the code crash when missing, should be either installed by the plugin or any use of the generated function should be denied by it.

Proposal
On function deploy the plugin should break out if raven is not found as installed dependency.

Direction for other language support (python)

You mention Other platforms can be added easily by providing a respective integration library. I am interested in adding support for python but am a bit lost on where exactly you foresee this library supporting other languages. I think there are two core parts to supporting a new language:

  • Exception Handler Wrapper
  • Raven setup

But I am not sure how we would traverse the python/node boundary.

Any insight?

Unified Node.js SDK

Is there any way to use this plugin with the latest version of the Sentry SDK? They have deprecated the Raven version.

Missing schema for `functions[].sentry` properties

Serverless Framework, over year ago was equipped with validation schema for all its service configuration. It allows to quickly pin point eventual errors developers are making when they're constructing service configurations.

It was provided with utilities for plugins so all properties that are introduced by them can also be easily accompanied with needed schema: https://www.serverless.com/framework/docs/providers/aws/guide/plugins#extending-validation-schema

Serverless Framework is about to release a v3, and with that version it's scheduled that by default any configuration errors (and undefined property is signaled as an error) will be reported with crashes and not warnings as it is in v2.

This will affect users which configure functions[].sentry, (custom namespace is excluded from that, as we allow free-form user configuration in that, still it's also good to provide schema for any properties in custom that plugin introduces).

It'll be great if plugin is upgraded and defines schemas for properties it introduces

Javascript Sourcemap upload to sentry.io

Are there any plans to support the upload of javascript sourcemaps?
https://docs.sentry.io/clients/javascript/sourcemaps/

I user webpack & uglify on my project and this would help to show the original source code on exceptions

Is not possible at the moment as sentry.io does not support this for node :-(
getsentry/sentry#2632

I tried to upload thru the sentry cli and tested with webpack devtool: 'source-map' and devtool: 'inline-source-map' but nothing worked as this feature is deactivated for node project globally

filterLocal: true gets ignored

What is wrong with my code that the configuration for "filterLocal" gets ignored?
Or how can I access the right instance of the wrapper in my App Object?

This is my excerpt from serverless.yml:

  sentry:
    dsn: https://[email protected]/YYYYY
    organization: ORG
    project: PRJ
    authToken: *****
    release: true
    filterLocal: true

starting server less offline:

...
Serverless: GET /getYYYY/b/a (λ: getYYYY)
Serverless: The first request might take a few extra seconds
Sentry **disabled in local environment**
...

this is the code in the handler.js:

import 'source-map-support/register';
import Raven from 'raven';
import RavenLambdaWrapper from 'serverless-sentry-lib';

import AppHandler from './app';

const handler = new AppHandler({});
export const getYYYY = RavenLambdaWrapper.handler(Raven, handler.getwlanuser() );

this is the code in the app.js:

import Raven from 'raven';

export default class {

  getYYYY() {
    return (event, context, cb) => { 
       Raven.captureMessage('Test Start');
    }
  }
}

Incompatible with serverless-http

This plugin appears to be incompatible with serverless-http.

Example:

module.exports.api = RavenLambdaWrapper.handler(Raven, serverless(app));

it works fine when running the code locally using serverless-offline

but when running on lambda I get Task timed out after 6.01 seconds in the cloudwatch logs and a response that looks like.

{
    "message": "Internal server error"
}

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.