@@ -4,10 +4,11 @@ This example demonstrates how to use [declarative configuration](https://opentel
44
55The configuration file is located at [ otel-agent-config.yaml] ( ./otel-agent-config.yaml ) .
66
7- This Spring Boot application includes two endpoints:
7+ This Spring Boot application includes three endpoints:
88
99- ` /actuator/health ` - A health check endpoint (from Spring Boot Actuator) that is configured to be excluded from tracing
1010- ` /api/example ` - A simple API endpoint that will be traced normally
11+ - ` /api/remote ` - An endpoint that makes an outgoing HTTP (client) call, used to demonstrate peer service mapping
1112
1213## End-to-End Instructions
1314
@@ -37,7 +38,7 @@ curl -L -o opentelemetry-javaagent.jar https://github.com/open-telemetry/opentel
3738
3839# Run with the OpenTelemetry Java Agent and contrib extension
3940java -javaagent:opentelemetry-javaagent.jar \
40- -Dotel.experimental. config.file=$( pwd) /otel-agent-config.yaml \
41+ -Dotel.config.file=$( pwd) /otel-agent-config.yaml \
4142 -jar build/libs/javaagent-declarative-configuration.jar
4243```
4344
@@ -51,6 +52,9 @@ curl http://localhost:8080/actuator/health
5152
5253# This endpoint WILL be traced normally
5354curl http://localhost:8080/api/example
55+
56+ # This endpoint makes an outgoing client call; its client span is tagged with peer.service
57+ curl http://localhost:8080/api/remote
5458```
5559
5660### Step 4: Verify Tracing Behavior
@@ -83,3 +87,25 @@ This configuration:
8387- Excludes health check endpoints (`/actuator.*`) from tracing using the `DROP` action
8488- Samples all other requests using the `always_on` fallback sampler
8589- Only applies to `SERVER` span kinds
90+
91+ # ## Peer service mapping
92+
93+ The `otel-agent-config.yaml` file also demonstrates peer service mapping, which maps the peer address (host name or IP)
94+ of an outgoing client call to a logical service name :
95+
96+ ` ` ` yaml
97+ instrumentation/development:
98+ java:
99+ common:
100+ service_peer_mapping:
101+ - peer: localhost
102+ service_name: example-backend
103+ ` ` `
104+
105+ This configuration :
106+
107+ - Replaces the `otel.instrumentation.common.peer-service-mapping` system property
108+ - Adds a `peer.service` attribute to client spans whose peer address (`server.address`) matches a configured `peer`.
109+ The port is optional — omitting it matches any port.
110+ - In this example, the `/api/remote` endpoint calls back into the application over `localhost`, so its client span is
111+ tagged with `peer.service=example-backend`
0 commit comments