Skip to content

Commit 32d463b

Browse files
committed
Address review comments
1 parent 4303a78 commit 32d463b

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

instrumentation/apache-elasticjob-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheelasticjob/v3_0/ElasticJobExperimentalAttributeExtractor.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class ElasticJobExperimentalAttributeExtractor
2727
longKey("scheduling.apache-elasticjob.sharding.total.count");
2828
private static final AttributeKey<String> ELASTICJOB_SHARDING_ITEM_PARAMETER =
2929
stringKey("scheduling.apache-elasticjob.sharding.item.parameter");
30+
private static final AttributeKey<String> ELASTICJOB_JOB_TYPE =
31+
stringKey("scheduling.apache-elasticjob.job.type");
3032

3133
@Override
3234
public void onStart(
@@ -38,9 +40,10 @@ public void onStart(
3840
attributes.put(ELASTICJOB_SHARDING_ITEM_INDEX, elasticJobProcessRequest.getShardingItemIndex());
3941
attributes.put(
4042
ELASTICJOB_SHARDING_TOTAL_COUNT, elasticJobProcessRequest.getShardingTotalCount());
41-
String shardingItemParameters = elasticJobProcessRequest.getShardingItemParameter();
42-
if (shardingItemParameters != null) {
43-
attributes.put(ELASTICJOB_SHARDING_ITEM_PARAMETER, shardingItemParameters);
43+
attributes.put(ELASTICJOB_JOB_TYPE, elasticJobProcessRequest.getJobType());
44+
String shardingItemParameter = elasticJobProcessRequest.getShardingItemParameter();
45+
if (shardingItemParameter != null) {
46+
attributes.put(ELASTICJOB_SHARDING_ITEM_PARAMETER, shardingItemParameter);
4447
}
4548
}
4649

instrumentation/apache-elasticjob-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheelasticjob/v3_0/ElasticJobProcessRequest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ public String getShardingItemParameter() {
8585
return this.shardingItemParameter;
8686
}
8787

88+
public String getJobType() {
89+
return this.jobType;
90+
}
91+
8892
public Class<?> getUserJobClass() {
8993
return this.userJobClass;
9094
}

instrumentation/apache-elasticjob-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheelasticjob/v3_0/ElasticJobTest.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ void testHttpJob() {
111111
3L,
112112
"Beijing",
113113
"process",
114-
"org.apache.shardingsphere.elasticjob.http.executor.HttpJobExecutor"))),
114+
"org.apache.shardingsphere.elasticjob.http.executor.HttpJobExecutor",
115+
"HTTP"))),
115116
trace ->
116117
trace.hasSpansSatisfyingExactly(
117118
span ->
@@ -124,7 +125,8 @@ void testHttpJob() {
124125
3L,
125126
"Shanghai",
126127
"process",
127-
"org.apache.shardingsphere.elasticjob.http.executor.HttpJobExecutor"))),
128+
"org.apache.shardingsphere.elasticjob.http.executor.HttpJobExecutor",
129+
"HTTP"))),
128130
trace ->
129131
trace.hasSpansSatisfyingExactly(
130132
span ->
@@ -137,7 +139,8 @@ void testHttpJob() {
137139
3L,
138140
"Guangzhou",
139141
"process",
140-
"org.apache.shardingsphere.elasticjob.http.executor.HttpJobExecutor"))));
142+
"org.apache.shardingsphere.elasticjob.http.executor.HttpJobExecutor",
143+
"HTTP"))));
141144
}
142145

143146
@Test
@@ -169,7 +172,8 @@ void testSimpleJob() {
169172
2L,
170173
"A",
171174
"execute",
172-
TestSimpleJob.class.getName()))),
175+
TestSimpleJob.class.getName(),
176+
"SIMPLE"))),
173177
trace ->
174178
trace.hasSpansSatisfyingExactly(
175179
span ->
@@ -182,7 +186,8 @@ void testSimpleJob() {
182186
2L,
183187
"B",
184188
"execute",
185-
TestSimpleJob.class.getName()))));
189+
TestSimpleJob.class.getName(),
190+
"SIMPLE"))));
186191
}
187192

188193
@Test
@@ -214,7 +219,8 @@ void testDataflowJob() {
214219
2L,
215220
"X",
216221
"processData",
217-
TestDataflowJob.class.getName()))),
222+
TestDataflowJob.class.getName(),
223+
"DATAFLOW"))),
218224
trace ->
219225
trace.hasSpansSatisfyingExactly(
220226
span ->
@@ -227,7 +233,8 @@ void testDataflowJob() {
227233
2L,
228234
"Y",
229235
"processData",
230-
TestDataflowJob.class.getName()))));
236+
TestDataflowJob.class.getName(),
237+
"DATAFLOW"))));
231238
}
232239

233240
@Test
@@ -247,7 +254,8 @@ void testScriptJob() throws IOException {
247254
1L,
248255
null,
249256
"process",
250-
"org.apache.shardingsphere.elasticjob.script.executor.ScriptJobExecutor"))));
257+
"org.apache.shardingsphere.elasticjob.script.executor.ScriptJobExecutor",
258+
"SCRIPT"))));
251259
}
252260

253261
@Test
@@ -280,7 +288,8 @@ void testFailedJob() {
280288
1L,
281289
"failed",
282290
"execute",
283-
TestFailedJob.class.getName()))));
291+
TestFailedJob.class.getName(),
292+
"SIMPLE"))));
284293
}
285294

286295
private static CoordinatorRegistryCenter setUpRegistryCenter() {
@@ -346,20 +355,22 @@ private static List<AttributeAssertion> elasticJobAttributes(
346355
String jobName,
347356
long item,
348357
long totalCount,
349-
String parameters,
358+
String parameter,
350359
String codeFunction,
351-
String codeNamespace) {
360+
String codeNamespace,
361+
String jobType) {
352362
List<AttributeAssertion> assertions =
353363
new ArrayList<>(
354364
asList(
355365
equalTo(stringKey("code.function"), codeFunction),
356366
equalTo(stringKey("code.namespace"), codeNamespace),
357367
equalTo(stringKey("job.system"), "elasticjob"),
358368
equalTo(stringKey("scheduling.apache-elasticjob.job.name"), jobName),
369+
equalTo(stringKey("scheduling.apache-elasticjob.job.type"), jobType),
359370
equalTo(longKey("scheduling.apache-elasticjob.sharding.item.index"), item),
360371
equalTo(longKey("scheduling.apache-elasticjob.sharding.total.count"), totalCount),
361372
equalTo(
362-
stringKey("scheduling.apache-elasticjob.sharding.item.parameters"), parameters),
373+
stringKey("scheduling.apache-elasticjob.sharding.item.parameter"), parameter),
363374
satisfies(
364375
stringKey("scheduling.apache-elasticjob.task.id"),
365376
taskId -> taskId.contains(jobName))));

0 commit comments

Comments
 (0)