Skip to content

fix: Update JS Docs #1556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 23, 2020
Merged

fix: Update JS Docs #1556

merged 10 commits into from
Mar 23, 2020

Conversation

HazAT
Copy link
Member

@HazAT HazAT commented Mar 18, 2020

No description provided.

@HazAT HazAT changed the title fix: Sampling rate fix: Update JS Docs Mar 18, 2020
@HazAT HazAT requested review from dashed and MimiDumpling and removed request for dashed March 18, 2020 13:25
],
tracesSampleRate: 0.1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be fixed in the next update, should have never been there in the first place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. Thanks for clarifying 👍

@dashed dashed requested a review from a team March 18, 2020 14:19
@@ -280,7 +316,7 @@ const Apm = require("@sentry/apm"); // This is required since it patches functio

Sentry.init({
dsn: "___PUBLIC_DSN___",
tracesSampleRate: 0.1
tracesSampleRate: 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change it to 1?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW this is also inconsistent with other code examples.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@MimiDumpling MimiDumpling requested a review from PeloWriter March 19, 2020 00:06
Copy link
Contributor

@rhcarvalho rhcarvalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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']})`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

@untitaker untitaker Mar 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhcarvalho nevermind, the regex is checking that the string doesn't begin with a forward slash.

@dashed dashed self-requested a review March 20, 2020 10:28
Co-Authored-By: Rodolfo Carvalho <[email protected]>
Comment on lines 233 to +234
// 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
Copy link
Contributor

@rhcarvalho rhcarvalho Mar 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why here we use ApmIntegrations.Tracing.startIdleTransaction instead of hub.startSpan?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we prefer ppl using the Integration over the startSpan
The integration also adds spans for XHR/fetch

Comment on lines +249 to +253
const activity = ApmIntegrations.Tracing.pushActivity('task', {
data: {
result
},
op: 'task',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

@dashed dashed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@HazAT HazAT merged commit 8b6aa07 into master Mar 23, 2020
@HazAT HazAT deleted the performance/sampling branch March 23, 2020 08:37
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants