-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add traces sampler function config for Android/Apple (#488)
* Update copyright notice * Add basic traces sampler implementation * Update package snapshot * Add traces sampler init for Apple * Add custom sampling context * Add transaction context placeholder * Update package snapshot * Add minimal transaction context API * Add transaction context setters * Add way of initializing transaction context with given params (not only native object) * Fix build errors in CI * Add extra API to start transaction * Update package snapshot * Add transaction context implementation for desktop * Add transaction context creation util to library * Fix logs * Update demo * Add custom trace sampler blueprint * Fix method signature * Update package snapshot * Add missing preprocessor directives for conditional compilation * Add missing native methods implementation * Update changelog * Fix traces sampling on Android * Update plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java Co-authored-by: Stefan Jandl <[email protected]> --------- Co-authored-by: Stefan Jandl <[email protected]>
- Loading branch information
1 parent
79b7582
commit 407cf19
Showing
51 changed files
with
887 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
plugin-dev/Source/Sentry/Private/Android/SentrySamplingContextAndroid.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) 2024 Sentry. All Rights Reserved. | ||
|
||
#include "SentrySamplingContextAndroid.h" | ||
|
||
#include "SentryTransactionContext.h" | ||
|
||
#include "Infrastructure/SentryConvertorsAndroid.h" | ||
#include "Infrastructure/SentryJavaClasses.h" | ||
|
||
SentrySamplingContextAndroid::SentrySamplingContextAndroid(jobject samplingContext) | ||
: FSentryJavaObjectWrapper(SentryJavaClasses::SamplingContext, samplingContext) | ||
{ | ||
SetupClassMethods(); | ||
} | ||
|
||
void SentrySamplingContextAndroid::SetupClassMethods() | ||
{ | ||
GetTransactionContextMethod = GetMethod("getTransactionContext", "()Lio/sentry/TransactionContext;"); | ||
GetCustomSamplingContextMethod = GetMethod("getCustomSamplingContext", "()Lio/sentry/CustomSamplingContext;"); | ||
} | ||
|
||
USentryTransactionContext* SentrySamplingContextAndroid::GetTransactionContext() const | ||
{ | ||
auto transactionContext = CallObjectMethod<jobject>(GetTransactionContextMethod); | ||
return SentryConvertorsAndroid::SentryTransactionContextToUnreal(*transactionContext); | ||
} | ||
|
||
TMap<FString, FString> SentrySamplingContextAndroid::GetCustomSamplingContext() const | ||
{ | ||
auto customSamplingContext = CallObjectMethod<jobject>(GetCustomSamplingContextMethod); | ||
if(!customSamplingContext) | ||
return TMap<FString, FString>(); | ||
|
||
FSentryJavaObjectWrapper NativeCustomSamplingContext(SentryJavaClasses::CustomSamplingContext, *customSamplingContext); | ||
FSentryJavaMethod GetDataMethod = NativeCustomSamplingContext.GetMethod("getData", "()Ljava/util/Map;"); | ||
|
||
auto data = NativeCustomSamplingContext.CallObjectMethod<jobject>(GetDataMethod); | ||
return SentryConvertorsAndroid::StringMapToUnreal(*data); | ||
} |
22 changes: 22 additions & 0 deletions
22
plugin-dev/Source/Sentry/Private/Android/SentrySamplingContextAndroid.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) 2024 Sentry. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include "Interface/SentrySamplingContextInterface.h" | ||
|
||
#include "Infrastructure/SentryJavaObjectWrapper.h" | ||
|
||
class SentrySamplingContextAndroid : public ISentrySamplingContext, public FSentryJavaObjectWrapper | ||
{ | ||
public: | ||
SentrySamplingContextAndroid(jobject samplingContext); | ||
|
||
void SetupClassMethods(); | ||
|
||
virtual USentryTransactionContext* GetTransactionContext() const override; | ||
virtual TMap<FString, FString> GetCustomSamplingContext() const override; | ||
|
||
private: | ||
FSentryJavaMethod GetTransactionContextMethod; | ||
FSentryJavaMethod GetCustomSamplingContextMethod; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.