File tree 2 files changed +16
-0
lines changed
examples/default/src/screens/apm
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { Screen } from '../../components/Screen';
6
6
import { VStack } from 'native-base' ;
7
7
import { InputField } from '../../components/InputField' ;
8
8
import { CustomButton } from '../../components/CustomButton' ;
9
+ import BackgroundTimer from 'react-native-background-timer' ;
9
10
10
11
export const FlowsScreen : React . FC = ( ) => {
11
12
const [ flowName , setFlowName ] = useState < string > ( '' ) ;
@@ -16,6 +17,12 @@ export const FlowsScreen: React.FC = () => {
16
17
return APM . startFlow ( flowName ) ;
17
18
}
18
19
20
+ async function startDelayedFlow ( ) {
21
+ return BackgroundTimer . setTimeout ( ( ) => {
22
+ APM . startFlow ( flowName ) ;
23
+ } , 5000 ) ;
24
+ }
25
+
19
26
function setFlowAttribute ( ) {
20
27
return APM . setFlowAttribute ( flowName , flowAttributeKey , flowAttributeValue ) ;
21
28
}
@@ -35,6 +42,7 @@ export const FlowsScreen: React.FC = () => {
35
42
value = { flowName }
36
43
/>
37
44
< CustomButton title = "Start Flow" onPress = { startFlow } />
45
+ < CustomButton title = "Start 5s Delayed Flow" onPress = { startDelayedFlow } />
38
46
< InputField
39
47
placeholder = "Flows Attribute Key"
40
48
onChangeText = { ( text ) => setFlowAttributeKey ( text ) }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { Screen } from '../../components/Screen';
6
6
import { VStack } from 'native-base' ;
7
7
import { InputField } from '../../components/InputField' ;
8
8
import { CustomButton } from '../../components/CustomButton' ;
9
+ import BackgroundTimer from 'react-native-background-timer' ;
9
10
10
11
export const TracesScreen : React . FC = ( ) => {
11
12
const [ traceName , setTraceName ] = useState < string > ( '' ) ;
@@ -17,6 +18,12 @@ export const TracesScreen: React.FC = () => {
17
18
executionTrace = await APM . startExecutionTrace ( traceName ?? '' ) ;
18
19
}
19
20
21
+ async function startDelayedTrace ( ) {
22
+ return BackgroundTimer . setTimeout ( async ( ) => {
23
+ executionTrace = await APM . startExecutionTrace ( traceName ?? '' ) ;
24
+ } , 5000 ) ;
25
+ }
26
+
20
27
function setTraceAttribute ( ) {
21
28
if ( ! executionTrace ) {
22
29
console . log ( 'Please, start a trace before setting attributes.' ) ;
@@ -42,6 +49,7 @@ export const TracesScreen: React.FC = () => {
42
49
value = { traceName }
43
50
/>
44
51
< CustomButton title = "Start Trace" onPress = { startTrace } />
52
+ < CustomButton title = "Start 5s Delayed Trace" onPress = { startDelayedTrace } />
45
53
< InputField
46
54
placeholder = "Trace Key Attribute"
47
55
onChangeText = { ( text ) => setTraceAttributeKey ( text ) }
You can’t perform that action at this time.
0 commit comments