Add Zipkin UI to webapp (#10167)

This commit is contained in:
kezhenxu94 2022-12-17 14:30:51 +08:00 committed by GitHub
parent 0c08a657ed
commit 4ee8389b5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 2934 additions and 7 deletions

2
.gitignore vendored
View File

@ -21,4 +21,4 @@ oap-server/oal-grammar/**/gen/
# This serves as a template but will ONLY be updated when building a source release tar,
# so we don't track future updates of this file.
oap-server/server-starter/src/main/resources/version.properties
oap-server/server-starter/src/main/resources/version.properties

View File

@ -71,6 +71,11 @@
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin</groupId>
<artifactId>zipkin-lens</artifactId>
</dependency>
<dependency>
<groupId>com.linecorp.armeria</groupId>
<artifactId>armeria</artifactId>

View File

@ -20,14 +20,11 @@ package org.apache.skywalking.oap.server.webapp;
import static org.yaml.snakeyaml.env.EnvScalarConstructor.ENV_FORMAT;
import static org.yaml.snakeyaml.env.EnvScalarConstructor.ENV_TAG;
import java.util.Collections;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.TypeDescription;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.env.EnvScalarConstructor;
import com.linecorp.armeria.common.SessionProtocol;
import com.linecorp.armeria.server.HttpService;
import com.linecorp.armeria.server.Server;
@ -55,12 +52,25 @@ public class ApplicationStartUp {
HttpFile
.of(ApplicationStartUp.class.getClassLoader(), "/public/index.html")
.asService();
final HttpService zipkinIndexPage =
HttpFile
.of(ApplicationStartUp.class.getClassLoader(), "/zipkin-lens/index.html")
.asService();
final ZipkinProxyService zipkin = new ZipkinProxyService(configuration.zipkinServices());
Server
.builder()
.port(port, SessionProtocol.HTTP)
.service("/graphql", new OapProxyService(oapServices))
.service("/internal/l7check", HealthCheckService.of())
.service("/zipkin/config.json", zipkin)
.serviceUnder("/zipkin/api", zipkin)
.serviceUnder("/zipkin",
FileService.of(
ApplicationStartUp.class.getClassLoader(),
"/zipkin-lens")
.orElse(zipkinIndexPage))
.serviceUnder("/",
FileService.of(
ApplicationStartUp.class.getClassLoader(),

View File

@ -31,6 +31,7 @@ import lombok.NoArgsConstructor;
public class Configuration {
private String serverPort;
private String oapServices;
private String zipkinServices;
public int port() {
return serverPort == null || serverPort.trim().length() == 0
@ -44,4 +45,11 @@ public class Configuration {
}
return oapServices.split(",");
}
public String[] zipkinServices() {
if (zipkinServices == null || zipkinServices.trim().length() == 0) {
throw new IllegalArgumentException("zipkinServices cannot be null or empty");
}
return zipkinServices.split(",");
}
}

View File

@ -0,0 +1,67 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.skywalking.oap.server.webapp;
import static java.util.stream.Collectors.toList;
import java.net.URI;
import java.util.List;
import java.util.stream.Stream;
import com.linecorp.armeria.client.Endpoint;
import com.linecorp.armeria.client.WebClient;
import com.linecorp.armeria.client.endpoint.EndpointGroup;
import com.linecorp.armeria.client.endpoint.EndpointSelectionStrategy;
import com.linecorp.armeria.client.logging.LoggingClient;
import com.linecorp.armeria.common.HttpRequest;
import com.linecorp.armeria.common.HttpResponse;
import com.linecorp.armeria.common.SessionProtocol;
import com.linecorp.armeria.server.AbstractHttpService;
import com.linecorp.armeria.server.ServiceRequestContext;
import lombok.SneakyThrows;
public final class ZipkinProxyService extends AbstractHttpService {
private final WebClient loadBalancingClient;
public ZipkinProxyService(String[] zipkinServices) throws Exception {
final List<Endpoint> endpoints =
Stream
.of(zipkinServices)
.map(URI::create)
.map(URI::getAuthority)
.map(Endpoint::parse)
.collect(toList());
loadBalancingClient = newLoadBalancingClient(
EndpointGroup.of(
EndpointSelectionStrategy.roundRobin(),
endpoints));
}
@SneakyThrows
private static WebClient newLoadBalancingClient(EndpointGroup zipkinGroup) {
return WebClient
.builder(SessionProtocol.HTTP, zipkinGroup)
.decorator(LoggingClient.newDecorator())
.build();
}
@Override
protected HttpResponse doGet(ServiceRequestContext ctx, HttpRequest req) throws Exception {
return loadBalancingClient.execute(req);
}
}

View File

@ -18,3 +18,5 @@ serverPort: ${SW_SERVER_PORT:-8080}
# Comma seperated list of OAP addresses.
oapServices: ${SW_OAP_ADDRESS:-http://localhost:12800}
zipkinServices: ${SW_ZIPKIN_ADDRESS:-http://localhost:9412}

4
dist-material/release-docs/LICENSE Executable file → Normal file
View File

@ -340,6 +340,7 @@ The text of each license is the standard Apache 2.0 license.
https://mvnrepository.com/artifact/io.vavr/vavr/0.10.3 Apache-2.0
https://mvnrepository.com/artifact/io.vavr/vavr-match/0.10.3 Apache-2.0
https://mvnrepository.com/artifact/io.zipkin.zipkin2/zipkin/2.23.16 Apache-2.0
https://mvnrepository.com/artifact/io.zipkin/zipkin-lens/2.23.16 Apache-2.0
https://mvnrepository.com/artifact/javax.inject/javax.inject/1 Apache-2.0
https://mvnrepository.com/artifact/joda-time/joda-time/2.10.5 Apache-2.0
https://mvnrepository.com/artifact/net.jodah/failsafe/2.3.4 Apache-2.0
@ -637,3 +638,6 @@ The text of each license is also included in licenses/LICENSE-[project].txt.
https://mvnrepository.com/artifact/org.reactivestreams/reactive-streams/1.0.4 https://spdx.org/licenses/MIT-0.html
=======================================================================
The zipkin-lens.jar dependency has more front-end dependencies in it and the front-end dependencies' licenses
are listed in zipkin-LICENSE.

View File

@ -31,3 +31,6 @@ The text of each license is also included in licenses/LICENSE-[project].txt.
{{- end }}
{{- end }}
{{ end }}
=======================================================================
The zipkin-lens.jar dependency has more front-end dependencies in it and the front-end dependencies' licenses
are listed in zipkin-LICENSE.

File diff suppressed because it is too large Load Diff

View File

@ -72,3 +72,4 @@ services:
- "8080:8080"
environment:
SW_OAP_ADDRESS: http://oap:12800
SW_ZIPKIN_ADDRESS: http://oap:9412

View File

@ -17,7 +17,8 @@
FROM eclipse-temurin:11-jre
ENV JAVA_OPTS=" -Xms256M " \
SW_OAP_ADDRESS="127.0.0.1:12800"
SW_OAP_ADDRESS="http://127.0.0.1:12800" \
SW_ZIPKIN_ADDRESS="http://127.0.0.1:9412"
WORKDIR skywalking

View File

@ -33,7 +33,7 @@
* Remove the dependency of `refresh_interval` of ElasticSearch indices from `elasticsearch/flushInterval` config. Now,
it uses `core/persistentPeriod` + 5s as `refresh_interval` for all indices instead.
* Change `elasticsearch/flushInterval` to 5s(was 15s).
* Optimize `flushInterval` of ElasticSearch BulkProcessor to avoid extra periodical flush in the continuous bulk streams.
* Optimize `flushInterval` of ElasticSearch BulkProcessor to avoid extra periodical flush in the continuous bulk streams.
* An unexpected dot is added when exp is a pure metric name and expPrefix != null.
* Support monitoring MariaDB.
* Remove measure/stream specific interval settings in BanyanDB.
@ -51,6 +51,8 @@
#### UI
* Add Zipkin Lens UI to webapp, and proxy it to context path `/zipkin`.
#### Documentation
* Remove Spring Sleuth docs, and add `Spring MicroMeter Observations Analysis` with the latest Java agent side

View File

@ -15,6 +15,7 @@ serverPort: ${SW_SERVER_PORT:-8080}
# Comma separated list of OAP addresses, without http:// prefix.
oapServices: ${SW_OAP_ADDRESS:-localhost:12800}
zipkinServices: ${SW_ZIPKIN_ADDRESS:localhost:9412}
```
## Start with Docker Image
@ -22,7 +23,7 @@ oapServices: ${SW_OAP_ADDRESS:-localhost:12800}
Start a container to connect OAP server whose address is `http://oap:12800`.
```shell
docker run --name oap --restart always -d -e SW_OAP_ADDRESS=http://oap:12800 apache/skywalking-ui:8.8.0
docker run --name oap --restart always -d -e SW_OAP_ADDRESS=http://oap:12800 -e SW_ZIPKIN_ADDRESS=http://oap:9412 apache/skywalking-ui:8.8.0
```
### Configuration
@ -32,3 +33,7 @@ We could set up environment variables to configure this image.
### SW_OAP_ADDRESS
The address of your OAP server. The default value is `http://127.0.0.1:12800`.
### SW_ZIPKIN_ADDRESS
The address of your Zipkin server. The default value is `http://127.0.0.1:9412`.

View File

@ -304,6 +304,12 @@
<artifactId>zipkin</artifactId>
<version>${zipkin.version}</version>
</dependency>
<!-- SkyWalking Web UI -->
<dependency>
<groupId>io.zipkin</groupId>
<artifactId>zipkin-lens</artifactId>
<version>${zipkin.version}</version>
</dependency>
<!-- -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>

View File

@ -99,6 +99,7 @@ services:
service: ui
environment:
- SW_OAP_ADDRESS=http://oap1:12800,http://oap2:12800
- SW_ZIPKIN_ADDRESS=http://oap1:9412,http://oap2:9412
depends_on:
oap1:
condition: service_healthy

View File

@ -81,6 +81,7 @@ services:
service: ui
environment:
- SW_OAP_ADDRESS=http://oap1:12800,http://oap2:12800
- SW_ZIPKIN_ADDRESS=http://oap1:9412,http://oap2:9412
depends_on:
oap1:
condition: service_healthy

View File

@ -51,6 +51,7 @@ services:
- e2e
environment:
- SW_OAP_ADDRESS=http://oap:12800
- SW_ZIPKIN_ADDRESS=http://oap:9412
banyandb:
image: "ghcr.io/apache/skywalking-banyandb:${SW_BANYANDB_COMMIT}"