Skip to content

Commit 81afedd

Browse files
authored
Update the endpoint name format of the Undertow (#497)
1 parent db7a14d commit 81afedd

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Release Notes.
2424
* Fix unexpected whitespace of the command catalogs in several Redis plugins.
2525
* Fix a thread leak in `SamplingService` when updated sampling policy in the runtime.
2626
* Support MySQL plugin tracing SQL parameters when useServerPrepStmts
27+
* Update the endpoint name of `Undertow` plugin to `Method:Path`.
2728

2829
#### Documentation
2930
* Update docs of Tracing APIs, reorganize the API docs into six parts.

apm-sniffer/apm-sdk-plugin/undertow-plugins/undertow-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/undertow/v2x/handler/TracingHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
5959
} else {
6060
operationName = template;
6161
}
62-
final AbstractSpan span = ContextManager.createEntrySpan(operationName, carrier);
62+
final AbstractSpan span = ContextManager.createEntrySpan(exchange.getRequestMethod() + ":" + operationName, carrier);
6363
Tags.URL.set(span, exchange.getRequestURL());
6464
Tags.HTTP.METHOD.set(span, exchange.getRequestMethod().toString());
6565
span.setComponent(ComponentsDefine.UNDERTOW);

apm-sniffer/apm-sdk-plugin/undertow-plugins/undertow-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/undertow/v2x/RoutingHandlerInterceptorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public class RoutingHandlerInterceptorTest {
7575
private EnhancedInstance enhancedInstance;
7676
private String template = "/projects/{projectId}/users";
7777
private String uri = "/projects/{projectId}/users";
78+
private String endpoint = "GET:/projects/{projectId}/users";
7879

7980
@Before
8081
public void setUp() throws Exception {
@@ -134,7 +135,7 @@ private HttpServerExchange buildExchange() {
134135
}
135136

136137
private void assertHttpSpan(AbstractTracingSpan span) {
137-
assertThat(span.getOperationName(), is(template));
138+
assertThat(span.getOperationName(), is(endpoint));
138139
assertComponent(span, ComponentsDefine.UNDERTOW);
139140
SpanAssert.assertTag(span, 0, "http://localhost:8080" + uri);
140141
assertThat(span.isEntry(), is(true));

apm-sniffer/apm-sdk-plugin/undertow-plugins/undertow-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/undertow/v2x/TracingHandlerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class TracingHandlerTest {
6868

6969
private String template = "/projects/{projectId}/users";
7070
private String uri = "/projects/{projectId}/users";
71+
private String endpoint = "GET:/projects/{projectId}/users";
7172

7273
@Test
7374
public void testStatusCodeIsOk() throws Throwable {
@@ -125,7 +126,7 @@ private HttpServerExchange buildExchange() {
125126
}
126127

127128
private void assertHttpSpan(AbstractTracingSpan span) {
128-
assertThat(span.getOperationName(), is(template));
129+
assertThat(span.getOperationName(), is(endpoint));
129130
assertComponent(span, ComponentsDefine.UNDERTOW);
130131
SpanAssert.assertTag(span, 0, "http://localhost:8080" + uri);
131132
assertThat(span.isEntry(), is(true));

test/plugin/scenarios/undertow-scenario/config/expectedData.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ segmentItems:
1919
segments:
2020
- segmentId: not null
2121
spans:
22-
- operationName: /undertow-scenario/case/undertow
22+
- operationName: GET:/undertow-scenario/case/undertow
2323
parentSpanId: -1
2424
spanId: 0
2525
spanLayer: Http
@@ -36,7 +36,7 @@ segmentItems:
3636
skipAnalysis: 'false'
3737
- segmentId: not null
3838
spans:
39-
- operationName: /undertow-routing-scenario/case/{context}
39+
- operationName: GET:/undertow-routing-scenario/case/{context}
4040
parentSpanId: -1
4141
spanId: 0
4242
spanLayer: Http
@@ -57,7 +57,7 @@ segmentItems:
5757
skipAnalysis: 'false'
5858
- segmentId: not null
5959
spans:
60-
- operationName: /undertow-scenario/case/undertow1
60+
- operationName: GET:/undertow-scenario/case/undertow1
6161
parentSpanId: -1
6262
spanId: 0
6363
spanLayer: Http
@@ -104,7 +104,7 @@ segmentItems:
104104
spanType: Local
105105
peer: ''
106106
refs:
107-
- {parentEndpoint: /undertow-scenario/case/undertow, networkAddress: '', refType: CrossThread,
107+
- {parentEndpoint: GET:/undertow-scenario/case/undertow, networkAddress: '', refType: CrossThread,
108108
parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not
109109
null, parentService: not null, traceId: not null}
110110
skipAnalysis: 'false'
@@ -136,7 +136,7 @@ segmentItems:
136136
spanType: Local
137137
peer: ''
138138
refs:
139-
- {parentEndpoint: '/undertow-routing-scenario/case/{context}', networkAddress: '',
139+
- {parentEndpoint: 'GET:/undertow-routing-scenario/case/{context}', networkAddress: '',
140140
refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not
141141
null, parentService: undertow-scenario, traceId: not null}
142142
skipAnalysis: 'false'

0 commit comments

Comments
 (0)