Dynatrace automatically detects event-based message queue handlers for certain technologies like JMS and Rabbit MQ. Dynatrace can't automatically detect how the messages are processed if your application uses a non-standard RabbitMQ handler, a Kafka or .NET messaging service, or simply processes messages in a non-event driven fashion. To get insight into these, you must define a custom messaging service.
Define a custom messaging service
To define a custom messaging service, go to Settings > Server-side service monitoring > Custom service detection. Select whether your messaging service is based on Java or .NET. Click the Define messaging service button.
When you follow the workflow, ensure that you give the service a meaningful name and select the proper technology.
Click Find entry point.
Find and select the process group that contains your entry point.
Select the process that contains your entry point and click Continue.
Find the class you want to instrument. Type in the name or part of the name to search for it.
Select the required class and click Continue.
Define how you want to instrument the class. You have two options:
- Use the selected class for instrumenting methods of the selected class only.
- Use an implemented interface or superclass for instrumenting methods in any interface or super class in the class hierarchy. In such cases, click Load inheritance to load all available superclasses and interfaces, then select the one you need.
Select the methods you want to instrument and click Finish.
For Apache Kafka messaging services, you can only select methods with a
ConsumerRecordargument. See the Apache Kafka section below.
The Define custom service page displays the newly added entry point and methods.
If needed, add more entry points.
If needed, restrict the new custom service to certain process groups. See the Restrict a custom service to specific process groups section below.
Review the entry point and methods to be instrumented.
In the bottom right corner of the page, click Save.
Apache Kafka is different from other messaging services. Its interfaces are designed to process messages in bulk, yet the purpose of Dynatrace is to follow single transactions. Dynatrace can only do this if you define a Java method that is responsible for processing a single Kafka message in your code and use this as the entry point of your Kafka messaging service. To enforce this, the wizard ensures that you only pick methods that have a Kafka
ConsumerRecord as an argument.
Priority of messaging custom services
If you have several custom services defined, the evaluation goes from top to bottom, applying the first matching rule. If for some reason you have the same class and method defined in several custom services, make sure to prioritize the services accordingly.
Edit custom service
You can edit any custom service at any time. For changes to take effect, you need to restart the affected processes, unless the real-time updates are activated for Java and PHP. For .NET, you must restart the process.
To edit a custom service, click the service's Edit button in the list of services.
You can activate/deactivate existing entry points, add/delete entry points, and add/delete methods in entry points.
You can also restrict the custom service to certain process groups. See the Restrict a custom service to specific process groups section below.
Updates to Java custom messaging services can be applied in near real-time, without process restarts. To activate this feature, enable the Enable real-time updates to Java and PHP services selector at Custom service detection.
Real-time updates may cause CPU spikes when changes are deployed.
Restrict a custom service to specific process groups
You can restrict usage of any custom service to certain process groups. Custom services rules will apply in specified process groups only and will be ignored in other process groups. You can restrict a custom service during creation or edit it later.
To restrict a custom service:
- On the Define custom service or Edit service page, expand the Optionally restrict custom service rules by process groups drop-down menu.
- Click Add process group.
- Select the process group where you want to apply the custom service.
- Click Add.
- In the bottom right corner of the Define custom service or Edit service page, click Save.