-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed as not planned
Labels
Package-Meta: OpenTelemetryPackage: nodeIssues related to the Sentry Node SDKIssues related to the Sentry Node SDKStale
Milestone
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?
@sentry/node
SDK Version
8.4.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup
import * as Sentry from "@sentry/node";
import { hostname } from "os";
if (config.sentryEnv !== "disabled") {
Sentry.init({
dsn: config.sentryDsn,
environment: config.sentryEnv,
release: process.env.npm_package_version,
serverName: hostname(),
sampleRate: 1.0,
// tracesSampleRate: 1.0,
tracesSampler(samplingContext) {
if (samplingContext.parentSampled === true) {
return 1.0;
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const url = samplingContext.attributes?.["http.target"] ?? samplingContext.attributes?.["http.url"] ?? "";
if (!_.isString(url)) {
console.warn("tracesSampler", "url is not a string", url);
return config.sentrySampleRate;
}
console.log("tracesSampler", url);
if (_.some(["/v4/images", "/v4/asset/image"], (path) => url.includes(path))) {
console.log("tracesSampler", url, "0.0001");
return 0.0001; // 0.01% of traces
}
if (_.some(["/wallet/txsubmit", "/wallet/txssubmit", "/wallet/swap/review"], (path) => url.includes(path))) {
console.log("tracesSampler", url, "1.0");
return 1.0; // 100% of traces
}
if (_.some(["/wallet/detailed"], (path) => url.includes(path))) {
console.log("tracesSampler", url, "0.5");
return 0.5; // 50% of traces
}
console.log("tracesSampler", url, config.sentrySampleRate);
return config.sentrySampleRate;
},
beforeSend(event, hint) {
// if (hint?.originalException instanceof Error) {
// recordSentryError(hint.originalException);
// }
hint;
return event;
},
beforeSendTransaction(event, hint) {
hint;
console.log(event.request);
return event;
},
});
}
Steps to Reproduce
Run the app. I tried to setup instrumentation:
- As an import using those instructions: https://docs.sentry.io/platforms/javascript/guides/fastify/install/esm-without-import/
- As NODE_OPTIONS import: https://docs.sentry.io/platforms/javascript/guides/fastify/install/esm/
Both options load the instrumentation fine (and well before fastify)
Expected Result
Instrumentation should work as expected and no warning should be given.
Actual Result
I think the instrumentation works as expected (possibly)? But I still get the following message:
console message:
[Sentry] fastify is not instrumented. Please make sure to initialize Sentry in a separate file that you `--import` when running node, see:
https://docs.sentry.io/platforms/javascript/guides/fastify/install/esm/.
Metadata
Metadata
Assignees
Labels
Package-Meta: OpenTelemetryPackage: nodeIssues related to the Sentry Node SDKIssues related to the Sentry Node SDKStale
Projects
Status
Waiting for: Community