Skip to content
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

.NET Custom Performance Metrics #5689

Merged
merged 4 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The **Dynamic Sampling** feature is currently only available for the following S

<Include name="sampling-supported-sdks.mdx" />

If your application relies on any Sentry SDK that isn't specified above, then you wont be able to use Sentry's **Dynamic Sampling**.
If your application relies on any Sentry SDK that isn't specified above, then you won't be able to use Sentry's **Dynamic Sampling**.

## Trace rules can only select based on the attributes of the initial transaction

Expand Down
3 changes: 1 addition & 2 deletions src/docs/product/performance/metrics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ For example, you might want to set a custom metric to track:

You define and configure custom metrics in the SDK. Currently, you can set custom metrics in:

- [JavaScript (version `7.0.0` or higher)](/platforms/javascript/performance/instrumentation/performance-metrics/)
- [Python (version `1.5.12` or higher)](/platforms/python/performance/instrumentation/performance-metrics/)
<Include name="custom-metrics-supported-sdks.mdx" />

Custom metrics are accessible to you in [sentry.io](https://sentry.io) when you:

Expand Down
7 changes: 7 additions & 0 deletions src/includes/custom-metrics-supported-sdks.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- [JavaScript (version `7.0.0` or later)](/platforms/javascript/performance/instrumentation/performance-metrics/)
- [Python (version `1.5.12` or later)](/platforms/python/performance/instrumentation/performance-metrics/)
- [Apple (version `7.28.0` or later)](/platforms/apple/performance/instrumentation/performance-metrics/)
- [Android (version `6.5.0` or later)](/platforms/android/performance/instrumentation/performance-metrics/)
- [Dart and Flutter (version `6.11.0` or later)](/platforms/dart/performance/instrumentation/performance-metrics/)
mattjohnsonpint marked this conversation as resolved.
Show resolved Hide resolved
- [Java (version `6.5.0` or later)](/platforms/java/performance/instrumentation/performance-metrics/)
- [.NET (version `3.23.0` or later)](/platforms/dotnet/performance/instrumentation/performance-metrics/)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Adding custom metrics is supported in Sentry's .NET SDK, version `3.23.0` and above.

The following example shows how to set custom metrics on a `transaction`, including how obtain the current `span` and get its `transaction`.
If you already have the `transaction` or `span`, you can use it directly.

```csharp
var span = SentrySdk.GetSpan(); // or hub.GetSpan()
if (span != null)
{
var transaction = span.GetTransaction();

// Record amount of memory used
transaction.SetMeasurement("memory_used", 64, MeasurementUnit.Information.Megabyte);

// Record time it took to load user profile
transaction.SetMeasurement("user_profile_loading_time", 1.3, MeasurementUnit.Duration.Second);

// Record number of times the screen was loaded
transaction.SetMeasurement("screen_load_count", 4);
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ supported:
- java.spring-boot
- android
- apple
- dotnet
notSupported:
- javascript.cordova
- javascript.electron
- dotnet
- go
- ruby
- unity
Expand Down