Open maurocolella opened 1 year ago
Assigning to @getsentry/support for routing, due by (sfo). ⏲️
Routing to @getsentry/product-owners-sdks-web-frontend for triage, due by (vie). ⏲️
Hey, thanks for reporting this. We should probably add this to the example. FWIW I think the current version still applies and we should keep it.
I cannot add sentry profiling at all to my gen2, nodejs + Typescript endpoint at all because this is missing. There type error occurs when calling:
import { MessagePublishedData } from '@google/events/cloud/pubsub/v1/MessagePublishedData';
import {
cloudEvent,
CloudEventFunction,
} from '@google-cloud/functions-framework';
import { CloudEventV1 } from 'cloudevents';
const main: CloudEventFunction<MessagePublishedData> = async (
event: CloudEventV1<MessagePublishedData>,
) => {
// function here
};
cloudEvent<MessagePublishedData>(
'topicName',
Sentry.GCPFunction.wrapEventFunction(main),
);
The error is:
Argument of type 'EventFunctionWithCallback' is not assignable to parameter of type 'CloudEventFunction<MessagePublishedData>'.
Target signature provides too few arguments. Expected 3 or more, but got 1
Any help is greatly appreciated, because I can't use sentry in any of my cloud functions.
Hey @mattgraphlan if I'm not mistaken, this problem isn't related to the original issue. Would you mind opening a new one?
My suspicion is that GCP cloud function APIs have changed or new ones were added. However, our Serverless package is generally not up to date with these more recent developments as it isn't a major focus of support for us. If you have any ideas or solutions how to use Sentry with these new APIs, feel free to let us know. We're more than happy to review PRs!
any updates on this one?
@shevy11 no updates. You will see it here.
If I'm not mistaken this isn't just a content issue, the current Sentry.GCPFunction.wrapCloudEventFunction
has a function signature that is incompatible with functions-framework. Trying to do:
import * as functions from "@google-cloud/functions-framework";
import * as Sentry from "@sentry/serverless";
functions.cloudEvent('helloCloudEvents', Sentry.GCPFunction.wrapCloudEventFunction(async (cloudEvent: functions.CloudEventFunction) => {
})
Throws a type error:
Argument of type 'CloudEventFunctionWithCallback' is not assignable to parameter of type 'CloudEventFunction<unknown>'.
Target signature provides too few arguments. Expected 2 or more, but got 1.
@Janscode the current way of instrumenting cloud event functions is documented in https://docs.sentry.io/platforms/javascript/guides/gcp-functions/ , if this however does not work for you then you will have to fall back to using @sentry/node
and use manual instrumentation. Hope this helps you getting started for now!
@Janscode I think you are correct that the current SDK is a bit outdated with regards to the newer cloud function interface. We need to update it but haven't gotten round to doing so. We accept PRs.
Core or SDK?
Platform/SDK
Which part? Which one?
@sentry/serverless
Description
The documentation suggests this form to wrap CloudEvent-type Google Cloud Functions:
But this doesn't match the actual recommended shape of handlers:
As a result, types do not align. Code samples in git are also minimal.
Suggested Solution
Update the documentation to clearly indicate usage with the current API.