You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I work on a very SQLite heavy application, where most of the network calls happen in the background outside the context of a user flow. One thing I'm not sure of is how I can include timings for SQL queries as part of the RUM session traces that are received. Does the SDK have support for this?
Even if the SDK has a way for me to add a generic span to the trace, that would be great as well. I just could find out a way to do this from the documentation.
Do you mean adding a span for a SQLite query performed on the device itself, or a SQL query performed in your backend? For backend tracing, you can take a look at our [APM documentation]https://docs.datadoghq.com/tracing/) page to add tracing to your stack directly. For local SQLite queries performed in your Android code, you can manually create traces by following this documentation.
@xgouchet I followed the sample on that documentation, and I was able to send traces to Datadog. One thing I was not able to figure out however, is making those traces show up in the RUM sessions.
The only thing I see in the RUM sessions is the OkHttp network calls, but the SQLite traces are only visible on the Traces dashboard. I tried looking at the code of the network interceptor, but not able to figure out exactly how these traces are added to the RUM sessions. Would you be able to give me some direction here?
Hey, on the spans that you can see in APM, can you check that you have the following attributes, and that they have "valid" values (invalid would be null, empty, or 00000000-0000-0000-0000-000000000000): session_id, application_id and view.id. E.g.:
Yup, they are all set. I even copied the view ID from the APM trace and filtered the RUM views on that ID and was able to find the screen. The trace just doesn't show up on the RUM session 🤔 .
Not sure if I need to change a filter or something to get it to show up.
For what it's worth, the application is open source, so there shouldn't be an issue sharing the implementation with you to see if we're missing something.
For what it's worth, the application is open source, so there shouldn't be an issue sharing the implementation with you to see if we're missing something.
@xgouchet I'll post the relevant code snippets here, and also link the branch at the end if you would like to go through the changes we have made.
In the main Application class, this is how we initialize the Datadog integration.
We have also instrumented our Room database DAOs to provide hooks for before and after a query is executed. We use this to start and stop the spans that we are sending to Datadog.
classDatadogSqlPerformanceReportingSink : ReportSink {
/** * Maintains the list of running spans for every DB call. * * This can potentially lead to memory leaks if there are DB operations that start but never * finish. However, the chances of that seem small enough that it may not be necessary to take * on the maintenance effort of periodically removing long running spans. * * Something to investigate at a later date. **/privatevar runningSpans = emptyMap<SqlOperation, Span>()
overridefunbegin(operation:SqlOperation) {
Timber.tag("SqlPerformanceReporting").d("Begin operation: $operation")
val tracer =GlobalTracer.get()
val span = tracer
.buildSpan("room.query")
.withTag("dao", operation.daoName)
.withTag("method", operation.methodName)
.start()
runningSpans = runningSpans + (operation to span)
}
overridefunend(operation:SqlOperation) {
Timber.tag("SqlPerformanceReporting").d("End operation: $operation")
val spanForOperation = runningSpans[operation]
/* * There is a possibility for a completed operation to not be present in the list of running * spans since we make copies of the map of running spans and the DB queries can run on multiple * threads. * * In this scenario, we'll just not report this span since the cost of thread synchronisation is * not worth the small chances of a span being lost. **/if (spanForOperation !=null) {
Timber.tag("SqlPerformanceReporting").d("Report operation: $operation")
spanForOperation.finish()
runningSpans = runningSpans - operation
}
}
}
With this setup, the room query traces show up on the Traces dashboard with all the attributes mentioned earlier set, but they don't show up on the RUM sessions themselves. Would you have any idea what we're doing wrong?
Hi @vinaysshenoy, in theory it should work. Let me fork your project and test it on my side to see what's happening.
Thanks, that would be super helpful!
A couple of notes about building and running the project:
The Datadog configuration parameters can be set in gradle.properties.
Database calls will typically not be made until you either register and/or login. Adding some test user credentials (in the order which the app will ask for them) here so you can login and trigger the database queries:
I've run into one more issue, which might not be related. The app has multiple build flavours, each of which correspond to a different environment on Datadog. We tried building a version of the app for a SANDBOX variant, which is essentially a nightly release build which goes to internal testing.
The RUM sessions are showing up on the dashboard, but none of the SQL query traces (which were showing up for a local development build) show up. The service itself is not visible in the list of the services for that environment, only visible for the local development environment which we had tested the Datadog integration on.
I've tried the following:
Added logs to the span start and stop locations in the code. The logs show up on Logcat as expected.
Checked to see if it might be a problem with build minification, this does not seem to the problem as well as they don't show up even if R8 is disabled.
I've run into one more issue, which might not be related. The app has multiple build flavours, each of which correspond to a different environment on Datadog. We tried building a version of the app for a SANDBOX variant, which is essentially a nightly release build which goes to internal testing.
The RUM sessions are showing up on the dashboard, but none of the SQL query traces (which were showing up for a local development build) show up. The service itself is not visible in the list of the services for that environment, only visible for the local development environment which we had tested the Datadog integration on.
I've tried the following:
* Added logs to the span start and stop locations in the code. The logs show up on Logcat as expected.
* Checked to see if it might be a problem with build minification, this does not seem to the problem as well as they don't show up even if R8 is disabled.
Any idea what could be the problem here?
Never mind, this was my fault. I missed setting up the Android tracer.
Activity
xgouchet commentedon Oct 22, 2021
Do you mean adding a span for a SQLite query performed on the device itself, or a SQL query performed in your backend? For backend tracing, you can take a look at our [APM documentation]https://docs.datadoghq.com/tracing/) page to add tracing to your stack directly. For local SQLite queries performed in your Android code, you can manually create traces by following this documentation.
vinaysshenoy commentedon Oct 22, 2021
This is for SQLite queries made in the mobile app. I'll take a look at the documentation, thanks for the quick reply! 🙏🏼
vinaysshenoy commentedon Nov 17, 2021
@xgouchet I followed the sample on that documentation, and I was able to send traces to Datadog. One thing I was not able to figure out however, is making those traces show up in the RUM sessions.
The only thing I see in the RUM sessions is the OkHttp network calls, but the SQLite traces are only visible on the Traces dashboard. I tried looking at the code of the network interceptor, but not able to figure out exactly how these traces are added to the RUM sessions. Would you be able to give me some direction here?
xgouchet commentedon Nov 17, 2021
Hey, on the spans that you can see in APM, can you check that you have the following attributes, and that they have "valid" values (invalid would be null, empty, or
00000000-0000-0000-0000-000000000000):session_id,application_idandview.id. E.g.:{ "application_id": "3dd57edb-7dbf-42fe-a996-50036c2c4b3a", "session_id": "f7d6e3b3-ad80-4827-adca-9013814b5851", "view": { "id": "d6e9f248-87bf-4301-93f5-ecef4298fca5" }, // … }vinaysshenoy commentedon Nov 17, 2021
Yup, they are all set. I even copied the view ID from the APM trace and filtered the RUM views on that ID and was able to find the screen. The trace just doesn't show up on the RUM session 🤔 .
Not sure if I need to change a filter or something to get it to show up.
vinaysshenoy commentedon Nov 17, 2021
For what it's worth, the application is open source, so there shouldn't be an issue sharing the implementation with you to see if we're missing something.
xgouchet commentedon Nov 18, 2021
Great news, thanks a lot @vinaysshenoy
vinaysshenoy commentedon Nov 22, 2021
@xgouchet I'll post the relevant code snippets here, and also link the branch at the end if you would like to go through the changes we have made.
In the main
Applicationclass, this is how we initialize the Datadog integration.We have also instrumented our Room database DAOs to provide hooks for before and after a query is executed. We use this to start and stop the spans that we are sending to Datadog.
With this setup, the room query traces show up on the Traces dashboard with all the attributes mentioned earlier set, but they don't show up on the RUM sessions themselves. Would you have any idea what we're doing wrong?
The branch is available for review at https://github.com/simpledotorg/simple-android/commits/vs/21oct/datadog-integration.
xgouchet commentedon Nov 22, 2021
Hi @vinaysshenoy, in theory it should work. Let me fork your project and test it on my side to see what's happening.
vinaysshenoy commentedon Nov 22, 2021
Thanks, that would be super helpful!
A couple of notes about building and running the project:
xgouchet commentedon Nov 22, 2021
Thanks, indeed something is not working as it should. Let me collect more info, and I'll come back to you
vinaysshenoy commentedon Nov 22, 2021
I've run into one more issue, which might not be related. The app has multiple build flavours, each of which correspond to a different environment on Datadog. We tried building a version of the app for a
SANDBOXvariant, which is essentially a nightly release build which goes to internal testing.The RUM sessions are showing up on the dashboard, but none of the SQL query traces (which were showing up for a local development build) show up. The service itself is not visible in the list of the services for that environment, only visible for the local development environment which we had tested the Datadog integration on.
I've tried the following:
Any idea what could be the problem here?
vinaysshenoy commentedon Nov 23, 2021
Never mind, this was my fault. I missed setting up the Android tracer.
vinaysshenoy commentedon Nov 25, 2021
@xgouchet Just checking in to see if you have any idea as to what's going on here.
xgouchet commentedon Nov 25, 2021
Hey @vinaysshenoy, I'm still trying to synchronize with all the teams involved, to understand the exact issue here.
vinaysshenoy commentedon Nov 26, 2021
Thanks! Please let me know if I can provide some more information that might be helpful in any way.
msasikanth commentedon Jan 11, 2022
Hey @xgouchet , checking in to see if there is any update on this issue?