Skip to content

Commit ac84d57

Browse files
authored
Expose complete Tracing APIs in the tracing toolkit (#442)
1 parent f366503 commit ac84d57

62 files changed

Lines changed: 3879 additions & 14 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/plugins-test.0.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
case:
5858
- activemq-scenario
5959
- apm-toolkit-trace-scenario
60+
- apm-toolkit-tracer-scenario
6061
- armeria-0.96minus-scenario
6162
- armeria-0.96plus-scenario
6263
- avro-scenario

CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ Release Notes.
66
------------------
77

88
* Enhance lettuce plugin to adopt uniform tags.
9+
* Expose complete Tracing APIs in the tracing toolkit
910

1011
#### Documentation
11-
12+
* Update docs of Tracing APIs, reorganize the API docs into six parts
1213

1314

1415
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/168?closed=1)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.toolkit.trace;
20+
21+
public class CarrierItemRef {
22+
23+
public boolean hasNext() {
24+
return false;
25+
}
26+
27+
public CarrierItemRef next() {
28+
return new CarrierItemRef();
29+
}
30+
31+
public String getHeadKey() {
32+
return "";
33+
}
34+
35+
public String getHeadValue() {
36+
return "";
37+
}
38+
39+
public void setHeadValue(String headValue) {
40+
}
41+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.toolkit.trace;
20+
21+
public class ContextCarrierRef {
22+
public CarrierItemRef items() {
23+
return new CarrierItemRef();
24+
}
25+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.toolkit.trace;
20+
21+
public class ContextSnapshotRef {
22+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.toolkit.trace;
20+
21+
import java.util.Map;
22+
23+
public class SpanRef {
24+
25+
public SpanRef prepareForAsync() {
26+
return new SpanRef();
27+
}
28+
29+
public SpanRef asyncFinish() {
30+
return new SpanRef();
31+
}
32+
33+
public void log(Throwable t) {
34+
}
35+
36+
public void log(Map<String, ?> event) {
37+
}
38+
39+
public void tag(String key, String value) {
40+
}
41+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.toolkit.trace;
20+
21+
public class Tracer {
22+
public static SpanRef createEntrySpan(String operationName, ContextCarrierRef carrierRef) {
23+
return new SpanRef();
24+
}
25+
26+
public static SpanRef createLocalSpan(String operationName) {
27+
return new SpanRef();
28+
}
29+
30+
public static SpanRef createExitSpan(String operationName, String remotePeer) {
31+
return new SpanRef();
32+
}
33+
34+
public static SpanRef createExitSpan(String operationName, ContextCarrierRef carrierRef, String remotePeer) {
35+
return new SpanRef();
36+
}
37+
38+
public static void stopSpan() {
39+
}
40+
41+
public static void inject(ContextCarrierRef carrierRef) {
42+
}
43+
44+
public static void extract(ContextCarrierRef carrierRef) {
45+
}
46+
47+
public static ContextSnapshotRef capture() {
48+
return new ContextSnapshotRef();
49+
}
50+
51+
public static void continued(ContextSnapshotRef snapshot) {
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.toolkit.activation.trace;
20+
21+
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
22+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
23+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
24+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
25+
26+
import java.lang.reflect.Method;
27+
28+
public class CarrierItemGetHeadKeyInterceptor implements InstanceMethodsAroundInterceptor {
29+
@Override
30+
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
31+
32+
}
33+
34+
@Override
35+
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
36+
CarrierItem carrierItem = (CarrierItem) objInst.getSkyWalkingDynamicField();
37+
return carrierItem.getHeadKey();
38+
}
39+
40+
@Override
41+
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
42+
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.toolkit.activation.trace;
20+
21+
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
22+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
23+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
24+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
25+
26+
import java.lang.reflect.Method;
27+
28+
public class CarrierItemGetHeadValueInterceptor implements InstanceMethodsAroundInterceptor {
29+
@Override
30+
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
31+
32+
}
33+
34+
@Override
35+
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
36+
CarrierItem carrierItem = (CarrierItem) objInst.getSkyWalkingDynamicField();
37+
return carrierItem.getHeadValue();
38+
}
39+
40+
@Override
41+
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
42+
43+
}
44+
}

0 commit comments

Comments
 (0)