Skip to main content
Custom instrumentation lets you define custom eBPF-based instrumentations for specific functions or methods in your application or its dependencies. Unlike automatic instrumentation, which covers common frameworks and libraries, custom instrumentation targets the exact code you choose—for example, a business-critical function or an internal helper that you want to see as a span in your traces. The VM Agent supports Java and Go. For Go, you can instrument either a function (by package and function name) or a receiver method (by package, receiver type, and method name); you must use one form or the other, not both. There are two ways to add a custom instrumentation rule: using odictl or using YAML files.
1

Launch odictl

odictl
2

Open the Instrumentation Rules pane

Use Tab to cycle to the Instrumentation Rules pane, or click it with your mouse. Press Enter or click + Add Rule to add a new rule.Open the Instrumentation Rules pane
3

Choose Custom instrumentation

Select Custom instrumentation as the rule type and press Enter.Choose Custom instrumentation
4

Configure the rule

  1. Press i to enter INSERT mode.
  2. For Java: set class (fully qualified class name) and method (method name).
  3. For Go function: set packageName and functionName. Do not set receiverName or receiverMethodName.
  4. For Go receiver method: set packageName, receiverName, and receiverMethodName. Do not set functionName.
  5. When finished, press Esc, then type :wq to save and exit.
Examples
Instrument a method by fully qualified class and method name:
name: my-custom-instrumentation
type: CustomInstrumentation
config:
  java:
    - className: "com.example.MyClass"
      methodName: "myMethod"
Instrument a function by package and function name:
name: my-custom-instrumentation
type: CustomInstrumentation
config:
  golang:
    - packageName: "github.com/example/ecommerce"
      functionName: "ProcessOrder"
Instrument a method by package, receiver type, and method name:
name: my-custom-instrumentation
type: CustomInstrumentation
config:
  golang:
    - packageName: "github.com/example/ecommerce"
      receiverName: "OrderProcessor"
      receiverMethodName: "ProcessOrder"
The java: and golang: keys accept a list; add multiple entries to instrument several methods or functions in one rule. Use only one language per rule (do not combine java: and golang:). For Go, use either functions or receiver methods in a single rule, not both.
To cancel, press Esc if in INSERT mode, then type :q! to exit without saving.
5

Complete adding the rule

Select OK. The rule appears in the Rules section in odictl.Complete adding the rule
6

Verify the rule

The rule appears in the Rules list.Rules list with the new rule