sentry-docs icon indicating copy to clipboard operation
sentry-docs copied to clipboard

Aspnetcore Setting a Sampling Function docs incorret key value

Open Rassilion opened this issue 3 years ago • 8 comments

Core or SDK?

Platform/SDK

Which part? Which one?

Aspnetcore

Description

In the Aspnetcore "Setting a Sampling Function" docs example script is not working, looks like key value "url" changed to "__HttpPath"

document page: https://docs.sentry.io/platforms/dotnet/guides/aspnetcore/configuration/sampling/#setting-a-sampling-function

I'm trying send a pull request but I could not found that page in this repo.

Suggested Solution

Change

context.CustomSamplingContext.GetValueOrDefault("url")

to

context.CustomSamplingContext.GetValueOrDefault("__HttpPath")

Rassilion avatar Jun 07 '22 12:06 Rassilion

Thanks for raising. The snippets are here: https://github.com/getsentry/sentry-docs/tree/master/src/includes We'd appreciate a PR

bruno-garcia avatar Jun 07 '22 15:06 bruno-garcia

Actually, it looks like the example doc referenced is showing custom context information. The build in one is available with just context.TryGetHttpPath().

The docs could still be a little clearer about this.

mattjohnsonpint avatar Jun 22 '22 21:06 mattjohnsonpint

@lucas-zimerman - want to improve this doc if you have some time?

mattjohnsonpint avatar Jun 22 '22 21:06 mattjohnsonpint

Will do :)

lucas-zimerman avatar Jul 07 '22 00:07 lucas-zimerman

See https://github.com/getsentry/sentry-dotnet/blob/3e77b2d9d0c2c246f7fb309de2571eccb6c82e0d/src/Sentry.AspNetCore/SamplingExtensions.cs

mattjohnsonpint avatar Jul 07 '22 01:07 mattjohnsonpint

Actually, it looks like the example doc referenced is showing custom context information. The build in one is available with just context.TryGetHttpPath().

The docs could still be a little clearer about this.

Thing is, TryGetHttpPath is only available on Asp.NET where the mentioned doc is shared across all .NET targets Maybe mention TryGetHttpPath if using with ASP.NET Core, otherwise the longer method.

lucas-zimerman avatar Jul 13 '22 00:07 lucas-zimerman

I see. Yeah - no need to split the docs up. Just put them both in the same example with a comment such as // assuming ASP.NET Core on one and // or from your own custom data on the other.

mattjohnsonpint avatar Jul 13 '22 01:07 mattjohnsonpint

@bruno-garcia could you close this Issue?

lucas-zimerman avatar Jul 19 '22 15:07 lucas-zimerman