-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #821 from zalando/bugfix/negative-port
Fixed -1 peer.port
- Loading branch information
Showing
4 changed files
with
64 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...opentracing/src/test/java/org/zalando/riptide/opentracing/span/PeerSpanDecoratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.zalando.riptide.opentracing.span; | ||
|
||
import io.opentracing.mock.MockSpan; | ||
import io.opentracing.mock.MockTracer; | ||
import org.junit.jupiter.api.Test; | ||
import org.zalando.riptide.RequestArguments; | ||
|
||
import java.net.URI; | ||
import java.util.Map; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.hasEntry; | ||
import static org.hamcrest.Matchers.hasKey; | ||
import static org.hamcrest.Matchers.not; | ||
|
||
final class PeerSpanDecoratorTest { | ||
|
||
private final SpanDecorator unit = new PeerSpanDecorator(); | ||
|
||
@Test | ||
void shouldIgnoreAbsentPort() { | ||
final MockTracer tracer = new MockTracer(); | ||
final MockSpan span = tracer.buildSpan("test").start(); | ||
|
||
final RequestArguments arguments = RequestArguments.create() | ||
.withBaseUrl(URI.create("http://localhost")) | ||
.withUriTemplate("/test"); | ||
|
||
unit.onRequest(span, arguments); | ||
|
||
final Map<String, Object> tags = span.tags(); | ||
|
||
assertThat(tags, hasEntry("peer.hostname", "localhost")); | ||
assertThat(tags, hasEntry("peer.address", "localhost")); | ||
assertThat(tags, not(hasKey("peer.port"))); | ||
} | ||
|
||
} |