> ## Documentation Index
> Fetch the complete documentation index at: https://docs.odigos.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Instrumentation

> The "Custom Instrumentation" rule can be used to instrument specific functions in PHP applications, or (with Odigos Enterprise) arbitrary Go/Java functions via eBPF.

## Considerations

In Odigos open source, Custom Instrumentation is supported for **PHP** applications using the community native OpenTelemetry distro.

Custom eBPF-based instrumentations for Go and Java require [Odigos Enterprise](/pricing).

PHP probes are delivered as environment variables and require a pod restart to take effect.

## Configuration Options

<AccordionGroup>
  <Accordion title="PHP">
    <AccordionGroup>
      <Accordion title="className">
        **className** `string` - The fully qualified class name to instrument.
        Leave empty for a global function. - This field is *optional*
      </Accordion>

      <Accordion title="functionName">
        **functionName** `string` - The name of the function or method to
        instrument. - This field is *required*
      </Accordion>
    </AccordionGroup>
  </Accordion>
</AccordionGroup>

## Basic Example

The following example instruments the `processOrder` method on `App\Service\OrderService`.

<Steps>
  <Step>
    Create a YAML file named `custom-instrumentation.yaml` with the following content:

    ```yaml theme={null}
    apiVersion: odigos.io/v1alpha1
    kind: InstrumentationRule
    metadata:
        name: custom-instrumentation-rule
        namespace: odigos-system
    spec:
        ruleName: "Custom Instrumentation for processOrder"
        customInstrumentations:
            php:
              - className: "App\\Service\\OrderService"
                functionName: "processOrder"
    ```
  </Step>

  <Step>
    Apply the rule to the cluster:

    ```shell theme={null}
    kubectl apply -f custom-instrumentation.yaml
    ```
  </Step>

  <Step>
    Restart the PHP workload so the new `ODIGOS_PHP_AGENT_CUSTOM_INSTRUMENTATIONS` environment variable is picked up.
  </Step>
</Steps>
