Skip to content

Commit

Permalink
Log service discovery requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper committed Oct 30, 2023
1 parent 67096de commit 1977f52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ public void start() {

public Discovery.ServiceDiscoveryResponse handleDiscoveryRequest(
Discovery.ServiceDiscoveryRequest request) {
return this.serviceDiscoveryHandler.handle(request);
Discovery.ServiceDiscoveryResponse response = this.serviceDiscoveryHandler.handle(request);
LOG.info(
"Replying to service discovery request with services [{}]",
String.join(",", response.getServicesList()));
return response;
}

// -- Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RequestHttpServerHandler implements Handler<HttpServerRequest> {

private static final Pattern SLASH = Pattern.compile(Pattern.quote("/"));

private static final String SERVICES_PATH = "/discover";
private static final String DISCOVER_PATH = "/discover";

static TextMapGetter<MultiMap> OTEL_TEXT_MAP_GETTER =
new TextMapGetter<>() {
Expand Down Expand Up @@ -72,15 +72,17 @@ public void handle(HttpServerRequest request) {
URI uri = URI.create(request.uri());

// Let's first check if it's a discovery request
if (SERVICES_PATH.equalsIgnoreCase(uri.getPath())) {
if (DISCOVER_PATH.equalsIgnoreCase(uri.getPath())) {
this.handleDiscoveryRequest(request);
return;
}

// Parse request
String[] pathSegments = SLASH.split(uri.getPath());
if (pathSegments.length < 3) {
LOG.warn("Path doesn't match the pattern /invoke/SvcName/MethodName: '{}'", request.path());
LOG.warn(
"Path doesn't match the pattern /invoke/SvcName/MethodName nor /discover: '{}'",
request.path());
request.response().setStatusCode(NOT_FOUND.code()).end();
return;
}
Expand Down

0 comments on commit 1977f52

Please sign in to comment.