Skip to content

Commit 98c606c

Browse files
committed
RUM-9899: Adding special button to for sending manual span
1 parent 1d75dcf commit 98c606c

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

sample/kotlin/src/main/kotlin/com/datadog/android/sample/traces/TracesFragment.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import androidx.fragment.app.Fragment
1818
import androidx.lifecycle.ViewModelProviders
1919
import com.datadog.android.sample.R
2020
import com.datadog.android.sample.SampleApplication
21+
import com.datadog.android.trace.withinSpan
2122

2223
internal class TracesFragment : Fragment(), View.OnClickListener {
2324

@@ -36,6 +37,7 @@ internal class TracesFragment : Fragment(), View.OnClickListener {
3637
): View? {
3738
val rootView = inflater.inflate(R.layout.fragment_traces, container, false)
3839
rootView.findViewById<Button>(R.id.start_async_operation).setOnClickListener(this)
40+
rootView.findViewById<Button>(R.id.send_span).setOnClickListener(this)
3941
rootView.findViewById<Button>(R.id.start_coroutine_operation).setOnClickListener(this)
4042
rootView.findViewById<Button>(R.id.start_request).setOnClickListener(this)
4143
rootView.findViewById<Button>(R.id.start_404_request).setOnClickListener(this)
@@ -88,6 +90,11 @@ internal class TracesFragment : Fragment(), View.OnClickListener {
8890
}
8991
)
9092
}
93+
R.id.send_span -> {
94+
withinSpan(MANUAL_SPAN_MESSAGE) {
95+
// Do nothing
96+
}
97+
}
9198
R.id.start_coroutine_operation -> {
9299
progressBarCoroutine.visibility = View.VISIBLE
93100
progressBarCoroutine.isIndeterminate = true
@@ -153,6 +160,7 @@ internal class TracesFragment : Fragment(), View.OnClickListener {
153160
// endregion
154161

155162
companion object {
163+
private const val MANUAL_SPAN_MESSAGE = "Manual span"
156164
fun newInstance(): TracesFragment {
157165
return TracesFragment()
158166
}

sample/kotlin/src/main/res/layout/fragment_traces.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@
4848
app:layout_constraintTop_toBottomOf="@id/start_async_operation"
4949
android:visibility="invisible"/>
5050

51+
<androidx.appcompat.widget.AppCompatButton
52+
android:id="@+id/send_span"
53+
android:layout_width="0dp"
54+
android:layout_height="wrap_content"
55+
android:layout_margin="16dp"
56+
android:text="@string/button_send_span"
57+
app:layout_constraintEnd_toEndOf="parent"
58+
app:layout_constraintStart_toStartOf="parent"
59+
app:layout_constraintTop_toBottomOf="@id/spinner_async" />
60+
61+
5162
<androidx.appcompat.widget.AppCompatTextView
5263
android:id="@+id/coroutine_operation"
5364
android:layout_width="0dp"
@@ -59,7 +70,7 @@
5970
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
6071
app:layout_constraintEnd_toEndOf="parent"
6172
app:layout_constraintStart_toStartOf="parent"
62-
app:layout_constraintTop_toBottomOf="@id/spinner_async"/>
73+
app:layout_constraintTop_toBottomOf="@id/send_span"/>
6374

6475
<androidx.appcompat.widget.AppCompatButton
6576
android:id="@+id/start_coroutine_operation"

sample/kotlin/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<string name="button_async_operation">Async Operation</string>
6262
<string name="button_network_request">Network Request</string>
6363
<string name="button_start">Start</string>
64+
<string name="button_send_span">Send manual span</string>
6465
<string name="button_start_sse">Start Server Sent Event Request</string>
6566
<string name="button_start_404">Start 404 Request</string>
6667
<string name="button_save">Save</string>

0 commit comments

Comments
 (0)