Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
70393389
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 1 年多
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
70393389
编写于
2月 27, 2018
作者:
H
hanahmily
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add apm-webapp module
上级
7f83f427
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
482 addition
and
5 deletion
+482
-5
apm-webapp/pom.xml
apm-webapp/pom.xml
+157
-0
apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/ApplicationStartUp.java
.../org/apache/skywalking/apm/webapp/ApplicationStartUp.java
+42
-0
apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/config/UIConfig.java
...ava/org/apache/skywalking/apm/webapp/config/UIConfig.java
+36
-0
apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/CollectorServerList.java
...ache/skywalking/apm/webapp/tools/CollectorServerList.java
+89
-0
apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/HttpClientTools.java
...g/apache/skywalking/apm/webapp/tools/HttpClientTools.java
+73
-0
apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/RewritePathFilter.java
...apache/skywalking/apm/webapp/tools/RewritePathFilter.java
+65
-0
apm-webapp/src/main/resources/application.yml
apm-webapp/src/main/resources/application.yml
+14
-0
pom.xml
pom.xml
+6
-5
未找到文件。
apm-webapp/pom.xml
0 → 100644
浏览文件 @
70393389
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
apm
</artifactId>
<groupId>
org.apache.skywalking
</groupId>
<version>
5.0.0-alpha-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apm-webapp
</artifactId>
<packaging>
jar
</packaging>
<properties>
<compiler.version>
1.8
</compiler.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<spring.boot.version>
1.5.10.RELEASE
</spring.boot.version>
<log4j.version>
2.6.2
</log4j.version>
<ui.path>
${project.parent.basedir}/skywalking-ui/src/main/frontend
</ui.path>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-dependencies
</artifactId>
<version>
Edgware.SR1
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<version>
${spring.boot.version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
<version>
${spring.boot.version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-configuration-processor
</artifactId>
<version>
${spring.boot.version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-devtools
</artifactId>
<version>
${spring.boot.version}
</version>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
2.8.2
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.3
</version>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-config
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-zuul
</artifactId>
</dependency>
</dependencies>
<build>
<finalName>
skywalking-webapp
</finalName>
<resources>
</resources>
<plugins>
<plugin>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
${compiler.version}
</source>
<target>
${compiler.version}
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
<plugin>
<groupId>
com.github.eirslett
</groupId>
<artifactId>
frontend-maven-plugin
</artifactId>
<version>
1.6
</version>
<configuration>
<workingDirectory>
${ui.path}
</workingDirectory>
<nodeVersion>
v8.9.4
</nodeVersion>
</configuration>
<executions>
<execution>
<id>
install node and npm
</id>
<goals>
<goal>
install-node-and-npm
</goal>
</goals>
</execution>
<execution>
<id>
npm install
</id>
<goals>
<goal>
npm
</goal>
</goals>
<configuration>
<arguments>
install --registry=http://registry.npmjs.org/
</arguments>
</configuration>
</execution>
<execution>
<id>
npm run build
</id>
<goals>
<goal>
npm
</goal>
</goals>
<configuration>
<arguments>
run build
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-resources-plugin
</artifactId>
<configuration>
<encoding>
${project.build.sourceEncoding}
</encoding>
<outputDirectory>
${project.build.directory}
</outputDirectory>
<resources>
<resource>
<targetPath>
${basedir}/target/classes/public
</targetPath>
<directory>
${ui.path}/dist
</directory>
</resource>
<resource>
<targetPath>
${basedir}/target/classes
</targetPath>
<directory>
src/main/resources
</directory>
</resource>
</resources>
</configuration>
</plugin>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<version>
${spring.boot.version}
</version>
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/ApplicationStartUp.java
0 → 100644
浏览文件 @
70393389
/*
* 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.apm.webapp
;
import
org.apache.skywalking.apm.webapp.config.UIConfig
;
import
org.apache.skywalking.apm.webapp.tools.RewritePathFilter
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.web.support.SpringBootServletInitializer
;
import
org.springframework.cloud.netflix.zuul.EnableZuulProxy
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Bean
;
@SpringBootApplication
@EnableZuulProxy
public
class
ApplicationStartUp
extends
SpringBootServletInitializer
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ApplicationContext
applicationContext
=
SpringApplication
.
run
(
ApplicationStartUp
.
class
,
args
);
}
@Bean
public
RewritePathFilter
addWritePathFilter
(
UIConfig
uiConfig
)
{
return
new
RewritePathFilter
(
uiConfig
.
getRewritePath
());
}
}
apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/config/UIConfig.java
0 → 100644
浏览文件 @
70393389
/*
* 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.apm.webapp.config
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Configuration
;
/**
* @author peng-yongsheng
*/
@Configuration
public
class
UIConfig
{
@Value
(
"${collector.path}"
)
private
String
rewritePath
;
public
String
getRewritePath
()
{
return
rewritePath
;
}
}
apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/CollectorServerList.java
0 → 100644
浏览文件 @
70393389
/*
* 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.apm.webapp.tools
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.Lists
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonArray
;
import
com.netflix.client.config.CommonClientConfigKey
;
import
com.netflix.client.config.IClientConfig
;
import
com.netflix.loadbalancer.AbstractServerList
;
import
com.netflix.loadbalancer.Server
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.stream.Collectors
;
import
java.util.stream.StreamSupport
;
public
class
CollectorServerList
extends
AbstractServerList
<
Server
>
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CollectorServerList
.
class
);
private
final
CopyOnWriteArrayList
<
Server
>
servers
=
new
CopyOnWriteArrayList
<>();
private
final
Gson
gson
=
new
Gson
();
private
IClientConfig
clientConfig
;
public
List
<
Server
>
getInitialListOfServers
()
{
return
fetchServer
();
}
public
List
<
Server
>
getUpdatedListOfServers
()
{
return
fetchServer
();
}
public
void
initWithNiwsConfig
(
IClientConfig
clientConfig
)
{
this
.
clientConfig
=
clientConfig
;
}
protected
List
<
Server
>
derive
(
String
value
)
{
List
<
Server
>
list
=
Lists
.
newArrayList
();
if
(
Strings
.
isNullOrEmpty
(
value
))
{
return
list
;
}
String
[]
serverArray
=
value
.
split
(
","
);
for
(
String
s
:
serverArray
)
{
list
.
add
(
new
Server
(
s
.
trim
()));
}
return
list
;
}
private
List
<
Server
>
fetchServer
()
{
for
(
Server
server
:
derive
(
this
.
clientConfig
.
get
(
CommonClientConfigKey
.
ListOfServers
)))
{
try
{
String
uiServerResponse
=
HttpClientTools
.
INSTANCE
.
get
(
"http://"
+
server
.
getHostPort
()
+
"/ui/jetty"
,
null
);
logger
.
debug
(
"uiServerResponse: {}"
,
uiServerResponse
);
JsonArray
serverArray
=
gson
.
fromJson
(
uiServerResponse
,
JsonArray
.
class
);
if
(
serverArray
==
null
||
serverArray
.
size
()
==
0
)
{
logger
.
warn
(
"emtry grpc server array, skip : {}"
,
server
);
continue
;
}
return
Lists
.
newArrayList
(
StreamSupport
.
stream
(
serverArray
.
spliterator
(),
false
).
map
(
f
->
new
Server
(
f
.
getAsString
())).
collect
(
Collectors
.
toList
()));
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
logger
.
warn
(
"none agentstream server return available grpc server."
);
return
servers
;
}
}
apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/HttpClientTools.java
0 → 100644
浏览文件 @
70393389
/*
* 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.apm.webapp.tools
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.util.List
;
/**
* @author peng-yongsheng
*/
public
enum
HttpClientTools
{
INSTANCE
;
private
Logger
logger
=
LoggerFactory
.
getLogger
(
HttpClientTools
.
class
);
public
String
get
(
String
url
,
List
<
NameValuePair
>
params
)
throws
IOException
{
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
try
{
HttpGet
httpget
=
new
HttpGet
(
url
);
if
(
params
==
null
)
{
httpget
.
setURI
(
new
URI
(
httpget
.
getURI
().
toString
()));
}
else
{
String
paramStr
=
EntityUtils
.
toString
(
new
UrlEncodedFormEntity
(
params
));
httpget
.
setURI
(
new
URI
(
httpget
.
getURI
().
toString
()
+
"?"
+
paramStr
));
}
logger
.
debug
(
"executing get request %s"
,
httpget
.
getURI
());
try
(
CloseableHttpResponse
response
=
httpClient
.
execute
(
httpget
))
{
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
{
return
EntityUtils
.
toString
(
entity
);
}
}
}
catch
(
Exception
e
)
{
logger
.
warn
(
"bad url="
+
url
,
e
);
}
finally
{
try
{
httpClient
.
close
();
}
catch
(
IOException
e
)
{
logger
.
warn
(
"bad url="
+
url
,
e
);
}
}
return
null
;
}
}
apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/RewritePathFilter.java
0 → 100644
浏览文件 @
70393389
/*
* 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.apm.webapp.tools
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.context.RequestContext
;
import
static
org
.
springframework
.
cloud
.
netflix
.
zuul
.
filters
.
support
.
FilterConstants
.
PRE_DECORATION_FILTER_ORDER
;
/**
* Rewrite url to rewritePath
*
* @author gaohongtao
*/
public
class
RewritePathFilter
extends
ZuulFilter
{
private
static
final
String
REQUEST_URI
=
"requestURI"
;
private
static
final
int
ORDER
=
PRE_DECORATION_FILTER_ORDER
+
1
;
public
RewritePathFilter
(
String
rewritePath
)
{
this
.
rewritePath
=
rewritePath
;
}
private
final
String
rewritePath
;
@Override
public
int
filterOrder
()
{
return
ORDER
;
}
@Override
public
String
filterType
()
{
return
"pre"
;
}
@Override
public
boolean
shouldFilter
()
{
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
return
ctx
.
containsKey
(
REQUEST_URI
);
}
@Override
public
Object
run
()
{
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
ctx
.
set
(
REQUEST_URI
,
rewritePath
);
return
null
;
}
}
apm-webapp/src/main/resources/application.yml
0 → 100644
浏览文件 @
70393389
server
:
port
:
8080
zuul
:
ignoredServices
:
'
*'
routes
:
api
:
path
:
/api/**
serviceId
:
collector
collector
:
path
:
/graphql
ribbon
:
listOfServers
:
127.0.0.1:10800
NIWSServerListClassName
:
org.apache.skywalking.apm.webapp.tools.CollectorServerList
pom.xml
浏览文件 @
70393389
...
...
@@ -58,11 +58,12 @@
</developers>
<modules>
<module>
apm-commons
</module>
<module>
apm-sniffer
</module>
<module>
apm-application-toolkit
</module>
<module>
apm-collector
</module>
<module>
apm-protocol
</module>
<!--<module>apm-commons</module>-->
<!--<module>apm-sniffer</module>-->
<!--<module>apm-application-toolkit</module>-->
<!--<module>apm-collector</module>-->
<!--<module>apm-protocol</module>-->
<module>
apm-webapp
</module>
</modules>
<packaging>
pom
</packaging>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录