提交 bcaa8be0 编写于 作者: Z zhangwei 提交者: wu-sheng

toolkit-scenario (#3739)

上级 7ebb3107
......@@ -66,7 +66,7 @@ pipeline {
sh './mvnw -f test/plugin/pom.xml clean package -DskipTests -Dbuild_id=wl2_${BUILD_ID} docker:build'
}
}
stage('Test Cases Report (155)') {
stage('Test Cases Report (156)') {
steps {
echo "reserve."
}
......@@ -110,6 +110,12 @@ pipeline {
sh 'bash test/plugin/run.sh --build_id=wl2_${BUILD_ID} spring-4.1.x-scenario'
}
}
stage('apm-toolkit-trace (1)') {
steps {
sh 'bash test/plugin/run.sh --build_id=wl2_${BUILD_ID} apm-toolkit-trace-scenario'
}
}
}
}
stage('Group2') {
......
......@@ -46,7 +46,7 @@ public class MockTraceSegmentService extends TraceSegmentReportServiceGrpc.Trace
for (SpanObjectV2 spanObject : traceSegmentObject.getSpansList()) {
Span.SpanBuilder spanBuilder = Span.builder().operationName(spanObject.getOperationName()).parentSpanId(spanObject.getParentSpanId())
.spanId(spanObject.getSpanId()).componentId(spanObject.getComponentId()).componentName(spanObject.getComponent())
.spanLayer(spanObject.getSpanLayer().toString()).endTime(spanObject.getEndTime())
.spanLayer(spanObject.getSpanLayer().toString()).endTime(spanObject.getEndTime()).isError(spanObject.getIsError())
.startTime(spanObject.getStartTime()).spanType(spanObject.getSpanType().toString())
.peer(spanObject.getPeer()).peerId(spanObject.getPeerId()).operationId(spanObject.getOperationNameId());
......
#!/bin/bash
#
# 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.
home="$(cd "$(dirname $0)"; pwd)"
java -jar ${agent_opts} ${home}/../libs/apm-toolkit-trace-scenario.jar &
\ No newline at end of file
# 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.
registryItems:
applications:
- {apm-toolkit-trace-scenario: 2}
instances:
- {apm-toolkit-trace-scenario: 1}
operationNames:
- apm-toolkit-trace-scenario: [/apm-toolkit-trace-scenario/case/asyncVisit/runnable,
/case/asyncVisit/runnable, /case/asyncVisit/callable, /apm-toolkit-trace-scenario/case/asyncVisit/callable,
/case/tool-kit]
heartbeat: []
segmentItems:
- applicationCode: apm-toolkit-trace-scenario
segmentSize: gt 5
segments:
- segmentId: not null
spans:
- operationName: test.org.apache.skywalking.apm.testcase.toolkit.controller.TestService.testTag()
operationId: 0
parentSpanId: 0
spanId: 1
spanLayer: Unknown
startTime: nq 0
endTime: nq 0
componentId: 0
componentName: ''
isError: false
spanType: Local
peer: ''
peerId: 0
tags:
- {key: key, value: value}
- operationName: test.org.apache.skywalking.apm.testcase.toolkit.controller.TestService.testInfo()
operationId: 0
parentSpanId: 0
spanId: 2
spanLayer: Unknown
startTime: nq 0
endTime: nq 0
componentId: 0
componentName: ''
isError: false
spanType: Local
peer: ''
peerId: 0
logs:
- logEvent:
- {key: event, value: info}
- {key: message, value: TestInfoMsg}
- operationName: test.org.apache.skywalking.apm.testcase.toolkit.controller.TestService.testDebug()
operationId: 0
parentSpanId: 0
spanId: 3
spanLayer: Unknown
startTime: nq 0
endTime: nq 0
componentId: 0
componentName: ''
isError: false
spanType: Local
peer: ''
peerId: 0
logs:
- logEvent:
- {key: event, value: debug}
- {key: message, value: TestDebugMsg}
- operationName: test.org.apache.skywalking.apm.testcase.toolkit.controller.TestService.testError()
operationId: 0
parentSpanId: 0
spanId: 4
spanLayer: Unknown
startTime: nq 0
endTime: nq 0
componentId: 0
componentName: ''
isError: true
spanType: Local
peer: ''
peerId: 0
- operationName: test.org.apache.skywalking.apm.testcase.toolkit.controller.TestService.testErrorMsg()
operationId: 0
parentSpanId: 0
spanId: 5
spanLayer: Unknown
startTime: nq 0
endTime: nq 0
componentId: 0
componentName: ''
isError: true
spanType: Local
peer: ''
peerId: 0
logs:
- logEvent:
- {key: event, value: error}
- {key: message, value: TestErrorMsg}
- operationName: test.org.apache.skywalking.apm.testcase.toolkit.controller.TestService.testErrorThrowable()
operationId: 0
parentSpanId: 0
spanId: 6
spanLayer: Unknown
startTime: nq 0
endTime: nq 0
componentId: 0
componentName: ''
isError: true
spanType: Local
peer: ''
peerId: 0
logs:
- logEvent:
- {key: event, value: error}
- {key: error.kind, value: java.lang.RuntimeException}
- {key: message, value: Test-Exception}
- {key: stack, value: not null}
- operationName: /case/tool-kit
operationId: 0
parentSpanId: -1
spanId: 0
spanLayer: Http
startTime: nq 0
endTime: nq 0
componentId: 14
componentName: ''
isError: false
spanType: Entry
peer: ''
peerId: 0
tags:
- {key: url, value: 'http://localhost:8080/apm-toolkit-trace-scenario/case/tool-kit'}
- {key: http.method, value: GET}
- segmentId: not null
spans:
- operationName: /case/asyncVisit/callable
operationId: 0
parentSpanId: -1
spanId: 0
spanLayer: Http
startTime: nq 0
endTime: nq 0
componentId: 14
componentName: ''
isError: false
spanType: Entry
peer: ''
peerId: 0
tags:
- {key: url, value: 'http://localhost:8080/apm-toolkit-trace-scenario/case/asyncVisit/callable'}
- {key: http.method, value: GET}
refs:
- {parentEndpointId: 0, parentEndpoint: Thread/org.apache.skywalking.apm.toolkit.trace.CallableWrapper/call,
networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1,
parentTraceSegmentId: not null, parentServiceInstanceId: 1,
networkAddress: 'localhost:8080', entryEndpoint: /case/tool-kit, entryServiceInstanceId: 1}
- segmentId: not null
spans:
- operationName: /apm-toolkit-trace-scenario/case/asyncVisit/runnable
operationId: 0
parentSpanId: 0
spanId: 1
spanLayer: Http
startTime: nq 0
endTime: nq 0
componentId: 2
componentName: ''
isError: false
spanType: Exit
peer: localhost:8080
peerId: 0
tags:
- {key: url, value: 'http://localhost:8080/apm-toolkit-trace-scenario/case/asyncVisit/runnable'}
- {key: http.method, value: GET}
- operationName: Thread/org.apache.skywalking.apm.toolkit.trace.RunnableWrapper/run
operationId: 0
parentSpanId: -1
spanId: 0
spanLayer: Unknown
startTime: nq 0
endTime: nq 0
componentId: 0
componentName: ''
isError: false
spanType: Local
peer: ''
peerId: 0
refs:
- {parentEndpointId: 0, parentEndpoint: /case/tool-kit, networkAddressId: 0,
entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null,
parentServiceInstanceId: 1, networkAddress: '', entryEndpoint: /case/tool-kit,
entryServiceInstanceId: 1}
- segmentId: not null
spans:
- operationName: /apm-toolkit-trace-scenario/case/asyncVisit/callable
operationId: 0
parentSpanId: 0
spanId: 1
spanLayer: Http
startTime: nq 0
endTime: nq 0
componentId: 2
componentName: ''
isError: false
spanType: Exit
peer: localhost:8080
peerId: 0
tags:
- {key: url, value: 'http://localhost:8080/apm-toolkit-trace-scenario/case/asyncVisit/callable'}
- {key: http.method, value: GET}
- operationName: Thread/org.apache.skywalking.apm.toolkit.trace.CallableWrapper/call
operationId: 0
parentSpanId: -1
spanId: 0
spanLayer: Unknown
startTime: nq 0
endTime: nq 0
componentId: 0
componentName: ''
isError: false
spanType: Local
peer: ''
peerId: 0
refs:
- {parentEndpointId: 0, parentEndpoint: /case/tool-kit, networkAddressId: 0,
entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null,
parentServiceInstanceId: 1, networkAddress: '', entryEndpoint: /case/tool-kit,
entryServiceInstanceId: 1}
- segmentId: not null
spans:
- operationName: /case/asyncVisit/runnable
operationId: 0
parentSpanId: -1
spanId: 0
spanLayer: Http
startTime: nq 0
endTime: nq 0
componentId: 14
componentName: ''
isError: false
spanType: Entry
peer: ''
peerId: 0
tags:
- {key: url, value: 'http://localhost:8080/apm-toolkit-trace-scenario/case/asyncVisit/runnable'}
- {key: http.method, value: GET}
refs:
- {parentEndpointId: 0, parentEndpoint: Thread/org.apache.skywalking.apm.toolkit.trace.RunnableWrapper/run,
networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1,
parentTraceSegmentId: not null, parentServiceInstanceId: 1,
networkAddress: 'localhost:8080', entryEndpoint: /case/tool-kit, entryServiceInstanceId: 1}
\ No newline at end of file
# 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.
type: jvm
entryService: http://localhost:8080/apm-toolkit-trace-scenario/case/tool-kit
healthCheck: http://localhost:8080/apm-toolkit-trace-scenario/case/healthCheck
startScript: ./bin/startup.sh
framework: apm-toolkit-trace
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-toolkit-trace-scenario</artifactId>
<version>5.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler.version>1.8</compiler.version>
<spring.boot.version>2.1.6.RELEASE</spring.boot.version>
<test.framework>apm-toolkit-trace</test.framework>
<test.framework.version>1.0.0</test.framework.version>
</properties>
<name>skywalking-apm-toolkit-trace-scenario</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3</version>
</dependency>
</dependencies>
<build>
<finalName>apm-toolkit-trace-scenario</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${compiler.version}</source>
<target>${compiler.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assemble</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
<outputDirectory>./target/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/snapshot</url>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<url>http://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>./bin</directory>
<fileMode>0775</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>./target/apm-toolkit-trace-scenario.jar</source>
<outputDirectory>./libs</outputDirectory>
<fileMode>0775</fileMode>
</file>
</files>
</assembly>
\ No newline at end of file
/*
* 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.toolkit.trace;
/**
* provide custom api that set tag for current active span.
*
* @author zhangxin
*/
public class ActiveSpan {
/**
* @param key tag key
* @param value tag value
*/
public static void tag(String key, String value) {
}
public static void error() {
}
public static void error(String errorMsg) {
}
public static void error(Throwable throwable) {
}
public static void debug(String debugMsg) {
}
public static void info(String infoMsg) {
}
}
/*
* 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.toolkit.trace;
import java.util.concurrent.Callable;
/**
* @author carlvine500
*/
@TraceCrossThread
public class CallableWrapper<V> implements Callable<V> {
final Callable<V> callable;
public static <V> CallableWrapper of(Callable<V> r) {
return new CallableWrapper<V>(r);
}
public CallableWrapper(Callable<V> callable) {
this.callable = callable;
}
@Override
public V call() throws Exception {
return callable.call();
}
}
\ No newline at end of file
/*
* 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.toolkit.trace;
/**
* @author lican
*/
@TraceCrossThread
public class RunnableWrapper implements Runnable {
final Runnable runnable;
public RunnableWrapper(Runnable runnable) {
this.runnable = runnable;
}
public static RunnableWrapper of(Runnable r) {
return new RunnableWrapper(r);
}
@Override
public void run() {
this.runnable.run();
}
}
\ No newline at end of file
/*
* 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.toolkit.trace;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* The agent create local span if the method that annotation with {@link Trace}. The value of span operation name will
* fetch by {@link #operationName()}. if the value of {@link #operationName()} is blank string. the operation name will
* be set the class name + method name.
*
* @author zhangxin
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Trace {
/**
* @return operation name, the default value is blank string.
*/
String operationName() default "";
}
/*
* 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.toolkit.trace;
/**
* Try to access the sky-walking tracer context.
* The context is not existed, always.
* only the middleware, component, or rpc-framework are supported in the current invoke stack, in the same thread,
* the context will be available.
* <p>
* Created by xin on 2016/12/15.
*/
public class TraceContext {
/**
* Try to get the traceId of current trace context.
*
* @return traceId, if it exists, or empty {@link String}.
*/
public static String traceId() {
return "";
}
}
/*
* 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.toolkit.trace;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author carlvine500
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface TraceCrossThread {
}
\ No newline at end of file
/*
* 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 test.org.apache.skywalking.apm.testcase.toolkit;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
/*
* 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 test.org.apache.skywalking.apm.testcase.toolkit.controller;
import org.apache.http.HttpEntity;
import org.apache.http.client.ResponseHandler;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.IOException;
/**
* @author caoyixiong
*/
@RestController
@RequestMapping("/case")
public class TestController {
private static final String SUCCESS = "Success";
@Autowired
private TestService testService;
@RequestMapping("/tool-kit")
public String toolKitCase() {
testService.testTag();
testService.testInfo();
testService.testDebug();
testService.testError();
testService.testErrorMsg();
testService.testErrorThrowable();
testService.asyncCallable(() -> {
visit("http://localhost:8080/apm-toolkit-trace-scenario/case/asyncVisit/callable");
return true;
});
testService.asyncRunnable(() -> {
try {
visit("http://localhost:8080/apm-toolkit-trace-scenario/case/asyncVisit/runnable");
} catch (IOException e) {
// ignore
}
});
return SUCCESS;
}
@RequestMapping("/healthCheck")
public String healthCheck() {
return SUCCESS;
}
@RequestMapping("/asyncVisit/runnable")
public String asyncVisitRunnable() {
return SUCCESS;
}
@RequestMapping("/asyncVisit/callable")
public String asyncVisitCallable() {
return SUCCESS;
}
private static void visit(String url) throws IOException {
CloseableHttpClient httpclient = HttpClients.createDefault();
try {
HttpGet httpget = new HttpGet(url);
ResponseHandler<String> responseHandler = response -> {
HttpEntity entity = response.getEntity();
return entity != null ? EntityUtils.toString(entity) : null;
};
httpclient.execute(httpget, responseHandler);
} finally {
httpclient.close();
}
}
}
/*
* 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 test.org.apache.skywalking.apm.testcase.toolkit.controller;
import org.apache.skywalking.apm.toolkit.trace.ActiveSpan;
import org.apache.skywalking.apm.toolkit.trace.CallableWrapper;
import org.apache.skywalking.apm.toolkit.trace.RunnableWrapper;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Component;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* @author caoyixiong
*/
@Component
public class TestService {
private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(r -> {
Thread thread = new Thread(r);
thread.setDaemon(true);
return thread;
});
@Trace
public void testTag() {
ActiveSpan.tag("key", "value");
}
@Trace
public void testError() {
ActiveSpan.error();
}
@Trace
public void testErrorMsg() {
ActiveSpan.error("TestErrorMsg");
}
@Trace
public void testErrorThrowable() {
ActiveSpan.error(new RuntimeException("Test-Exception"));
}
@Trace
public void testDebug() {
ActiveSpan.debug("TestDebugMsg");
}
@Trace
public void testInfo() {
ActiveSpan.info("TestInfoMsg");
}
public void asyncRunnable(Runnable runnable) {
SERVICE.submit(RunnableWrapper.of(runnable));
}
public void asyncCallable(Callable<Boolean> callable) {
SERVICE.submit(CallableWrapper.of(callable));
}
}
#
# 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.
#
#
server:
port: 8080
servlet:
context-path: /apm-toolkit-trace-scenario
\ No newline at end of file
# 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.
1.0.0
\ No newline at end of file
......@@ -104,6 +104,8 @@ public class SegmentAssert {
ExpressParser.parse(excepted.peer()).assertValue("peer", actualSpan.peer());
ExpressParser.parse(excepted.spanLayer()).assertValue("span layer", actualSpan.spanLayer());
ExpressParser.parse(excepted.peerId()).assertValue("peer id", actualSpan.peerId());
ExpressParser.parse(excepted.error()).assertValue("is error", actualSpan.error());
ExpressParser.parse(excepted.spanType()).assertValue("span type", actualSpan.spanType());
tagsEquals(excepted.tags(), actualSpan.tags());
logsEquals(excepted.logs(), actualSpan.logs());
refEquals(excepted.refs(), actualSpan.refs());
......
......@@ -184,7 +184,7 @@ public class SegmentForRead implements Segment {
private String endTime;
private String componentId;
private String componentName;
private boolean isError;
private String isError;
private String spanType;
private String peer;
private String peerId;
......@@ -233,7 +233,7 @@ public class SegmentForRead implements Segment {
this.componentName = componentName;
}
public void setError(boolean error) {
public void setError(String error) {
isError = error;
}
......@@ -318,7 +318,7 @@ public class SegmentForRead implements Segment {
return componentName;
}
@Override public boolean error() {
@Override public String error() {
return isError;
}
......
......@@ -41,7 +41,7 @@ public interface Span {
String componentName();
boolean error();
String error();
String spanType();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册