Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
7bbe0693
S
SkyWalking
项目概览
山不在高_有仙则灵
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
12
Star
0
Fork
2
代码
文件
提交
分支
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 搜索 >>
提交
7bbe0693
编写于
10月 31, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make service instrument works
上级
11b2170a
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
148 addition
and
32 deletion
+148
-32
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleManager.java
...g/skywalking/apm/collector/core/module/ModuleManager.java
+1
-1
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/MetricCollector.java
...apm/collector/core/module/instrument/MetricCollector.java
+28
-0
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/ServiceInstrumentation.java
...lector/core/module/instrument/ServiceInstrumentation.java
+4
-1
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleABusiness1Impl.java
...lking/apm/collector/core/module/ModuleABusiness1Impl.java
+28
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleABusiness2Impl.java
...lking/apm/collector/core/module/ModuleABusiness2Impl.java
+26
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleAProvider.java
...skywalking/apm/collector/core/module/ModuleAProvider.java
+2
-12
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBBusiness1Impl.java
...lking/apm/collector/core/module/ModuleBBusiness1Impl.java
+25
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBBusiness2Impl.java
...lking/apm/collector/core/module/ModuleBBusiness2Impl.java
+25
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBProvider.java
...skywalking/apm/collector/core/module/ModuleBProvider.java
+2
-10
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleManagerTest.java
...ywalking/apm/collector/core/module/ModuleManagerTest.java
+7
-8
未找到文件。
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleManager.java
浏览文件 @
7bbe0693
...
...
@@ -31,7 +31,7 @@ import java.util.ServiceLoader;
*/
public
class
ModuleManager
{
private
Map
<
String
,
Module
>
loadedModules
=
new
HashMap
<>();
private
boolean
isServiceInstrument
=
fals
e
;
private
boolean
isServiceInstrument
=
tru
e
;
/**
* Init the given modules
...
...
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/MetricCollector.java
0 → 100644
浏览文件 @
7bbe0693
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.module.instrument
;
/**
* The <code>MetricCollector</code> collects the service metrics by Module/Provider/Service structure.
*/
public
enum
MetricCollector
{
INSTANCE
;
}
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/instrument/ServiceInstrumentation.java
浏览文件 @
7bbe0693
...
...
@@ -31,6 +31,9 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
not
;
/**
* The <code>ServiceInstrumentation</code> create the dynamic service implementations based on the provider
* implementation. So the new implementation will report performance metric to {@link MetricCollector}.
*
* @author wu-sheng
*/
public
enum
ServiceInstrumentation
{
...
...
@@ -40,7 +43,7 @@ public enum ServiceInstrumentation {
private
ElementMatcher
<?
super
MethodDescription
>
excludeObjectMethodsMatcher
;
public
Service
buildServiceUnderMonitor
(
Service
implementation
)
{
if
(
TracedService
.
class
.
isInstance
(
implementation
)
)
{
if
(
implementation
instanceof
TracedService
)
{
// Duplicate service instrument, ignore.
return
implementation
;
}
...
...
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleABusiness1Impl.java
0 → 100644
浏览文件 @
7bbe0693
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.module
;
/**
* @author wu-sheng
*/
public
class
ModuleABusiness1Impl
implements
BaseModuleA
.
ServiceABusiness1
{
@Override
public
void
print
()
{
}
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleABusiness2Impl.java
0 → 100644
浏览文件 @
7bbe0693
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.module
;
/**
* @author wu-sheng
*/
public
class
ModuleABusiness2Impl
implements
BaseModuleA
.
ServiceABusiness2
{
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleAProvider.java
浏览文件 @
7bbe0693
...
...
@@ -33,11 +33,11 @@ public class ModuleAProvider extends ModuleProvider {
}
@Override
public
void
prepare
(
Properties
config
)
throws
ServiceNotProvidedException
{
this
.
registerServiceImplementation
(
BaseModuleA
.
ServiceABusiness1
.
class
,
new
Business1
());
this
.
registerServiceImplementation
(
BaseModuleA
.
ServiceABusiness1
.
class
,
new
ModuleABusiness1Impl
());
}
@Override
public
void
start
(
Properties
config
)
throws
ServiceNotProvidedException
{
this
.
registerServiceImplementation
(
BaseModuleA
.
ServiceABusiness2
.
class
,
new
Business2
());
this
.
registerServiceImplementation
(
BaseModuleA
.
ServiceABusiness2
.
class
,
new
ModuleABusiness2Impl
());
}
@Override
public
void
notifyAfterCompleted
()
throws
ServiceNotProvidedException
{
...
...
@@ -47,14 +47,4 @@ public class ModuleAProvider extends ModuleProvider {
@Override
public
String
[]
requiredModules
()
{
return
new
String
[
0
];
}
public
class
Business1
implements
BaseModuleA
.
ServiceABusiness1
{
@Override
public
void
print
()
{
}
}
public
class
Business2
implements
BaseModuleA
.
ServiceABusiness2
{
}
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBBusiness1Impl.java
0 → 100644
浏览文件 @
7bbe0693
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.module
;
/**
* @author wu-sheng
*/
public
class
ModuleBBusiness1Impl
implements
BaseModuleB
.
ServiceBBusiness1
{
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBBusiness2Impl.java
0 → 100644
浏览文件 @
7bbe0693
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.module
;
/**
* @author wu-sheng
*/
public
class
ModuleBBusiness2Impl
implements
BaseModuleB
.
ServiceBBusiness2
{
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleBProvider.java
浏览文件 @
7bbe0693
...
...
@@ -33,11 +33,11 @@ public class ModuleBProvider extends ModuleProvider {
}
@Override
public
void
prepare
(
Properties
config
)
throws
ServiceNotProvidedException
{
this
.
registerServiceImplementation
(
BaseModuleB
.
ServiceBBusiness1
.
class
,
new
Business1
());
this
.
registerServiceImplementation
(
BaseModuleB
.
ServiceBBusiness1
.
class
,
new
ModuleBBusiness1Impl
());
}
@Override
public
void
start
(
Properties
config
)
throws
ServiceNotProvidedException
{
this
.
registerServiceImplementation
(
BaseModuleB
.
ServiceBBusiness2
.
class
,
new
Business2
());
this
.
registerServiceImplementation
(
BaseModuleB
.
ServiceBBusiness2
.
class
,
new
ModuleBBusiness2Impl
());
}
@Override
public
void
notifyAfterCompleted
()
throws
ServiceNotProvidedException
{
...
...
@@ -47,12 +47,4 @@ public class ModuleBProvider extends ModuleProvider {
@Override
public
String
[]
requiredModules
()
{
return
new
String
[
0
];
}
public
class
Business1
implements
BaseModuleB
.
ServiceBBusiness1
{
}
public
class
Business2
implements
BaseModuleB
.
ServiceBBusiness2
{
}
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/module/ModuleManagerTest.java
浏览文件 @
7bbe0693
...
...
@@ -30,29 +30,28 @@ public class ModuleManagerTest {
public
void
testInit
()
throws
ServiceNotProvidedException
,
ModuleNotFoundException
,
ProviderNotFoundException
,
DuplicateProviderException
{
ApplicationConfiguration
configuration
=
new
ApplicationConfiguration
();
configuration
.
addModule
(
"Test"
).
addProviderConfiguration
(
"TestModule-Provider"
,
null
);
configuration
.
addModule
(
"BaseA"
).
addProviderConfiguration
(
"P-A"
,
null
);
configuration
.
addModule
(
"BaseB"
).
addProviderConfiguration
(
"P-B"
,
null
);
configuration
.
addModule
(
"BaseA"
).
addProviderConfiguration
(
"P-A"
,
null
);
configuration
.
addModule
(
"BaseB"
).
addProviderConfiguration
(
"P-B"
,
null
);
ModuleManager
manager
=
new
ModuleManager
();
manager
.
init
(
configuration
);
BaseModuleA
.
ServiceABusiness1
serviceABusiness1
=
manager
.
find
(
"BaseA"
).
provider
().
getService
(
BaseModuleA
.
ServiceABusiness1
.
class
);
serviceABusiness1
.
print
(
);
Assert
.
assertTrue
(
serviceABusiness1
!=
null
);
}
//
@Test
@Test
public
void
testInstrument
()
throws
ServiceNotProvidedException
,
ModuleNotFoundException
,
ProviderNotFoundException
,
DuplicateProviderException
{
ApplicationConfiguration
configuration
=
new
ApplicationConfiguration
();
configuration
.
addModule
(
"Test"
).
addProviderConfiguration
(
"TestModule-Provider"
,
null
);
configuration
.
addModule
(
"BaseA"
).
addProviderConfiguration
(
"P-A"
,
null
);
configuration
.
addModule
(
"BaseB"
).
addProviderConfiguration
(
"P-B"
,
null
);
configuration
.
addModule
(
"BaseA"
).
addProviderConfiguration
(
"P-A"
,
null
);
configuration
.
addModule
(
"BaseB"
).
addProviderConfiguration
(
"P-B"
,
null
);
ModuleManager
manager
=
new
ModuleManager
();
manager
.
setServiceInstrument
(
true
);
manager
.
init
(
configuration
);
BaseModuleA
.
ServiceABusiness1
serviceABusiness1
=
manager
.
find
(
"BaseA"
).
provider
().
getService
(
BaseModuleA
.
ServiceABusiness1
.
class
);
serviceABusiness1
.
print
();
BaseModuleA
.
ServiceABusiness1
serviceABusiness1
=
manager
.
find
(
"BaseA"
).
getService
(
BaseModuleA
.
ServiceABusiness1
.
class
);
Assert
.
assertTrue
(
serviceABusiness1
instanceof
TracedService
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录