-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
armeria: showcase Eureka integration (#104)
Signed-off-by: Adrian Cole <[email protected]>
- Loading branch information
1 parent
fe58f3a
commit 9bdcd4c
Showing
8 changed files
with
176 additions
and
23 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
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,48 @@ | ||
package brave.example; | ||
|
||
import com.linecorp.armeria.client.WebClient; | ||
import com.linecorp.armeria.common.AggregatedHttpResponse; | ||
import com.linecorp.armeria.common.HttpData; | ||
import com.linecorp.armeria.common.HttpMethod; | ||
import com.linecorp.armeria.common.HttpRequest; | ||
import com.linecorp.armeria.common.MediaType; | ||
import java.io.IOException; | ||
import java.util.List; | ||
import zipkin2.reporter.BytesMessageEncoder; | ||
import zipkin2.reporter.BytesMessageSender; | ||
import zipkin2.reporter.ClosedSenderException; | ||
import zipkin2.reporter.Encoding; | ||
|
||
final class WebClientSender extends BytesMessageSender.Base { | ||
final WebClient zipkinApiV2SpansClient; | ||
volatile boolean closeCalled; // volatile as not called from the reporting thread. | ||
|
||
WebClientSender(WebClient zipkinApiV2SpansClient) { | ||
super(Encoding.JSON); | ||
this.zipkinApiV2SpansClient = zipkinApiV2SpansClient; | ||
} | ||
|
||
@Override public int messageMaxBytes() { | ||
return 500_000; // Use the most common HTTP default | ||
} | ||
|
||
@Override public void send(List<byte[]> encodedSpans) throws IOException { | ||
if (closeCalled) throw new ClosedSenderException(); | ||
byte[] body = BytesMessageEncoder.JSON.encode(encodedSpans); | ||
HttpRequest request = | ||
HttpRequest.of(HttpMethod.POST, "", MediaType.JSON, HttpData.wrap(body)); | ||
AggregatedHttpResponse response = zipkinApiV2SpansClient.blocking().execute(request); | ||
try (HttpData content = response.content()) { | ||
if (!response.status().isSuccess()) { | ||
if (content.isEmpty()) { | ||
throw new IOException("response failed: " + response); | ||
} | ||
throw new IOException("response failed: " + content.toStringAscii()); | ||
} | ||
} | ||
} | ||
|
||
@Override public void close() { | ||
closeCalled = true; | ||
} | ||
} |
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,41 @@ | ||
# permit depends_on/condition: service_healthy | ||
version: '2.4' | ||
|
||
services: | ||
eureka: | ||
image: ghcr.io/openzipkin/zipkin-eureka | ||
container_name: eureka | ||
# Uncomment to expose the eureka port for testing | ||
# ports: | ||
# - 8761:8761 | ||
|
||
zipkin: | ||
extends: | ||
file: docker-compose.yml | ||
service: zipkin | ||
environment: | ||
- EUREKA_SERVICE_URL=http://eureka:8761/eureka/v2 | ||
- EUREKA_HOSTNAME=zipkin | ||
depends_on: | ||
eureka: | ||
condition: service_healthy | ||
|
||
frontend: | ||
extends: | ||
file: docker-compose.yml | ||
service: frontend | ||
environment: | ||
- EUREKA_SERVICE_URL=http://eureka:8761/eureka/v2 | ||
depends_on: | ||
eureka: | ||
condition: service_healthy | ||
|
||
backend: | ||
extends: | ||
file: docker-compose.yml | ||
service: backend | ||
environment: | ||
- EUREKA_SERVICE_URL=http://eureka:8761/eureka/v2 | ||
depends_on: | ||
eureka: | ||
condition: service_healthy |
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