fix: Update JS Docs - #1556
Conversation
| }), | ||
| new ApmIntegrations.Tracing(), | ||
| ], | ||
| tracesSampleRate: 0.1, |
There was a problem hiding this comment.
@HazAT Just curious, is this the preferred placement of the configuration? Wondering because of https://github.com/getsentry/sentry/blob/3672ca751d9306fc22761f1a52847787fcef7915/src/sentry/static/sentry/app/bootstrap.jsx#L37-L40
There was a problem hiding this comment.
This will be fixed in the next update, should have never been there in the first place.
| Sentry.init({ | ||
| dsn: "___PUBLIC_DSN___", | ||
| tracesSampleRate: 0.1 | ||
| tracesSampleRate: 1 |
There was a problem hiding this comment.
Daniel, we cannot allow anybody to send 100% of their traffic to us. This burns immediately through their quota as long as the new billing is not live.
There was a problem hiding this comment.
I leave it in the responsibility of the user to set the correct value here.
1 = they see it works
0.1 = they write into support it's not working
There was a problem hiding this comment.
Okay, can we then add a comment here that they should be careful in increasing this towards 1 in prod? 1 makes total sense in dev.
There was a problem hiding this comment.
FWIW this is also inconsistent with other code examples.
There was a problem hiding this comment.
can we then add a comment here that they should be careful in increasing this towards 1 in prod? 1 makes total sense in dev.
+1
Maybe nobody cares, but I would also find 1.0 more indicative that this is not a 0 or 1 setting, but that typical values are floats in the [0.0, 1.0] range: 0.0, 0.1, 0.25...
There was a problem hiding this comment.
@HazAT
maybe keep it at 1.0 but then put a comment before or after the code snippet that says,
"We recommend 0.1 for when you put this to production [because...]"
maybe keep it at 0.1 but then put a comment before or after the code snippet that says,
"You may want this on 1.0 if you're testing it for the first time"
"You may want this on 1.0 if you're testing it for the first time or else you might think your transactions aren't coming through"
you're 100% correct about them writing into support, as I tricked myself on this the first time I set it up, and then again a month later when I re-visisted it. So that makes me prefer to see it at 1.0 by default.
Co-Authored-By: Rodolfo Carvalho <rodolfo.carvalho@sentry.io>
Co-Authored-By: Rodolfo Carvalho <rodolfo.carvalho@sentry.io>
…cs into performance/sampling
rhcarvalho
left a comment
There was a problem hiding this comment.
Thanks for adding this! A few suggestions.
| - Your frontend is running `mywebapp.com` | ||
| - Your backend is running `api.mybackend.com` | ||
| - You setup your frontend to make API calls to `api.mybackend.com` | ||
| - Then the option need to be configured like this `new ApmIntegrations.Tracing({tracingOrigins: ['localhost', /^\//, 'api.mybackend.com']})` |
There was a problem hiding this comment.
What's the /^\// for in this case?
Also, I'd not include localhost, because what's the point of sending the header to localhost (the page visitor's loopback device). Users may need to arrange for this config to have different values depending on environment.
There was a problem hiding this comment.
I would suggest only adding a new bullet point before this one without changing the code sample:
- In development, your API is at `localhost`
To explain what the localhost is needed for. Then they can make an informed choice on which values to include in their config
There was a problem hiding this comment.
The choice of hosts is very env specific. If you're developing on local containers, localhost is probably the wrong value. We can't know what the right value is for everyone, but we can explain what it needs to match and how to detect errors/ fix it.
There was a problem hiding this comment.
@rhcarvalho I think
it's for checking that the string 'localhost' is validated or not by the regex /^// ?
check out the function isMatchingPattern in string.ts
// tracing.ts
const isWhitelisted = self._options.tracingOrigins.some((origin: string | RegExp) =>
isMatchingPattern(url, origin),
);
looks like you can also write ['localhost', 'string']?
// string.ts
export function isMatchingPattern(value: string, pattern: RegExp | string): boolean {
if (isRegExp(pattern)) {
return (pattern as RegExp).test(value);
}
if (typeof pattern === 'string') {
return value.includes(pattern);
}
return false;
}
but i'm a little confused because:
reg = /^\//
reg.test('foobar')
false
reg.test('foo/bar')
false
There was a problem hiding this comment.
@rhcarvalho nevermind, the regex is checking that the string doesn't begin with a forward slash.
Co-Authored-By: Rodolfo Carvalho <rodolfo.carvalho@sentry.io>
| // When we pop the activity, the Integration will finish the span and after the timeout finish the transaction and send it to Sentry | ||
| Integrations.ApmIntegrations.popActivity(activity); | ||
| // Keep in mind, as long as you do not pop the activity, the transaction will be kept alive and not sent to Sentry |
There was a problem hiding this comment.
We ended up with two sentences that perhaps could be combined together to better convey the important information? ("When we pop... send it to Sentry" & "Keep in mind, ... sent to Sentry")
| // Let's say this function is invoked when a user clicks on the checkout button of your shop | ||
| shopCheckout() { | ||
| // This will create a new Transaction for you | ||
| ApmIntegrations.Tracing.startIdleTransaction('shopCheckout'); |
There was a problem hiding this comment.
Why here we use ApmIntegrations.Tracing.startIdleTransaction instead of hub.startSpan?
There was a problem hiding this comment.
Because we prefer ppl using the Integration over the startSpan
The integration also adds spans for XHR/fetch
| const activity = ApmIntegrations.Tracing.pushActivity('task', { | ||
| data: { | ||
| result | ||
| }, | ||
| op: 'task', |
There was a problem hiding this comment.
Why do we need a name (first arg) for an Activity? Why would people need to write an activity name and then op (which is also some sort of activity/operation name)?!
There was a problem hiding this comment.
It's there if you want to have an activity that is "blocking" the idle transaction but you do not want to create a span out of it.
Co-Authored-By: Rodolfo Carvalho <rodolfo.carvalho@sentry.io>
No description provided.