Skip to content

Commit e41b986

Browse files
feat(example): Add delayed button
- Add it for both Flows and Traces
1 parent 346badd commit e41b986

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

examples/default/src/screens/apm/FlowsScreen.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Screen } from '../../components/Screen';
66
import { VStack } from 'native-base';
77
import { InputField } from '../../components/InputField';
88
import { CustomButton } from '../../components/CustomButton';
9+
import BackgroundTimer from 'react-native-background-timer';
910

1011
export const FlowsScreen: React.FC = () => {
1112
const [flowName, setFlowName] = useState<string>('');
@@ -16,6 +17,12 @@ export const FlowsScreen: React.FC = () => {
1617
return APM.startFlow(flowName);
1718
}
1819

20+
async function startDelayedFlow() {
21+
return BackgroundTimer.setTimeout(() => {
22+
APM.startFlow(flowName);
23+
}, 5000);
24+
}
25+
1926
function setFlowAttribute() {
2027
return APM.setFlowAttribute(flowName, flowAttributeKey, flowAttributeValue);
2128
}
@@ -35,6 +42,7 @@ export const FlowsScreen: React.FC = () => {
3542
value={flowName}
3643
/>
3744
<CustomButton title="Start Flow" onPress={startFlow} />
45+
<CustomButton title="Start 5s Delayed Flow" onPress={startDelayedFlow} />
3846
<InputField
3947
placeholder="Flows Attribute Key"
4048
onChangeText={(text) => setFlowAttributeKey(text)}

examples/default/src/screens/apm/TracesScreen.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Screen } from '../../components/Screen';
66
import { VStack } from 'native-base';
77
import { InputField } from '../../components/InputField';
88
import { CustomButton } from '../../components/CustomButton';
9+
import BackgroundTimer from 'react-native-background-timer';
910

1011
export const TracesScreen: React.FC = () => {
1112
const [traceName, setTraceName] = useState<string>('');
@@ -17,6 +18,12 @@ export const TracesScreen: React.FC = () => {
1718
executionTrace = await APM.startExecutionTrace(traceName ?? '');
1819
}
1920

21+
async function startDelayedTrace() {
22+
return BackgroundTimer.setTimeout(async () => {
23+
executionTrace = await APM.startExecutionTrace(traceName ?? '');
24+
}, 5000);
25+
}
26+
2027
function setTraceAttribute() {
2128
if (!executionTrace) {
2229
console.log('Please, start a trace before setting attributes.');
@@ -42,6 +49,7 @@ export const TracesScreen: React.FC = () => {
4249
value={traceName}
4350
/>
4451
<CustomButton title="Start Trace" onPress={startTrace} />
52+
<CustomButton title="Start 5s Delayed Trace" onPress={startDelayedTrace} />
4553
<InputField
4654
placeholder="Trace Key Attribute"
4755
onChangeText={(text) => setTraceAttributeKey(text)}

0 commit comments

Comments
 (0)