Skip to content

Commit dd62c9d

Browse files
committed
add declarative config to methods readme
1 parent 8e0b613 commit dd62c9d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

instrumentation/methods/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,34 @@ occurrences. The resulting data is automatically translated into OpenTelemetry t
1010
| `otel.instrumentation.methods.include` | String | None | List of methods to include for tracing. For more information, see [Creating spans around methods with `otel.instrumentation.methods.include`][cs]. |
1111

1212
[cs]: https://opentelemetry.io/docs/zero-code/java/agent/annotations/#creating-spans-around-methods-with-otelinstrumentationmethodsinclude
13+
14+
# Declarative Configuration Example
15+
16+
In addition to configuring method instrumentation via system properties, you can use declarative
17+
configuration files to specify which methods to trace. This approach allows for more flexible and
18+
maintainable instrumentation settings.
19+
20+
Below is an example of a declarative configuration YAML file that enables tracing for a specific
21+
method:
22+
23+
```yaml
24+
file_format: "1.0-rc.1"
25+
instrumentation/development:
26+
java:
27+
methods:
28+
include:
29+
- class: io.opentelemetry.javaagent.instrumentation.methods.MethodTest$ConfigTracedCallable
30+
methods:
31+
- name: call
32+
span_kind: SERVER
33+
```
34+
35+
**Explanation:**
36+
37+
- `class`: The fully qualified name of the class containing the method to be traced.
38+
- `methods`: A list of method configurations for the specified class.
39+
- `name`: The name of the method to trace.
40+
- `span_kind`: The kind of span to create (e.g., SERVER, CLIENT).
41+
42+
This configuration will instruct the OpenTelemetry Java agent to create a span around the `call`
43+
method of the specified class, with the span kind set to SERVER.

0 commit comments

Comments
 (0)