diff --git a/docs/platforms/unreal/configuration/debug-symbols/index.mdx b/docs/platforms/unreal/configuration/debug-symbols/index.mdx index 25797d3b43e7f..0d5f199b25f14 100644 --- a/docs/platforms/unreal/configuration/debug-symbols/index.mdx +++ b/docs/platforms/unreal/configuration/debug-symbols/index.mdx @@ -7,7 +7,7 @@ Sentry requires [debug information files](/platforms/unreal/data-management/debu -For Android, debug symbols upload is handled by [Sentry Android Gradle Plugin](/platforms/android/configuration/gradle). +For Android, debug symbols upload is handled by [Sentry Android Gradle Plugin](/platforms/android/configuration/gradle). By default, it bumps Gradle version to 7.5 automatically, however one can fallback to using its legacy version in case compatibility issues with other third-party plugins arise. @@ -21,6 +21,8 @@ You must configure which build configurations, target types, and platforms Sentr ![The Unreal Engine debug symbols upload configuration](./img/unreal-debug-symbols.png) +Alternatively, debug symbol upload can be enabled by setting the `SENTRY_UPLOAD_SYMBOLS_AUTOMATICALLY` environment variable to `True`. This can be especially helpful in CI/CD environments where manual configuration is impractical. + ### Manual Upload Using sentry-cli To upload debug symbols to Sentry manually, run `sentry-cli` through the command line. You can either use the provided executables from within the package, or follow the [sentry-cli documentation](/product/cli/installation/) to make it available globally. To upload debug symbols run the following command: diff --git a/docs/platforms/unreal/configuration/options.mdx b/docs/platforms/unreal/configuration/options.mdx index 9560ca21abbdb..99a8a758c1045 100644 --- a/docs/platforms/unreal/configuration/options.mdx +++ b/docs/platforms/unreal/configuration/options.mdx @@ -57,6 +57,18 @@ This variable controls the total amount of breadcrumbs that should be captured. + + +Configures whether to automatically add breadcrumbs on in-game events (i.e. when a game map is loaded or session ID is changed). + + + + + +Configures whether to automatically add breadcrumbs for log messages with certain keywords (examples: `Fatal`, `Error`, `Warning`, `Log` and `Verbose`). + + + When enabled, stack traces are automatically attached to all messages logged. Stack traces are always attached to exceptions; however, when this option is set, stack traces are also sent with messages. This option, for instance, means that stack traces appear next to all log messages. @@ -72,6 +84,12 @@ Grouping in Sentry is different for events with stack traces and without. As a r Takes a screenshot of the application when an error happens and includes it as an attachment. Learn more about enriching events with screenshots in our Screenshots documentation. + + +The support for screenshot attachment on crash events is limited to Windows and Linux. + + + ## Hooks @@ -85,3 +103,23 @@ This function is called with an SDK-specific message or error event object, and By the time is executed, all scope data has already been applied to the event. Further modification of the scope won't have any effect. + +## Tracing Options + + + +A number between 0 and 1, controlling the percentage chance a given transaction will be sent to Sentry. (0 represents 0% while 1 represents 100%.) Applies equally to all transactions created in the app. Either this or must be defined to enable tracing. + + + + + +A function responsible for determining the percentage chance a given transaction will be sent to Sentry. It will automatically be passed information about the transaction and the context in which it's being created, and must return a number between `0` (0% chance of being sent) and `1` (100% chance of being sent). Can also be used for filtering transactions, by returning 0 for those that are unwanted. Either this or must be defined to enable tracing. + + + +Currently, there is no support for sampling functions on Windows or Linux (). + + + + diff --git a/docs/platforms/unreal/configuration/releases.mdx b/docs/platforms/unreal/configuration/releases.mdx index 35d472a60df93..3d2f734fe736d 100644 --- a/docs/platforms/unreal/configuration/releases.mdx +++ b/docs/platforms/unreal/configuration/releases.mdx @@ -57,3 +57,21 @@ Setting the release name tags each event with that release name. We recommend th If you don't tell Sentry about a new release, Sentry will automatically create a release entity in the system the first time it sees an event with that release ID. After configuring your SDK, you can install a repository integration or manually supply Sentry with your own commit metadata. Read our documentation about [setting up releases](/product/releases/setup/) for further information about integrations, associating commits, and telling Sentry when deploying releases. + +## Release Health + +Monitor the [health of releases](/product/releases/health/) by observing user adoption, usage of the application, percentage of [crashes](/product/releases/health/#crash), and [session data](/product/releases/health/#session). Release health will provide insight into the impact of crashes and bugs as they relate to user experience, and reveal trends with each new issue through the [Release Details](/product/releases/release-details/) graphs and filters. + +In order to monitor release health, the SDK sends session data. + +### Sessions + +A session represents the interaction between the user and the application. Sessions contain a timestamp, a status (if the session was OK or if it crashed), and are always linked to a release. Most Sentry SDKs can manage sessions automatically. + + + + + +On Windows, release health support for Unreal Engine is currently limited to games made with UE 5.2 or later. Note, that "Enable automatic crash capturing (Windows, UE 5.2+)" in the plugin settings has to be checked to track crashed sessions properly. + + diff --git a/docs/platforms/unreal/configuration/sampling.mdx b/docs/platforms/unreal/configuration/sampling.mdx new file mode 100644 index 0000000000000..2e54aa6003bff --- /dev/null +++ b/docs/platforms/unreal/configuration/sampling.mdx @@ -0,0 +1,103 @@ +--- +title: Sampling +description: "Learn how to configure the volume of error and transaction events sent to Sentry." +sidebar_order: 50 +--- + +Adding Sentry to your app gives you a great deal of very valuable information about errors and performance you wouldn't otherwise get. And lots of information is good -- as long as it's the right information, at a reasonable volume. + +## Sampling Error Events + +To send a representative sample of your errors to Sentry, set the option in your SDK configuration to a number between `0` (0% of errors sent) and `1` (100% of errors sent). This is a static rate, which will apply equally to all errors. For example, to sample 25% of your errors: + + + +The error sample rate defaults to `1`, meaning all errors are sent to Sentry. + + + +Changing the error sample rate requires re-deployment. In addition, setting an SDK sample rate limits visibility into the source of events. Setting a rate limit for your project (which only drops events when volume is high) may better suit your needs. + + + +## Sampling Transaction Events + +We recommend sampling your transactions for two reasons: + +1. Capturing a single trace involves minimal overhead, but capturing traces for _every_ level loaded or _every_ API request may add an undesirable load to your system. + +2. Enabling sampling allows you to better manage the number of events sent to Sentry, so you can tailor your volume to your organization's needs. + +Choose a sampling rate with the goal of finding a balance between performance and volume concerns with data accuracy. You don't want to collect _too_ much data, but you want to collect sufficient data from which to draw meaningful conclusions. If you’re not sure what rate to choose, start with a low value and gradually increase it as you learn more about your traffic patterns and volume. + +## Configuring the Transaction Sample Rate + +The Sentry SDKs have two configuration options to control the volume of transactions sent to Sentry, allowing you to take a representative sample: + +1. Uniform sample rate (): + + - Provides an even cross-section of transactions, no matter where in your app or under what circumstances they occur. + - Uses default [inheritance](#inheritance) and [precedence](#precedence) behavior + +2. Sampling function () which: + - Samples different transactions at different rates + - Filters out some + transactions entirely + - Modifies default [precedence](#precedence) and [inheritance](#inheritance) behavior + +By default, none of these options are set, meaning no transactions will be sent to Sentry. You must set one of the options to start sending transactions. + +### Setting a Uniform Sample Rate + + + +### Setting a Sampling Function + + + +## Sampling Context Data + +### Default Sampling Context Data + +The information contained in the object passed to the when a transaction is created varies by platform and integration. + + + +### Custom Sampling Context Data + +When using custom instrumentation to create a transaction, you can add data to the by passing it as an optional second argument to . This is useful if there's data you want the sampler to have access to, but you don't want to attach it to the transaction as `tags` or `data`, such as information that's sensitive or that’s too large to send with the transaction. For example: + + + +## Inheritance + +Whatever a transaction's sampling decision, that decision will be passed to its child spans and from there to any transactions they subsequently trigger in other services. + +(See Distributed Tracing for more about how that propagation is done.) + +If the transaction currently being created is one of those subsequent transactions (in other words, if it has a parent transaction), the upstream (parent) sampling decision will be included in the sampling context data. Your can use this information to choose whether to inherit that decision. In most cases, inheritance is the right choice, to avoid breaking distributed traces. A broken trace will not include all your services. + +If you're using a rather than a , the decision will always be inherited. + +## Precedence + +There are multiple ways for a transaction to end up with a sampling decision. + +- Random sampling according to a static sample rate set in +- Random sampling according to a sample function rate returned by +- Absolute decision (100% chance or 0% chance) returned by +- If the transaction has a parent, inheriting its parent's sampling decision +- Absolute decision passed to + +When there's the potential for more than one of these to come into play, the following precedence rules apply: + +1. If a sampling decision is passed to , that decision will be used, overriding everything else. +1. If is defined, its decision will be used. It can choose to keep or ignore any parent sampling decision, use the sampling context data to make its own decision, or choose a sample rate for the transaction. We advise against overriding the parent sampling decision because it will break distributed traces +1. If is not defined, but there's a parent sampling decision, the parent sampling decision will be used. +1. If is not defined and there's no parent sampling decision, will be used. + + + +Currently there is no support for forcing a sampling decision by passing it into . + + diff --git a/docs/platforms/unreal/enriching-events/breadcrumbs/img/unreal_automatic_breadcrumbs.png b/docs/platforms/unreal/enriching-events/breadcrumbs/img/unreal_automatic_breadcrumbs.png index d22f6016353a0..e7c7318deecd4 100644 Binary files a/docs/platforms/unreal/enriching-events/breadcrumbs/img/unreal_automatic_breadcrumbs.png and b/docs/platforms/unreal/enriching-events/breadcrumbs/img/unreal_automatic_breadcrumbs.png differ diff --git a/docs/platforms/unreal/tracing/index.mdx b/docs/platforms/unreal/tracing/index.mdx new file mode 100644 index 0000000000000..c56cf4293ed2e --- /dev/null +++ b/docs/platforms/unreal/tracing/index.mdx @@ -0,0 +1,42 @@ +--- +title: Set Up Tracing +description: "Learn how to enable tracing in your app and discover valuable performance insights of your application." +sidebar_order: 4000 +--- + +With [tracing](/product/performance/), Sentry tracks your software performance, measuring metrics like throughput and latency, and displaying the impact of errors across multiple systems. Sentry captures distributed traces consisting of transactions and spans, which measure individual services and individual operations within those services. Learn more about our model in [Distributed Tracing](/product/sentry-basics/tracing/distributed-tracing/). + + + +If you’re adopting Tracing in a high-throughput environment, we recommend testing prior to deployment to ensure that your service’s performance characteristics maintain expectations. + + + +## Configure + +First, enable tracing and configure the sample rate for transactions. Set the sample rate for your transactions by either: + +- Setting a uniform sample rate for all transactions using the option in your SDK config to a number between `0` and `1`. (For example, to send 20% of transactions, set to `0.2`.) +- Controlling the sample rate based on the transaction itself and the context in which it's captured, by providing a function to the config option. + +The two options are meant to be mutually exclusive. If you set both, will take precedence. + + + +Currently there is no support for sampling functions on Windows/Linux (). + + + + + +Learn more about tracing options, how to use the TracesSampler function, or how to sample transactions. + +## Verify + +Test out tracing by starting and finishing a transaction, which you _must_ do so transactions can be sent to Sentry. Learn how in our Custom Instrumentation content. + +While you're testing, set to `1.0`, as that ensures that every transaction will be sent to Sentry. Once testing is complete, you may want to set a lower value, or switch to using to selectively sample and filter your transactions, based on contextual data. + +## Next Steps + + diff --git a/docs/platforms/unreal/tracing/instrumentation/custom-instrumentation.mdx b/docs/platforms/unreal/tracing/instrumentation/custom-instrumentation.mdx new file mode 100644 index 0000000000000..a07ebf534cff1 --- /dev/null +++ b/docs/platforms/unreal/tracing/instrumentation/custom-instrumentation.mdx @@ -0,0 +1,19 @@ +--- +title: Custom Instrumentation +description: "Learn how to capture performance data on any action in your app." +sidebar_order: 20 +--- + + + +To capture transactions and spans customized to your organization's needs, you must first set up tracing. + + + + + + + +## Distributed Tracing + +In order to use distributed tracing, follow the custom instrumentation steps. diff --git a/docs/platforms/unreal/tracing/instrumentation/index.mdx b/docs/platforms/unreal/tracing/instrumentation/index.mdx new file mode 100644 index 0000000000000..eaac9e016be4c --- /dev/null +++ b/docs/platforms/unreal/tracing/instrumentation/index.mdx @@ -0,0 +1,7 @@ +--- +title: Instrumentation +description: "Learn how to instrument tracing in your app." +sidebar_order: 20 +--- + + diff --git a/docs/platforms/unreal/tracing/trace-propagation/custom-instrumentation/index.mdx b/docs/platforms/unreal/tracing/trace-propagation/custom-instrumentation/index.mdx new file mode 100644 index 0000000000000..c95628d0bcfd3 --- /dev/null +++ b/docs/platforms/unreal/tracing/trace-propagation/custom-instrumentation/index.mdx @@ -0,0 +1,6 @@ +--- +title: Custom Instrumentation +sidebar_order: 40 +--- + + diff --git a/docs/platforms/unreal/tracing/trace-propagation/index.mdx b/docs/platforms/unreal/tracing/trace-propagation/index.mdx new file mode 100644 index 0000000000000..8e9da14b3644f --- /dev/null +++ b/docs/platforms/unreal/tracing/trace-propagation/index.mdx @@ -0,0 +1,34 @@ +--- +title: Trace Propagation +description: "Learn how to connect events across applications/services." +sidebar_order: 3000 +--- + +If the overall application landscape that you want to observe with Sentry consists of more than just a single service or application, distributed tracing can add a lot of value. + +## What is Distributed Tracing? + +In the context of tracing events across a distributed system, distributed tracing acts as a powerful debugging tool. Imagine your application as a vast network of interconnected parts. For example, your system might be spread across different servers or your application might split into different backend and frontend services, each potentially having their own technology stack. + +When an error or performance issue occurs, it can be challenging to pinpoint the root cause due to the complexity of such a system. Distributed tracing helps you follow the path of an event as it travels through this intricate web, recording every step it takes. By examining these traces, you can reconstruct the sequence of events leading up to the event of interest, identify the specific components involved, and understand their interactions. This detailed visibility enables you to diagnose and resolve issues more effectively, ultimately improving the reliability and performance of your distributed system. + +## Basic Example + +Here's an example showing a distributed trace in Sentry: + + + +This distributed trace shows a Vue app's `pageload` making a request to a Python backend, which then calls the `/api` endpoint of a Ruby microservice. + +What happens in the background is that Sentry uses reads and further propagates two HTTP headers between your applications: + +- `sentry-trace` +- `baggage` + +If you run any JavaScript applications in your distributed system, make sure that those two headers are added to your CORS allowlist and won't be blocked or stripped by your proxy servers, gateways, or firewalls. + +## How to Use Distributed Tracing? + + + +Remember that in order to propagate trace information through your whole distributed system, you have to use Sentry in all of the involved services and applications. Take a look at their respective SDK docs to learn how distributed tracing can be enabled for each platform. diff --git a/platform-includes/configuration/sample-rate/unreal.mdx b/platform-includes/configuration/sample-rate/unreal.mdx new file mode 100644 index 0000000000000..6c00675376042 --- /dev/null +++ b/platform-includes/configuration/sample-rate/unreal.mdx @@ -0,0 +1,17 @@ +```cpp +#include "SentrySettings.h" + +FConfigureSettingsDelegate SettingsDelegate; +SettingsDelegate.BindDynamic(this, &USomeClass::ConfigureSettingsDelegate); + +void USomeClass::ConfigureSettingsDelegate(USentrySettings* Settings) +{ + Settings->SampleRate = 0.25f; +} + +... + +USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem(); + +SentrySubsystem->InitializeWithSettings(SettingsDelegate); +``` diff --git a/platform-includes/distributed-tracing/custom-instrumentation/unreal.mdx b/platform-includes/distributed-tracing/custom-instrumentation/unreal.mdx new file mode 100644 index 0000000000000..cfc78573544bc --- /dev/null +++ b/platform-includes/distributed-tracing/custom-instrumentation/unreal.mdx @@ -0,0 +1,19 @@ +On this page you will learn how to manually propagate trace information into and out of your Unreal Engine game. + +Continuing a trace from an upstream service requires using `ContinueTrace()`, which will create a transaction context with the provided `sentry-trace` header. This transaction starts with the transaction context will contain everything needed to continue the trace. + +```cpp +// Get incoming tracing information +const FString inTrace = ... +TArray() inBaggage = ... + +USentryTransactionContext* transactionContext = + SentrySubsystem->ContinueTrace(inTrace, inBaggage); + +USentryTransaction* transaction = + SentrySubsystem->StartTransactionWithContext(transactionContext); +``` + +To obtain trace header from a transaction or span, use `GetTrace()`. Pass the returned value to the downstream service. If communication happens over HTTP, we recommend you attach this header to the outgoing HTTP request. + +The format of the `sentry-trace` header should follow the one defined in [the telemetry docs](https://develop.sentry.dev/sdk/telemetry/traces/#header-sentry-trace). It should consist of a 32 character hexadecimal string for the `traceId`, followed by a 16 character hexadecimal string for the `spanId` and an optional single character for the `sampled` flag. If the given string doesn't match this format, the update is ignored and the values in the transaction context will remain unchanged. diff --git a/platform-includes/distributed-tracing/how-to-use/unreal.mdx b/platform-includes/distributed-tracing/how-to-use/unreal.mdx new file mode 100644 index 0000000000000..8b48c3a35cd03 --- /dev/null +++ b/platform-includes/distributed-tracing/how-to-use/unreal.mdx @@ -0,0 +1 @@ +In order to use distributed tracing, follow the custom instrumentation steps. diff --git a/platform-includes/performance/add-spans-example/unreal.mdx b/platform-includes/performance/add-spans-example/unreal.mdx new file mode 100644 index 0000000000000..27bda4d6dadc3 --- /dev/null +++ b/platform-includes/performance/add-spans-example/unreal.mdx @@ -0,0 +1,42 @@ +For example, if you want to create a transaction for a user interaction in your application: + +```cpp +// Let's say this method is called in a background thread when a user clicks on the checkout button. +void perform_checkout() { + USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem(); + + // This will create a new Transaction for you + USentryTransactionContext* transactionContext = NewObject(); + transactionContext->Initialize( + TEXT("checkout"), + TEXT("perform-checkout") + ); + + USentryTransaction* transaction = + SentrySubsystem->StartTransactionWithContext(transactionContext); + + // Validate the cart + USentrySpan* validationSpan = transaction->StartChild( + TEXT("validation"), + TEXT("validating shopping cart") + ); + + validate_shopping_cart(); // Some long process, maybe a sync http request. + + validationSpan->Finish(); + + // Process the order + SentrySpan* processSpan = transaction->StartChild( + TEXT("process"), + TEXT("processing shopping cart") + ); + + process_shopping_cart(); // Another time consuming process. + + processSpan->Finish(); + + transaction->Finish(); +} +``` + +This example will send a transaction named `checkout` to Sentry. The transaction will contain a `validation` span that measures how long `validate_shopping_cart()` took and a `process` span that measures `process_shopping_cart()`. Finally, the `transaction->Finish()` call will finish the transaction and send it to Sentry. diff --git a/platform-includes/performance/configure-sample-rate/unreal.mdx b/platform-includes/performance/configure-sample-rate/unreal.mdx new file mode 100644 index 0000000000000..769f7b382f591 --- /dev/null +++ b/platform-includes/performance/configure-sample-rate/unreal.mdx @@ -0,0 +1,17 @@ +```cpp {diff} +#include "SentrySettings.h" + +FConfigureSettingsDelegate SettingsDelegate; +SettingsDelegate.BindDynamic(this, &USomeClass::ConfigureSettingsDelegate); + +void USomeClass::ConfigureSettingsDelegate(USentrySettings* Settings) +{ + Settings->TracesSampleRate = 0.2f; +} + +... + +USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem(); + +SentrySubsystem->InitializeWithSettings(SettingsDelegate); +``` diff --git a/platform-includes/performance/custom-sampling-context/unreal.mdx b/platform-includes/performance/custom-sampling-context/unreal.mdx new file mode 100644 index 0000000000000..eed9af39c7b1b --- /dev/null +++ b/platform-includes/performance/custom-sampling-context/unreal.mdx @@ -0,0 +1,20 @@ +```cpp +USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem(); + +// The following data will take part in the sampling decision +TMap options; +options.Add(TEXT("user_id"), TEXT("12312012")); +options.Add(TEXT("search_results"), TEXT("...")); + +USentryTransactionContext* transactionContext = NewObject(); +transactionContext->Initialize( + TEXT("GET /search"), + TEXT("http") +); + +USentryTransaction* transaction = + SentrySubsystem->StartTransactionWithContextAndOptions( + transactionContext, + options + ); +``` diff --git a/platform-includes/performance/default-sampling-context-platform/unreal.mdx b/platform-includes/performance/default-sampling-context-platform/unreal.mdx new file mode 100644 index 0000000000000..c0cbb1c4960d6 --- /dev/null +++ b/platform-includes/performance/default-sampling-context-platform/unreal.mdx @@ -0,0 +1 @@ + includes a [Transaction Context](https://github.com/getsentry/sentry-unreal/blob/6e4ee91fd538cede13e95635dd1e38c3ad0ab0ba/plugin-dev/Source/Sentry/Public/SentryTransactionContext.h) and a custom sampling context (`FString` to `FString` map). diff --git a/platform-includes/performance/default-sampling-context/unreal.mdx b/platform-includes/performance/default-sampling-context/unreal.mdx new file mode 100644 index 0000000000000..a6a92c2a989d8 --- /dev/null +++ b/platform-includes/performance/default-sampling-context/unreal.mdx @@ -0,0 +1 @@ + diff --git a/platform-includes/performance/enable-manual-instrumentation/unreal.mdx b/platform-includes/performance/enable-manual-instrumentation/unreal.mdx new file mode 100644 index 0000000000000..064acbc2b30ef --- /dev/null +++ b/platform-includes/performance/enable-manual-instrumentation/unreal.mdx @@ -0,0 +1,24 @@ +To instrument certain parts of your code, you can create transactions to capture them. + +```cpp +USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem(); + +// Transactions can be started by providing the name and the operation +USentryTransaction* transaction = SentrySubsystem->StartTransaction( + TEXT("transaction name"), + TEXT("transaction operation") +); + +// Transactions can have child spans (and those spans can have child spans as well) +USentrySpan* span = transaction->StartChild( + TEXT("span name"), + TEXT("span description") +); + +// ... +// (Perform the operation represented by the span/transaction) +// ... + +span->Finish(); +transaction->Finish(); +``` diff --git a/platform-includes/performance/sampling-function-intro/unreal.mdx b/platform-includes/performance/sampling-function-intro/unreal.mdx new file mode 100644 index 0000000000000..80f82dcc3c56e --- /dev/null +++ b/platform-includes/performance/sampling-function-intro/unreal.mdx @@ -0,0 +1,11 @@ +To use the sampling function, set the option in your SDK configuration to a function that will accept a dictionary and return a sample rate between 0 and 1. For example: + + + + + +Currently there's no support for sampling functions on Windows/Linux (). + + + +Additionally, your sampling function may also return `false`, which indicates that no sampling decision has been made. In such case, the trace will retain the previous decision if it has been made (for example if it was started from an incoming trace header), or fall back to the value configured in . diff --git a/platform-includes/performance/traces-sample-rate/unreal.mdx b/platform-includes/performance/traces-sample-rate/unreal.mdx new file mode 100644 index 0000000000000..efe84c930e27e --- /dev/null +++ b/platform-includes/performance/traces-sample-rate/unreal.mdx @@ -0,0 +1,17 @@ +```cpp +#include "SentrySettings.h" + +FConfigureSettingsDelegate SettingsDelegate; +SettingsDelegate.BindDynamic(this, &USomeClass::ConfigureSettingsDelegate); + +void USomeClass::ConfigureSettingsDelegate(USentrySettings* Settings) +{ + Settings->TracesSampleRate = 0.2f; +} + +... + +USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem(); + +SentrySubsystem->InitializeWithSettings(SettingsDelegate); +``` diff --git a/platform-includes/performance/traces-sampler-as-sampler/unreal.mdx b/platform-includes/performance/traces-sampler-as-sampler/unreal.mdx new file mode 100644 index 0000000000000..58843aff2796c --- /dev/null +++ b/platform-includes/performance/traces-sampler-as-sampler/unreal.mdx @@ -0,0 +1,59 @@ +```cpp +UCLASS() +class USomeTraceSampler : public USentryTraceSampler +{ + GENERATED_BODY() + +public: + virtual bool Sample_Implementation(USentrySamplingContext* samplingContext, float& samplingValue) override + { + const FString& gameMode = + *samplingContext->GetCustomSamplingContext().Find("GameMode"); + + if (gameMode.Equals(TEXT("ranked"))) + { + // Ranked matches are important - take a big sample + samplingValue = 0.5; + } + else if (gameMode.Equals(TEXT("quick_match"))) + { + // Quick matches less important and happen more frequently - only take 20% + samplingValue = 0.2; + } + else if (gameMode.Equals(TEXT("training"))) + { + // Training matches are just noise - drop all transactions + samplingValue = 0.0; + } + else + { + // Default sample rate for other game modes + samplingValue = 0.1; + } + + return true; + + // Or return false to fallback to options.TracesSampleRate (1.0 in this case) + } +}; + +... + +FConfigureSettingsDelegate SettingsDelegate; +SettingsDelegate.BindDynamic(this, &USomeClass::HandleSettingsDelegate); + +void USomeClass::HandleSettingsDelegate(USentrySettings* Settings) +{ + // Set a uniform sample rate + Settings->TracesSampleRate = 1.0f; + + // OR: Determine traces sample rate based on the sampling context + Settings->TracesSampler = USomeTraceSampler::StaticCLass(); +} + +... + +USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem(); + +SentrySubsystem->InitializeWithSettings(SettingsDelegate); +``` diff --git a/platform-includes/performance/uniform-sample-rate/unreal.mdx b/platform-includes/performance/uniform-sample-rate/unreal.mdx new file mode 100644 index 0000000000000..e2496d9a71828 --- /dev/null +++ b/platform-includes/performance/uniform-sample-rate/unreal.mdx @@ -0,0 +1,3 @@ +To do this, set the option to a number between 0 and 1. With this option set, every transaction created will have that percentage chance of being sent to Sentry. For example, if you set to `0.2`, approximately 20% of your transactions will be recorded and sent. That looks like this: + +