Skip to content

Commit 7cf6900

Browse files
committed
fix-format-violations
1 parent dcb4798 commit 7cf6900

File tree

2 files changed

+27
-81
lines changed

2 files changed

+27
-81
lines changed

instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpClientAttributesExtractorTest.java

Lines changed: 27 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -169,36 +169,26 @@ void normal() {
169169

170170
AttributesBuilder startAttributes = Attributes.builder();
171171
extractor.onStart(startAttributes, Context.root(), request);
172-
// assertThat(startAttributes.build())
173-
// .containsOnly(
174-
// entry(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
175-
// entry(UrlAttributes.URL_FULL, "http://github.com"),
176-
// entry(
177-
// AttributeKey.stringArrayKey("http.request.header.custom-request-header"),
178-
// asList("123", "456")),
179-
// entry(ServerAttributes.SERVER_ADDRESS, "github.com"),
180-
// entry(ServerAttributes.SERVER_PORT, 80L),
181-
// entry(HttpAttributes.HTTP_REQUEST_RESEND_COUNT, 2L));
182172

183173
AttributesBuilder endAttributes = Attributes.builder();
184174
extractor.onEnd(endAttributes, Context.root(), request, response, null);
185175
assertThat(endAttributes.build())
186-
.containsOnly(
187-
entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 202L),
188-
entry(
189-
AttributeKey.stringArrayKey("http.response.header.custom-response-header"),
190-
asList("654", "321")),
191-
entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
192-
entry(NetworkAttributes.NETWORK_PEER_ADDRESS, "4.3.2.1"),
193-
entry(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
194-
entry(UrlAttributes.URL_FULL, "http://github.com"),
195-
entry(
196-
AttributeKey.stringArrayKey("http.request.header.custom-request-header"),
197-
asList("123", "456")),
198-
entry(ServerAttributes.SERVER_ADDRESS, "github.com"),
199-
entry(ServerAttributes.SERVER_PORT, 80L),
200-
entry(HttpAttributes.HTTP_REQUEST_RESEND_COUNT, 2L),
201-
entry(NetworkAttributes.NETWORK_PEER_PORT, 456L));
176+
.containsOnly(
177+
entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 202L),
178+
entry(
179+
AttributeKey.stringArrayKey("http.response.header.custom-response-header"),
180+
asList("654", "321")),
181+
entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
182+
entry(NetworkAttributes.NETWORK_PEER_ADDRESS, "4.3.2.1"),
183+
entry(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
184+
entry(UrlAttributes.URL_FULL, "http://github.com"),
185+
entry(
186+
AttributeKey.stringArrayKey("http.request.header.custom-request-header"),
187+
asList("123", "456")),
188+
entry(ServerAttributes.SERVER_ADDRESS, "github.com"),
189+
entry(ServerAttributes.SERVER_PORT, 80L),
190+
entry(HttpAttributes.HTTP_REQUEST_RESEND_COUNT, 2L),
191+
entry(NetworkAttributes.NETWORK_PEER_PORT, 456L));
202192
}
203193

204194
@ParameterizedTest
@@ -362,21 +352,17 @@ void shouldExtractServerAddressAndPortFromHostHeader() {
362352
response.put("statusCode", "200");
363353

364354
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
365-
HttpClientAttributesExtractor.create(new TestHttpClientAttributesGetter());
355+
HttpClientAttributesExtractor.create(new TestHttpClientAttributesGetter());
366356

367357
AttributesBuilder startAttributes = Attributes.builder();
368358
extractor.onStart(startAttributes, Context.root(), request);
369-
// assertThat(startAttributes.build())
370-
// .containsOnly(
371-
// entry(ServerAttributes.SERVER_ADDRESS, "github.com"),
372-
// entry(ServerAttributes.SERVER_PORT, 123L));
373359

374360
AttributesBuilder endAttributes = Attributes.builder();
375361
extractor.onEnd(endAttributes, Context.root(), request, response, null);
376362
assertThat(endAttributes.build())
377-
.containsOnly(entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
378-
entry(ServerAttributes.SERVER_ADDRESS, "github.com"),
379-
entry(ServerAttributes.SERVER_PORT, 123L));
363+
.containsOnly(entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
364+
entry(ServerAttributes.SERVER_ADDRESS, "github.com"),
365+
entry(ServerAttributes.SERVER_PORT, 123L));
380366
}
381367

382368
@Test
@@ -391,24 +377,20 @@ void shouldExtractPeerAddressEvenIfItDuplicatesServerAddress() {
391377
response.put("statusCode", "200");
392378

393379
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
394-
HttpClientAttributesExtractor.create(new TestHttpClientAttributesGetter());
380+
HttpClientAttributesExtractor.create(new TestHttpClientAttributesGetter());
395381

396382
AttributesBuilder startAttributes = Attributes.builder();
397383
extractor.onStart(startAttributes, Context.root(), request);
398-
// assertThat(startAttributes.build())
399-
// .containsOnly(
400-
// entry(ServerAttributes.SERVER_ADDRESS, "1.2.3.4"),
401-
// entry(ServerAttributes.SERVER_PORT, 123L));
402384

403385
AttributesBuilder endAttributes = Attributes.builder();
404386
extractor.onEnd(endAttributes, Context.root(), request, response, null);
405387
assertThat(endAttributes.build())
406-
.containsOnly(
407-
entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
408-
entry(NetworkAttributes.NETWORK_PEER_ADDRESS, "1.2.3.4"),
409-
entry(NetworkAttributes.NETWORK_PEER_PORT, 456L),
410-
entry(ServerAttributes.SERVER_ADDRESS, "1.2.3.4"),
411-
entry(ServerAttributes.SERVER_PORT, 123L));
388+
.containsOnly(
389+
entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
390+
entry(NetworkAttributes.NETWORK_PEER_ADDRESS, "1.2.3.4"),
391+
entry(NetworkAttributes.NETWORK_PEER_PORT, 456L),
392+
entry(ServerAttributes.SERVER_ADDRESS, "1.2.3.4"),
393+
entry(ServerAttributes.SERVER_PORT, 123L));
412394
}
413395

