Custom Go services
Dynatrace OneAgent not only detects Go-based web applications and provides full code-level visibility; it also offers support for proprietary application-specific services. Thanks to custom services, you can monitor any Go application service even if Dynatrace doesn't provide built-in support for it. A custom service can be used to quickly monitor functions in any Go application.
Custom services serve multiple purposes:
- Service-level visibility for application-specific components.
- Response time baselining. This enables the Dynatrace AI to automatically detect changes in response time and identify their root cause.
- Failure detection and baselining. The AI not only detects when a custom service failed due to an error; it can also identify the root cause and determine if the failure impacts end-user experience.
- Deeper visibility into your application. This gives you request-level end-to-end traces and method hotspots.
The application you want to define a custom service for must be instrumented with OneAgent.
Create custom Go services
To define custom Go services
-
In the Dynatrace menu, go to Settings > Service detection > Custom service detection.
-
Go to the Go services tab, and select Define Go services.
-
Type a custom name for the service, and then select Find entry point.
-
Choose the process group and the process that contain the entry points, and select Continue.
-
Choose the package or type that you want to use, and select Continue.
In this example, the scope is
main.(*CronJob)
because the function is defined as a method of theCronJob
type in themain
package. -
Choose one or more functions as entry points for the custom service, and select Finish.
-
Select Save changes in the lower-right corner to enable the new custom Go service.
-
Restart the goCron process to allow Dynatrace OneAgent to instrument all entry points defined in custom Go services.
The newly defined service appears in Smartscape, Service flow, and on its own standalone service overview page:
Closures in Go
Closures are anonymous functions to which the Go compiler assigns special names.
The generated closure names defined in a scope are numbered in order of their appearance: func1
, func2
, and so on. For instance, the closure in the main
function gets the func1
label:
package main
func main() {
go func() {
// ...
}()
}