-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* TCK OpenTracing * Fix absolute path handling in Routing and base path handling in JAX-RS * Only send trailer headers when expected by the client.
- Loading branch information
1 parent
7c9381e
commit b47ae71
Showing
17 changed files
with
620 additions
and
186 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
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,32 @@ | ||
# | ||
# Copyright (c) 2022 Oracle and/or its affiliates. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# Example Logging Configuration File | ||
# For more information see $JAVA_HOME/jre/lib/logging.properties | ||
|
||
# Send messages to the console | ||
handlers=io.helidon.logging.jul.HelidonConsoleHandler | ||
|
||
# HelidonConsoleHandler uses a SimpleFormatter subclass that replaces "!thread!" with the current thread | ||
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n | ||
|
||
# Global logging level. Can be overridden by specific loggers | ||
.level=WARNING | ||
|
||
io.helidon.level=INFO | ||
|
||
|
||
|
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
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
170 changes: 170 additions & 0 deletions
170
.../webserver/tracing/src/main/java/io/helidon/nima/webserver/tracing/PathTracingConfig.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,170 @@ | ||
/* | ||
* Copyright (c) 2019, 2022 Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.helidon.nima.webserver.tracing; | ||
|
||
import java.util.Collection; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import io.helidon.common.http.Http; | ||
import io.helidon.common.http.PathMatcher; | ||
import io.helidon.common.http.PathMatchers; | ||
import io.helidon.common.uri.UriPath; | ||
import io.helidon.config.Config; | ||
import io.helidon.tracing.config.TracingConfig; | ||
|
||
/** | ||
* Traced system configuration for web server for a specific path. | ||
*/ | ||
public interface PathTracingConfig { | ||
/** | ||
* Create a new traced path configuration from {@link io.helidon.config.Config}. | ||
* | ||
* @param config config of a path | ||
* @return traced path configuration | ||
*/ | ||
static PathTracingConfig create(Config config) { | ||
return builder().config(config).build(); | ||
} | ||
|
||
/** | ||
* Create a new builder to configure traced path configuration. | ||
* | ||
* @return a new builder instance | ||
*/ | ||
static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
/** | ||
* Method used by Helidon to check if this tracing is valid for the specified method and path. | ||
* | ||
* @param method HTTP method | ||
* @param path invoked path | ||
* @return {@code true} if matched | ||
*/ | ||
boolean matches(Http.Method method, UriPath path); | ||
|
||
/** | ||
* Associated configuration of tracing valid for the configured path and (possibly) methods. | ||
* | ||
* @return traced system configuration | ||
*/ | ||
TracingConfig tracedConfig(); | ||
|
||
/** | ||
* Fluent API builder for {@link io.helidon.nima.webserver.tracing.PathTracingConfig}. | ||
*/ | ||
final class Builder implements io.helidon.common.Builder<Builder, PathTracingConfig> { | ||
private final List<String> methods = new LinkedList<>(); | ||
private String path; | ||
private TracingConfig tracedConfig; | ||
|
||
private Builder() { | ||
} | ||
|
||
@Override | ||
public PathTracingConfig build() { | ||
// immutable | ||
final Collection<Http.Method> finalMethods = methods.stream() | ||
.map(Http.Method::create) | ||
.toList(); | ||
final TracingConfig finalTracingConfig = tracedConfig; | ||
|
||
PathMatcher pathMatcher = PathMatchers.create(path); | ||
Http.MethodPredicate methodPredicate = Http.Method.predicate(finalMethods); | ||
|
||
return new PathTracingConfig() { | ||
@Override | ||
public boolean matches(Http.Method method, UriPath path) { | ||
return methodPredicate.test(method) && pathMatcher.match(path).accepted(); | ||
} | ||
|
||
@Override | ||
public TracingConfig tracedConfig() { | ||
return finalTracingConfig; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return path + "(" + finalMethods + "): " + finalTracingConfig; | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* Update this builder from provided {@link io.helidon.config.Config}. | ||
* | ||
* @param config config to update this builder from | ||
* @return updated builder instance | ||
*/ | ||
public Builder config(Config config) { | ||
path(config.get("path").asString().get()); | ||
List<String> methods = config.get("methods").asList(String.class).orElse(null); | ||
if (null != methods) { | ||
methods(methods); | ||
} | ||
tracingConfig(TracingConfig.create(config)); | ||
|
||
return this; | ||
} | ||
|
||
/** | ||
* Path to register the traced configuration on. | ||
* | ||
* @param path path as understood by {@link io.helidon.nima.webserver.http.HttpRouting.Builder} of web server | ||
* @return updated builder instance | ||
*/ | ||
public Builder path(String path) { | ||
this.path = path; | ||
return this; | ||
} | ||
|
||
/** | ||
* HTTP methods to restrict registration of this configuration on web server. | ||
* | ||
* @param methods list of methods to use, empty means all methods | ||
* @return updated builder instance | ||
*/ | ||
public Builder methods(List<String> methods) { | ||
this.methods.clear(); | ||
this.methods.addAll(methods); | ||
return this; | ||
} | ||
|
||
/** | ||
* Add a new HTTP method to restrict this configuration for. | ||
* | ||
* @param method method to add to the list of supported methods | ||
* @return updated builder instance | ||
*/ | ||
public Builder addMethod(String method) { | ||
this.methods.add(method); | ||
return this; | ||
} | ||
|
||
/** | ||
* Configuration of a traced system to use on this path and possibly method(s). | ||
* | ||
* @param tracedConfig configuration of components, spans and span logs | ||
* @return updated builder instance | ||
*/ | ||
public Builder tracingConfig(TracingConfig tracedConfig) { | ||
this.tracedConfig = tracedConfig; | ||
return this; | ||
} | ||
} | ||
} |
Oops, something went wrong.