414396
@Test

instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerAttributesExtractorTest.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -196,20 +196,6 @@ void normal() {
196196

197197
AttributesBuilder startAttributes = Attributes.builder();
198198
extractor.onStart(startAttributes, Context.root(), request);
199-
// assertThat(startAttributes.build())
200-
// .containsOnly(
201-
// entry(ServerAttributes.SERVER_ADDRESS, "github.com"),
202-
// entry(ServerAttributes.SERVER_PORT, 443L),
203-
// entry(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
204-
// entry(UrlAttributes.URL_SCHEME, "https"),
205-
// entry(UrlAttributes.URL_PATH, "/repositories/1"),
206-
// entry(UrlAttributes.URL_QUERY, "details=true"),
207-
// entry(UserAgentAttributes.USER_AGENT_ORIGINAL, "okhttp 3.x"),
208-
// entry(HttpAttributes.HTTP_ROUTE, "/repositories/{id}"),
209-
// entry(ClientAttributes.CLIENT_ADDRESS, "1.1.1.1"),
210-
// entry(
211-
// AttributeKey.stringArrayKey("http.request.header.custom-request-header"),
212-
// asList("123", "456")));
213199

214200
AttributesBuilder endAttributes = Attributes.builder();
215201
extractor.onEnd(endAttributes, Context.root(), request, response, null);
@@ -429,11 +415,6 @@ void shouldExtractServerAddressAndPortFromForwardedHeader() {
429415
AttributesBuilder startAttributes = Attributes.builder();
430416
extractor.onStart(startAttributes, Context.root(), request);
431417

432-
// assertThat(startAttributes.build())
433-
// .containsOnly(
434-
// entry(ServerAttributes.SERVER_ADDRESS, "example.com"),
435-
// entry(ServerAttributes.SERVER_PORT, 42L));
436-
437418
AttributesBuilder endAttributes = Attributes.builder();
438419
extractor.onEnd(endAttributes, Context.root(), request, response, null);
439420
assertThat(endAttributes.build())
@@ -458,11 +439,6 @@ void shouldExtractServerAddressAndPortFromForwardedHostHeader() {
458439
AttributesBuilder startAttributes = Attributes.builder();
459440
extractor.onStart(startAttributes, Context.root(), request);
460441

461-
// assertThat(startAttributes.build())
462-
// .containsOnly(
463-
// entry(ServerAttributes.SERVER_ADDRESS, "opentelemetry.io"),
464-
// entry(ServerAttributes.SERVER_PORT, 987L));
465-
466442
AttributesBuilder endAttributes = Attributes.builder();
467443
extractor.onEnd(endAttributes, Context.root(), request, response, null);
468444
assertThat(endAttributes.build())
@@ -486,11 +462,6 @@ void shouldExtractServerAddressAndPortFromAuthorityPseudoHeader() {
486462
AttributesBuilder startAttributes = Attributes.builder();
487463
extractor.onStart(startAttributes, Context.root(), request);
488464

489-
// assertThat(startAttributes.build())
490-
// .containsOnly(
491-
// entry(ServerAttributes.SERVER_ADDRESS, "opentelemetry.io"),
492-
// entry(ServerAttributes.SERVER_PORT, 42L));
493-
494465
AttributesBuilder endAttributes = Attributes.builder();
495466
extractor.onEnd(endAttributes, Context.root(), request, response, null);
496467
assertThat(endAttributes.build())
@@ -513,11 +484,6 @@ void shouldExtractServerAddressAndPortFromHostHeader() {
513484
AttributesBuilder startAttributes = Attributes.builder();
514485
extractor.onStart(startAttributes, Context.root(), request);
515486

516-
// assertThat(startAttributes.build())
517-
// .containsOnly(
518-
// entry(ServerAttributes.SERVER_ADDRESS, "github.com"),
519-
// entry(ServerAttributes.SERVER_PORT, 123L));
520-
521487
AttributesBuilder endAttributes = Attributes.builder();
522488
extractor.onEnd(endAttributes, Context.root(), request, response, null);
523489
assertThat(endAttributes.build())
@@ -541,8 +507,6 @@ void shouldExtractPeerAddressEvenIfItDuplicatesClientAddress() {
541507

542508
AttributesBuilder startAttributes = Attributes.builder();
543509
extractor.onStart(startAttributes, Context.root(), request);
544-
// assertThat(startAttributes.build())
545-
// .containsOnly(entry(ClientAttributes.CLIENT_ADDRESS, "1.2.3.4"));
546510

547511
AttributesBuilder endAttributes = Attributes.builder();
548512
extractor.onEnd(endAttributes, Context.root(), request, response, null);

0 commit comments

Comments
 (0)