Considerations
If you wish to create custom instrumentations for Go, Java, or PHP applications, you can define a “Custom Instrumentation” rule via the Odigos InstrumentationRule CRD or the Odigos UI. This feature is a great way to extend Odigos’s auto-instrumentation capabilities to cover your specific use cases and application logic. For Go and Java, custom instrumentation is applied dynamically via eBPF. For PHP, probes are delivered as environment variables and require a pod restart to take effect.Configuration Options
Golang
Golang
packageName
packageName
packageName
string - The name of the package containing the function to instrument.- This field is required
functionName
functionName
functionName
string - The name of the function to instrument.- This field is optional
receiverName
receiverName
receiverName
string - The name of the receiver type if the function is a method.- This field is optional
receiverMethodName
receiverMethodName
receiverMethodName
string - The name of the method receiver if the function is a method.- This field is optional
Java
Java
className
className
className
string - The fully qualified name of the class containing the method to instrument.- This field is required
methodName
methodName
methodName
string - The name of the method to instrument.- This field is required
PHP
PHP
className
className
className
string - The fully qualified class name to instrument. Leave empty for a global function.- This field is optional
functionName
functionName
functionName
string - The name of the function or method to instrument.- This field is required
Basic Example
The following example shows how to create a “Custom Instrumentation” rule that instruments a function namedProcessOrder in the github.com/example/ecommerce package.
1
Create a YAML file named
custom-instrumentation.yaml with the following content:Package and function (Golang)
Package and function (Golang)
Receiver method (Golang)
Receiver method (Golang)
Class and method (Java)
Class and method (Java)
Class and function (PHP)
Class and function (PHP)
2
Apply the action to the cluster: