Repository navigation
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g. bundle.tracing.min.js) in your SDK setup.
@sentry/serverless
SDK Version
7.31.1
Framework Version
No response
Link to Sentry event
Customer Event
SDK Setup
Sentry.GCPFunction.init({
dsn: "https://<>@o478484.ingest.sentry.io/<>",
tracesSampleRate: 1.0,
environment: process.env.<VAR>,
release: `<HIDDEN>`,
integrations: defaults => defaults.filter(integration => integration.name !== "Console"),
});
Steps to Reproduce
Context:
Customer trying to set the serverless Function Name as a tag, because the cloud function’s name is not on the event / they don’t know which Cloud Function (GCP) it came from.
Problem:
Set a custom tag, and it doesn’t appear on the Issue.event in Sentry.
ProblemUnderlying (Optional)
Maybe if the Function Name could appear by default in a tag, then the customer would not be trying to set a custom tag for it. Is that something we could make happen?
When an error occurs in a web server /endpoint (not Serverless architecture) you know where it occurred because of the tags
url:http://
transaction:
But in a serverless function error, the Cloud Function / Lambda name is equivalent to the url endpoint, in the user’s mind? And there’s no Function Name on the event? The stacktrace alone doesn’t guarantee you can figure out which URL/Endpoint or Cloud Function it came from, or does it?
Expected Result
Custom Tag should appear on the event linked
Actual Result
Custom Tag does not appear on the event linked
Activity
Lms24 commentedon Feb 20, 2023
Hey @thinkocapo
How do they set the tag? I'm wondering if there's some problem with the scope 🤔
Two thoughts here:
sl0thentr0py commentedon Feb 20, 2023
we're actually working on getsentry/sentry-python#1820 for adding gcp/aws metadata to
contexts.cloudright now, so eventually we could add a similar integration to node too.Lms24 commentedon Feb 20, 2023
Nice, then I'll backlog this for now
(Actually, let's also see why the user's tag isn't showing up)
smeubank commentedon Feb 20, 2023
@Lms24 it was in a related slack thread
Lms24 commentedon Feb 28, 2023
Setting custom tags will be fixed in #7298. We'll include this fix in the next SDK release.
One more thing:
Sentry.setTag("function", 'units')will specifically still not work because'function'is a reserved tag name name and will be filtered out by Relay. See relay/normalize.rs at 37f965b9747fd00ba4f3b01be378279bb6704687 · getsentry/relaySo I'd advise to set the tag name to something else like
Sentry.setTag("gcp-function", 'units')antonpirker commentedon Feb 28, 2023
FYI @Lms24 the cloud resource context we have in Python does not add the name of the function. But each handler of a Lambda function gets a context where you can call
getFunctionName()on: https://docs.aws.amazon.com/lambda/latest/dg/java-context.htmlFor GCP there is an env var called
K_SERVICEthat contains the functions name: https://cloud.google.com/functions/docs/configuring/env-var#newer_runtimesLms24 commentedon Feb 28, 2023
Thanks @antonpirker, I think for now we'll go with the fix that at least custom tags work and we can revisit setting the function name automatically. We'll probably need more consideration in what way we add this to the event.
Or does the Python Serverless SDK already set function names automatically?