Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
494d2a5b
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 搜索 >>
未验证
提交
494d2a5b
编写于
8月 19, 2020
作者:
于
于玉桔
提交者:
GitHub
8月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Elastic job plugin use wrong span type (#5347)
上级
7ceb3bc8
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
28 addition
and
22 deletion
+28
-22
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/tag/Tags.java
...rg/apache/skywalking/apm/agent/core/context/tag/Tags.java
+2
-0
apm-sniffer/apm-sdk-plugin/elastic-job-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticjob/ElasticJobExecutorInterceptor.java
.../apm/plugin/elasticjob/ElasticJobExecutorInterceptor.java
+3
-2
apm-sniffer/apm-sdk-plugin/graphql-plugin/graphql-12.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/graphql/v12/GraphqlInterceptor.java
...skywalking/apm/plugin/graphql/v12/GraphqlInterceptor.java
+1
-5
apm-sniffer/apm-sdk-plugin/graphql-plugin/graphql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/graphql/v8/GraphqlInterceptor.java
.../skywalking/apm/plugin/graphql/v8/GraphqlInterceptor.java
+1
-5
apm-sniffer/apm-sdk-plugin/graphql-plugin/graphql-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/graphql/v9/GraphqlInterceptor.java
.../skywalking/apm/plugin/graphql/v9/GraphqlInterceptor.java
+1
-5
test/plugin/scenarios/elasticjob-3.x-scenario/config/expectedData.yaml
...cenarios/elasticjob-3.x-scenario/config/expectedData.yaml
+2
-1
test/plugin/scenarios/elasticjob-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticjob/controller/CaseController.java
...ng/apm/testcase/elasticjob/controller/CaseController.java
+5
-3
test/plugin/scenarios/elasticjob-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticjob/job/DemoSimpleJob.java
...skywalking/apm/testcase/elasticjob/job/DemoSimpleJob.java
+13
-1
未找到文件。
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/tag/Tags.java
浏览文件 @
494d2a5b
...
...
@@ -87,6 +87,8 @@ public final class Tags {
public
static
final
StringTag
LOGIC_ENDPOINT
=
new
StringTag
(
12
,
"x-le"
);
public
static
final
String
VAL_LOCAL_SPAN_AS_LOGIC_ENDPOINT
=
"{\"logic-span\":true}"
;
/**
* Creates a {@code StringTag} with the given key and cache it, if it's created before, simply return it without
* creating a new one.
...
...
apm-sniffer/apm-sdk-plugin/elastic-job-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticjob/ElasticJobExecutorInterceptor.java
浏览文件 @
494d2a5b
...
...
@@ -19,8 +19,8 @@
package
org.apache.skywalking.apm.plugin.elasticjob
;
import
org.apache.shardingsphere.elasticjob.api.listener.ShardingContexts
;
import
org.apache.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.tag.Tags
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
...
...
@@ -36,8 +36,9 @@ public class ElasticJobExecutorInterceptor implements InstanceMethodsAroundInter
ShardingContexts
shardingContexts
=
(
ShardingContexts
)
allArguments
[
0
];
Integer
item
=
(
Integer
)
allArguments
[
1
];
String
operateName
=
ComponentsDefine
.
ELASTIC_JOB
.
getName
()
+
"/"
+
shardingContexts
.
getJobName
();
AbstractSpan
span
=
ContextManager
.
create
EntrySpan
(
operateName
,
new
ContextCarrier
()
);
AbstractSpan
span
=
ContextManager
.
create
LocalSpan
(
operateName
);
span
.
setComponent
(
ComponentsDefine
.
ELASTIC_JOB
);
Tags
.
LOGIC_ENDPOINT
.
set
(
span
,
Tags
.
VAL_LOCAL_SPAN_AS_LOGIC_ENDPOINT
);
span
.
tag
(
"item"
,
item
==
null
?
""
:
String
.
valueOf
(
item
));
span
.
tag
(
"shardingTotalCount"
,
Integer
.
toString
(
shardingContexts
.
getShardingTotalCount
()));
span
.
tag
(
"taskId"
,
shardingContexts
.
getTaskId
());
...
...
apm-sniffer/apm-sdk-plugin/graphql-plugin/graphql-12.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/graphql/v12/GraphqlInterceptor.java
浏览文件 @
494d2a5b
...
...
@@ -39,7 +39,7 @@ public class GraphqlInterceptor implements InstanceMethodsAroundInterceptor {
return
;
}
AbstractSpan
span
=
ContextManager
.
createLocalSpan
(
parameters
.
getField
().
getSingleField
().
getName
());
Tags
.
LOGIC_ENDPOINT
.
set
(
span
,
buildLogicEndpointSpan
()
);
Tags
.
LOGIC_ENDPOINT
.
set
(
span
,
Tags
.
VAL_LOCAL_SPAN_AS_LOGIC_ENDPOINT
);
span
.
setComponent
(
ComponentsDefine
.
GRAPHQL
);
}
...
...
@@ -67,8 +67,4 @@ public class GraphqlInterceptor implements InstanceMethodsAroundInterceptor {
span
.
errorOccurred
();
span
.
log
(
throwable
);
}
private
String
buildLogicEndpointSpan
()
{
return
"{\"logic-span\":true}"
;
}
}
apm-sniffer/apm-sdk-plugin/graphql-plugin/graphql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/graphql/v8/GraphqlInterceptor.java
浏览文件 @
494d2a5b
...
...
@@ -48,7 +48,7 @@ public class GraphqlInterceptor implements InstanceMethodsAroundInterceptor {
return
;
}
AbstractSpan
span
=
ContextManager
.
createLocalSpan
(
parameters
.
getField
().
get
(
0
).
getName
());
Tags
.
LOGIC_ENDPOINT
.
set
(
span
,
buildLogicEndpointSpan
()
);
Tags
.
LOGIC_ENDPOINT
.
set
(
span
,
Tags
.
VAL_LOCAL_SPAN_AS_LOGIC_ENDPOINT
);
span
.
setComponent
(
ComponentsDefine
.
GRAPHQL
);
}
catch
(
NoSuchFieldException
|
IllegalAccessException
e
)
{
}
...
...
@@ -98,8 +98,4 @@ public class GraphqlInterceptor implements InstanceMethodsAroundInterceptor {
span
.
errorOccurred
();
span
.
log
(
throwable
);
}
private
String
buildLogicEndpointSpan
()
{
return
"{\"logic-span\":true}"
;
}
}
apm-sniffer/apm-sdk-plugin/graphql-plugin/graphql-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/graphql/v9/GraphqlInterceptor.java
浏览文件 @
494d2a5b
...
...
@@ -39,7 +39,7 @@ public class GraphqlInterceptor implements InstanceMethodsAroundInterceptor {
return
;
}
AbstractSpan
span
=
ContextManager
.
createLocalSpan
(
parameters
.
getField
().
get
(
0
).
getName
());
Tags
.
LOGIC_ENDPOINT
.
set
(
span
,
buildLogicEndpointSpan
()
);
Tags
.
LOGIC_ENDPOINT
.
set
(
span
,
Tags
.
VAL_LOCAL_SPAN_AS_LOGIC_ENDPOINT
);
span
.
setComponent
(
ComponentsDefine
.
GRAPHQL
);
}
...
...
@@ -67,8 +67,4 @@ public class GraphqlInterceptor implements InstanceMethodsAroundInterceptor {
span
.
errorOccurred
();
span
.
log
(
throwable
);
}
private
String
buildLogicEndpointSpan
()
{
return
"{\"logic-span\":true}"
;
}
}
test/plugin/scenarios/elasticjob-3.x-scenario/config/expectedData.yaml
浏览文件 @
494d2a5b
...
...
@@ -43,10 +43,11 @@ segmentItems:
endTime
:
not
null
componentId
:
24
isError
:
false
spanType
:
Entry
spanType
:
Local
peer
:
'
'
skipAnalysis
:
false
tags
:
-
{
key
:
x-le
,
value
:
'
{"logic-span":true}'
}
-
{
key
:
item
,
value
:
'
0'
}
-
{
key
:
shardingTotalCount
,
value
:
'
1'
}
-
{
key
:
taskId
,
value
:
not null
}
...
...
test/plugin/scenarios/elasticjob-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticjob/controller/CaseController.java
浏览文件 @
494d2a5b
...
...
@@ -18,8 +18,8 @@
package
org.apache.skywalking.apm.testcase.elasticjob.controller
;
import
org.apache.
logging.log4j.LogManager
;
import
org.
apache.logging.log4j.Logger
;
import
org.apache.
skywalking.apm.testcase.elasticjob.job.DemoSimpleJob
;
import
org.
springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -28,13 +28,15 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping
(
"/case"
)
public
class
CaseController
{
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
CaseController
.
class
);
@Autowired
private
DemoSimpleJob
demoSimpleJob
;
private
static
final
String
SUCCESS
=
"Success"
;
@RequestMapping
(
"/healthCheck"
)
@ResponseBody
public
String
healthCheck
()
throws
Exception
{
demoSimpleJob
.
getLatchAwait
();
return
SUCCESS
;
}
...
...
test/plugin/scenarios/elasticjob-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticjob/job/DemoSimpleJob.java
浏览文件 @
494d2a5b
...
...
@@ -30,19 +30,31 @@ import org.springframework.stereotype.Component;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.concurrent.CountDownLatch
;
@Component
public
class
DemoSimpleJob
implements
SimpleJob
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
DemoSimpleJob
.
class
);
OkHttpClient
client
=
new
OkHttpClient
.
Builder
().
build
();
private
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
public
void
getLatchAwait
()
throws
InterruptedException
{
try
{
latch
.
await
();
}
catch
(
InterruptedException
e
)
{
throw
e
;
}
}
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
logger
.
info
(
"Elastic Job Item: {} | Time: {} | Thread: {} | {}"
,
shardingContext
.
getShardingItem
(),
new
SimpleDateFormat
(
"HH:mm:ss"
).
format
(
new
Date
()),
Thread
.
currentThread
().
getId
(),
"SIMPLE"
);
Request
request
=
new
Request
.
Builder
().
url
(
"http://localhost:8080/elasticjob-3.x-scenario/case/ping"
).
build
();
Response
response
=
null
;
latch
.
countDown
();
try
{
response
=
client
.
newCall
(
request
).
execute
();
}
catch
(
IOException
e
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录