In our .NET application, we are trying to instrument calls to Redis using the OneAgent SDK. More specifically, we are using the TraceOutgoingRemoteCall method in all our Redis calls.
Even doing this, the service doesn't show up in the Dynatrace portal, so I'm supposing we've missed something. Is there any other necessary step to enable this kind of tracing in Dynatrace? Also, would it be better to use the TraceSQLDatabaseRequest for these Redis calls?
Solved! Go to Solution.
Unfortunately I cannot access your environment unless you open a ticket with our support team but I'll try my best to assist you.
I assume that general out-of-the-box .NET monitoring is working for the process you're trying to instrument. If so, please make sure to follow the SDK-specific troubleshooting steps described here: https://github.com/Dynatrace/OneAgent-SDK-for-dotnet#troubleshooting.
Please also check that the SDK features are not disabled in Dynatrace (Settings > Server-side service monitoring > Deep monitoring > Troubleshooting > "OneAgent SDK outgoing remote call / .NET" and others).
Apart from that, I would suggest using TraceSQLDatabaseRequest as you can provide metadata regarding your Redis instance and query this way. This will also have your Redis instance show up as database in Dynatrace whereas with TraceOutgoingRemoteCall it would just be a generic "black box" service being called. As your Redis command will not be a valid SQL statement, however, I suppose that you will just see the plain query string you provide showing up in Dynatrace without further processing/analysis.
Please note that database calls do not start PurePaths themselves - they are only traced as part of an active service call so if you call Redis from outside your service methods you will have to define a custom service.
Thank you for your answer. We will change the tracing to TraceSQLDatabaseRequest, execute the SDK-specific troubleshooting steps and check the results.
I didn't understand exactly about the creation of the custom service. Will I need to create this service with same database name to see it traced? Also, do I need to use the traced methods as entry points to this service?
This is an example of one of the traced request implementation.
public bool KeyExists(RedisKey key, CommandFlags flags = CommandFlags.None)
var databaseInfo = _oneAgentSdk.CreateDatabaseInfo(
var tracer = _oneAgentSdk.TraceSQLDatabaseRequest(databaseInfo, nameof(KeyExists))
return tracer.Trace(() => _database.KeyExists(key, flags));
your snippet looks good so far. You could also just use "Redis" as databaseVendor - you are not required to use one of the pre-defined constants (those are just well-known vendors for which we would show the respective logo in the UI if available).
If the Redis calls you want to trace are within an execution path which is already traced (e.g., "HandleWebRequest --> GetUsers --> GetUsersCached --> KeyExists" with HandleWebRequest being detected as a web service) you're fine. The calls you instrument using SDK tracers will be added to your existing service.
If Redis is called from an unmonitored method (i.e., no PurePath is active on that thread), however, you'll have to define a custom service either on KeyExists or anywhere up your call tree. This currently only applies to the database tracer as this one is defined not to create a new service itself (i.e., it's not a service entrypoint). The other tracers (incoming/outgoing remote calls, web requests, message sending/processing), however, always declare a new service unless they are called from an existing service in which case they'll be added to the existing PurePath.
Custom services are explained here: https://www.dynatrace.com/support/help/how-to-use-dynatrace/services-and-transactions/configuration/...
Thank you for all the support. Now we are able to see the redis requests in the database section!
Great, glad I could help!