Merge branch 'master' into fix/graphql/node-nullable
This commit is contained in:
commit
315a6f06d9
11
.travis.yml
11
.travis.yml
|
|
@ -1,12 +1,13 @@
|
|||
sudo: required
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
language: java
|
||||
before_install:
|
||||
- cd ci-dependencies
|
||||
- curl -O https://openskywalking.github.io/skywalking-ci-assist/jars/ojdbc14-10.2.0.4.0.jar
|
||||
- curl -O https://openskywalking.github.io/skywalking-ci-assist/jars/resin-4.0.41.jar
|
||||
- cd ..
|
||||
|
||||
install:
|
||||
- jdk_switcher use oraclejdk8
|
||||
- mvn clean install --quiet jacoco:report coveralls:report
|
||||
|
||||
after_success:
|
||||
- bash ./travis/push_image.sh
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Apache SkyWalking
|
||||
Copyright 2015-2017 The Apache Software Foundation
|
||||
Copyright 2015-2018 The Apache Software Foundation
|
||||
|
||||
This product includes software developed by The Apache Software
|
||||
Foundation (http://www.apache.org/).
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@ Apache SkyWalking | [中文](README_ZH.md)
|
|||
microservices, cloud native and container-based (Docker, K8s, Mesos) architectures.
|
||||
Underlying technology is a distributed tracing system.
|
||||
|
||||
[](https://github.com/apache/incubator-skywalking)
|
||||
[](https://twitter.com/AsfSkyWalking)
|
||||
|
||||
[](https://travis-ci.org/apache/incubator-skywalking)
|
||||
[](https://twitter.com/AsfSkyWalking)
|
||||
[](https://gitter.im/openskywalking/Lobby)
|
||||
[](http://opentracing.io)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@ Apache SkyWalking | [English](README.md)
|
|||
**SkyWalking**: 针对分布式系统的APM(应用性能监控)系统,特别针对微服务、cloud native和容器化(Docker, K8s, Mesos)架构,
|
||||
其核心是个分布式追踪系统。
|
||||
|
||||
[](https://github.com/apache/incubator-skywalking)
|
||||
[](https://twitter.com/AsfSkyWalking)
|
||||
|
||||
[](https://travis-ci.org/apache/incubator-skywalking)
|
||||
[](https://twitter.com/AsfSkyWalking)
|
||||
[](https://gitter.im/openskywalking/Lobby)
|
||||
[](http://opentracing.io)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.GraphIdDefi
|
|||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IMemoryMetricService;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Graph;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric;
|
||||
|
|
@ -53,7 +54,7 @@ public class MemoryMetricService implements IMemoryMetricService {
|
|||
memoryMetric.setId(id);
|
||||
memoryMetric.setMetricId(metricId);
|
||||
memoryMetric.setInstanceId(instanceId);
|
||||
memoryMetric.setIsHeap(isHeap);
|
||||
memoryMetric.setIsHeap(BooleanUtils.booleanToValue(isHeap));
|
||||
memoryMetric.setInit(init);
|
||||
memoryMetric.setMax(max);
|
||||
memoryMetric.setUsed(used);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService
|
|||
import org.apache.skywalking.apm.collector.core.graph.Graph;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -98,7 +99,7 @@ public class SegmentCostSpanListener implements EntrySpanListener, ExitSpanListe
|
|||
Graph<SegmentCost> graph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.SEGMENT_COST_GRAPH_ID, SegmentCost.class);
|
||||
logger.debug("segment cost listener build");
|
||||
for (SegmentCost segmentCost : segmentCosts) {
|
||||
segmentCost.setIsError(isError);
|
||||
segmentCost.setIsError(BooleanUtils.booleanToValue(isError));
|
||||
segmentCost.setTimeBucket(timeBucket);
|
||||
graph.start(segmentCost);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerExce
|
|||
import org.apache.skywalking.apm.collector.cache.CacheModule;
|
||||
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegisterDAO;
|
||||
|
|
@ -65,7 +66,7 @@ public class ApplicationRegisterSerialWorker extends AbstractLocalAsyncWorker<Ap
|
|||
userApplication.setApplicationCode(Const.USER_CODE);
|
||||
userApplication.setApplicationId(Const.NONE_APPLICATION_ID);
|
||||
userApplication.setAddressId(Const.NONE);
|
||||
userApplication.setIsAddress(false);
|
||||
userApplication.setIsAddress(BooleanUtils.FALSE);
|
||||
applicationRegisterDAO.save(userApplication);
|
||||
|
||||
newApplication = new Application();
|
||||
|
|
|
|||
|
|
@ -25,18 +25,20 @@ public enum IdAutoIncrement {
|
|||
INSTANCE;
|
||||
|
||||
public int increment(int min, int max) {
|
||||
int instanceId;
|
||||
int id;
|
||||
if (min == max) {
|
||||
instanceId = -1;
|
||||
if (min == 0) {
|
||||
id = -1;
|
||||
} else {
|
||||
id = 1;
|
||||
}
|
||||
} else if (min + max == 0) {
|
||||
instanceId = max + 1;
|
||||
id = max + 1;
|
||||
} else if (min + max > 0) {
|
||||
instanceId = min - 1;
|
||||
} else if (max < 0) {
|
||||
instanceId = 1;
|
||||
id = min - 1;
|
||||
} else {
|
||||
instanceId = max + 1;
|
||||
id = max + 1;
|
||||
}
|
||||
return instanceId;
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerExce
|
|||
import org.apache.skywalking.apm.collector.cache.CacheModule;
|
||||
import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO;
|
||||
|
|
@ -70,7 +71,7 @@ public class InstanceRegisterSerialWorker extends AbstractLocalAsyncWorker<Insta
|
|||
userInstance.setOsInfo(Const.EMPTY_STRING);
|
||||
userInstance.setRegisterTime(System.currentTimeMillis());
|
||||
userInstance.setAddressId(Const.NONE);
|
||||
userInstance.setIsAddress(false);
|
||||
userInstance.setIsAddress(BooleanUtils.FALSE);
|
||||
instanceRegisterDAO.save(userInstance);
|
||||
|
||||
newInstance = new Instance();
|
||||
|
|
|
|||
|
|
@ -26,19 +26,16 @@ import org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheServ
|
|||
import org.apache.skywalking.apm.collector.core.graph.Graph;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.Application;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationIDService implements IApplicationIDService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ApplicationIDService.class);
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private ApplicationCacheService applicationCacheService;
|
||||
private NetworkAddressCacheService networkAddressCacheService;
|
||||
|
|
@ -78,7 +75,7 @@ public class ApplicationIDService implements IApplicationIDService {
|
|||
application.setApplicationCode(applicationCode);
|
||||
application.setApplicationId(0);
|
||||
application.setAddressId(Const.NONE);
|
||||
application.setIsAddress(false);
|
||||
application.setIsAddress(BooleanUtils.FALSE);
|
||||
|
||||
getApplicationRegisterGraph().start(application);
|
||||
}
|
||||
|
|
@ -94,7 +91,7 @@ public class ApplicationIDService implements IApplicationIDService {
|
|||
application.setApplicationCode(networkAddress);
|
||||
application.setApplicationId(0);
|
||||
application.setAddressId(addressId);
|
||||
application.setIsAddress(true);
|
||||
application.setIsAddress(BooleanUtils.TRUE);
|
||||
|
||||
getApplicationRegisterGraph().start(application);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService;
|
|||
import org.apache.skywalking.apm.collector.core.graph.Graph;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
|
|
@ -83,7 +84,7 @@ public class InstanceIDService implements IInstanceIDService {
|
|||
instance.setHeartBeatTime(registerTime);
|
||||
instance.setInstanceId(0);
|
||||
instance.setOsInfo(osInfo);
|
||||
instance.setIsAddress(false);
|
||||
instance.setIsAddress(BooleanUtils.FALSE);
|
||||
instance.setAddressId(Const.NONE);
|
||||
|
||||
getInstanceRegisterGraph().start(instance);
|
||||
|
|
@ -104,7 +105,7 @@ public class InstanceIDService implements IInstanceIDService {
|
|||
instance.setHeartBeatTime(registerTime);
|
||||
instance.setInstanceId(0);
|
||||
instance.setOsInfo(Const.EMPTY_STRING);
|
||||
instance.setIsAddress(true);
|
||||
instance.setIsAddress(BooleanUtils.TRUE);
|
||||
instance.setAddressId(addressId);
|
||||
|
||||
getInstanceRegisterGraph().start(instance);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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.collector.analysis.register.provider.register;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class IdAutoIncrementTestCase {
|
||||
|
||||
@Test
|
||||
public void testIncrement() {
|
||||
int id = IdAutoIncrement.INSTANCE.increment(0, 0);
|
||||
Assert.assertEquals(-1, id);
|
||||
|
||||
id = IdAutoIncrement.INSTANCE.increment(-1, -1);
|
||||
Assert.assertEquals(1, id);
|
||||
|
||||
id = IdAutoIncrement.INSTANCE.increment(-1, 1);
|
||||
Assert.assertEquals(2, id);
|
||||
|
||||
id = IdAutoIncrement.INSTANCE.increment(-1, 2);
|
||||
Assert.assertEquals(-2, id);
|
||||
|
||||
id = IdAutoIncrement.INSTANCE.increment(-2, 2);
|
||||
Assert.assertEquals(3, id);
|
||||
}
|
||||
}
|
||||
|
|
@ -42,10 +42,10 @@ ui:
|
|||
# index_shards_number: 2
|
||||
# index_replicas_number: 0
|
||||
# ttl: 7
|
||||
#storage:
|
||||
# h2:
|
||||
# url: jdbc:h2:tcp://localhost/~/test
|
||||
# user_name: sa
|
||||
storage:
|
||||
h2:
|
||||
url: jdbc:h2:tcp://localhost/~/test
|
||||
user_name: sa
|
||||
configuration:
|
||||
default:
|
||||
application_apdex_threshold: 2000
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation;
|
|||
import org.apache.skywalking.apm.collector.core.data.operator.MaxOperation;
|
||||
import org.apache.skywalking.apm.collector.core.data.operator.MinOperation;
|
||||
import org.apache.skywalking.apm.collector.core.data.operator.NonOperation;
|
||||
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -132,11 +131,11 @@ public class MemoryMetric extends StreamData {
|
|||
setDataInteger(0, instanceId);
|
||||
}
|
||||
|
||||
public Boolean getIsHeap() {
|
||||
return BooleanUtils.valueToBoolean(getDataInteger(1));
|
||||
public Integer getIsHeap() {
|
||||
return getDataInteger(1);
|
||||
}
|
||||
|
||||
public void setIsHeap(Boolean isHeap) {
|
||||
setDataInteger(1, BooleanUtils.booleanToValue(isHeap));
|
||||
public void setIsHeap(Integer isHeap) {
|
||||
setDataInteger(1, isHeap);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import org.apache.skywalking.apm.collector.core.data.Column;
|
|||
import org.apache.skywalking.apm.collector.core.data.StreamData;
|
||||
import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation;
|
||||
import org.apache.skywalking.apm.collector.core.data.operator.NonOperation;
|
||||
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -90,11 +89,11 @@ public class Application extends StreamData {
|
|||
setDataInteger(1, addressId);
|
||||
}
|
||||
|
||||
public boolean getIsAddress() {
|
||||
return BooleanUtils.valueToBoolean(getDataInteger(2));
|
||||
public int getIsAddress() {
|
||||
return getDataInteger(2);
|
||||
}
|
||||
|
||||
public void setIsAddress(boolean isAddress) {
|
||||
setDataInteger(2, BooleanUtils.booleanToValue(isAddress));
|
||||
public void setIsAddress(int isAddress) {
|
||||
setDataInteger(2, isAddress);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import org.apache.skywalking.apm.collector.core.data.Column;
|
|||
import org.apache.skywalking.apm.collector.core.data.StreamData;
|
||||
import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation;
|
||||
import org.apache.skywalking.apm.collector.core.data.operator.NonOperation;
|
||||
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -127,11 +126,11 @@ public class Instance extends StreamData {
|
|||
setDataInteger(2, addressId);
|
||||
}
|
||||
|
||||
public boolean getIsAddress() {
|
||||
return BooleanUtils.valueToBoolean(getDataInteger(3));
|
||||
public int getIsAddress() {
|
||||
return getDataInteger(3);
|
||||
}
|
||||
|
||||
public void setIsAddress(boolean isAddress) {
|
||||
setDataInteger(3, BooleanUtils.booleanToValue(isAddress));
|
||||
public void setIsAddress(int isAddress) {
|
||||
setDataInteger(3, isAddress);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import org.apache.skywalking.apm.collector.core.data.Column;
|
|||
import org.apache.skywalking.apm.collector.core.data.StreamData;
|
||||
import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation;
|
||||
import org.apache.skywalking.apm.collector.core.data.operator.NonOperation;
|
||||
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -127,11 +126,11 @@ public class SegmentCost extends StreamData {
|
|||
setDataInteger(0, applicationId);
|
||||
}
|
||||
|
||||
public Boolean getIsError() {
|
||||
return BooleanUtils.valueToBoolean(getDataInteger(1));
|
||||
public Integer getIsError() {
|
||||
return getDataInteger(1);
|
||||
}
|
||||
|
||||
public void setIsError(Boolean isError) {
|
||||
setDataInteger(0, BooleanUtils.booleanToValue(isError));
|
||||
public void setIsError(Integer isError) {
|
||||
setDataInteger(1, isError);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,16 +30,12 @@ import org.elasticsearch.action.search.SearchType;
|
|||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceEsCacheDAO extends EsDAO implements IInstanceCacheDAO {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(InstanceEsCacheDAO.class);
|
||||
|
||||
public InstanceEsCacheDAO(ElasticSearchClient client) {
|
||||
super(client);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class NetworkAddressEsCacheDAO extends EsDAO implements INetworkAddressCa
|
|||
ElasticSearchClient client = getClient();
|
||||
|
||||
SearchRequestBuilder searchRequestBuilder = client.prepareSearch(NetworkAddressTable.TABLE);
|
||||
searchRequestBuilder.setTypes("type");
|
||||
searchRequestBuilder.setTypes(NetworkAddressTable.TABLE_TYPE);
|
||||
searchRequestBuilder.setSearchType(SearchType.QUERY_THEN_FETCH);
|
||||
searchRequestBuilder.setQuery(QueryBuilders.termQuery(NetworkAddressTable.COLUMN_NETWORK_ADDRESS, networkAddress));
|
||||
searchRequestBuilder.setSize(1);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public abstract class AbstractMemoryMetricEsPersistenceDAO extends AbstractPersi
|
|||
memoryMetric.setMetricId((String)source.get(MemoryMetricTable.COLUMN_METRIC_ID));
|
||||
|
||||
memoryMetric.setInstanceId(((Number)source.get(MemoryMetricTable.COLUMN_INSTANCE_ID)).intValue());
|
||||
memoryMetric.setIsHeap((Boolean)source.get(MemoryMetricTable.COLUMN_IS_HEAP));
|
||||
memoryMetric.setIsHeap(((Number)source.get(MemoryMetricTable.COLUMN_IS_HEAP)).intValue());
|
||||
|
||||
memoryMetric.setInit(((Number)source.get(MemoryMetricTable.COLUMN_INIT)).longValue());
|
||||
memoryMetric.setMax(((Number)source.get(MemoryMetricTable.COLUMN_MAX)).longValue());
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric;
|
|||
import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng, clevertension
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public abstract class AbstractMemoryMetricH2PersistenceDAO extends AbstractPersistenceH2DAO<MemoryMetric> {
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ public abstract class AbstractMemoryMetricH2PersistenceDAO extends AbstractPersi
|
|||
memoryMetric.setMetricId(resultSet.getString(MemoryMetricTable.COLUMN_METRIC_ID));
|
||||
|
||||
memoryMetric.setInstanceId(resultSet.getInt(MemoryMetricTable.COLUMN_INSTANCE_ID));
|
||||
memoryMetric.setIsHeap(resultSet.getBoolean(MemoryMetricTable.COLUMN_IS_HEAP));
|
||||
memoryMetric.setIsHeap(resultSet.getInt(MemoryMetricTable.COLUMN_IS_HEAP));
|
||||
|
||||
memoryMetric.setInit(resultSet.getLong(MemoryMetricTable.COLUMN_INIT));
|
||||
memoryMetric.setMax(resultSet.getLong(MemoryMetricTable.COLUMN_MAX));
|
||||
|
|
|
|||
|
|
@ -18,25 +18,26 @@
|
|||
|
||||
package org.apache.skywalking.apm.plugin.spring.mvc.commons;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class EnhanceRequireObjectCache {
|
||||
private PathMappingCache pathMappingCache;
|
||||
private NativeWebRequest nativeWebRequest;
|
||||
private HttpServletResponse httpResponse;
|
||||
private ThreadLocal<NativeWebRequest> nativeWebRequest = new ThreadLocal<NativeWebRequest>();
|
||||
private ThreadLocal<HttpServletResponse> httpResponse = new ThreadLocal<HttpServletResponse>();
|
||||
|
||||
public void setPathMappingCache(PathMappingCache pathMappingCache) {
|
||||
this.pathMappingCache = pathMappingCache;
|
||||
}
|
||||
|
||||
public HttpServletResponse getHttpServletResponse() {
|
||||
return httpResponse == null ? (HttpServletResponse)nativeWebRequest.getNativeResponse() : httpResponse;
|
||||
return httpResponse.get() == null ? (HttpServletResponse) nativeWebRequest.get().getNativeResponse() : httpResponse.get();
|
||||
}
|
||||
|
||||
public void setNativeWebRequest(NativeWebRequest nativeWebRequest) {
|
||||
this.nativeWebRequest = nativeWebRequest;
|
||||
this.nativeWebRequest.set(nativeWebRequest);
|
||||
}
|
||||
|
||||
public String findPathMapping(Method method) {
|
||||
|
|
@ -52,10 +53,12 @@ public class EnhanceRequireObjectCache {
|
|||
}
|
||||
|
||||
public void setHttpResponse(HttpServletResponse httpResponse) {
|
||||
this.httpResponse = httpResponse;
|
||||
this.httpResponse.set(httpResponse);
|
||||
}
|
||||
|
||||
public HttpServletResponse getHttpResponse() {
|
||||
return httpResponse;
|
||||
public void clearRequestAndResponse() {
|
||||
setNativeWebRequest(null);
|
||||
setHttpResponse(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,27 +19,28 @@
|
|||
|
||||
package org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
|
||||
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.context.trace.SpanLayer;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache;
|
||||
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
|
||||
import org.apache.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
import org.apache.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* the abstract method inteceptor
|
||||
*/
|
||||
public abstract class AbstractMethodInteceptor implements InstanceMethodsAroundInterceptor {
|
||||
public abstract class AbstractMethodInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
public abstract String getRequestURL(Method method);
|
||||
|
||||
@Override
|
||||
|
|
@ -72,15 +73,19 @@ public abstract class AbstractMethodInteceptor implements InstanceMethodsAroundI
|
|||
@Override
|
||||
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
Object ret) throws Throwable {
|
||||
HttpServletResponse response = ((EnhanceRequireObjectCache)objInst.getSkyWalkingDynamicField()).getHttpServletResponse();
|
||||
try {
|
||||
HttpServletResponse response = ((EnhanceRequireObjectCache) objInst.getSkyWalkingDynamicField()).getHttpServletResponse();
|
||||
|
||||
AbstractSpan span = ContextManager.activeSpan();
|
||||
if (response.getStatus() >= 400) {
|
||||
span.errorOccurred();
|
||||
Tags.STATUS_CODE.set(span, Integer.toString(response.getStatus()));
|
||||
AbstractSpan span = ContextManager.activeSpan();
|
||||
if (response.getStatus() >= 400) {
|
||||
span.errorOccurred();
|
||||
Tags.STATUS_CODE.set(span, Integer.toString(response.getStatus()));
|
||||
}
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
} finally {
|
||||
((EnhanceRequireObjectCache)objInst.getSkyWalkingDynamicField()).clearRequestAndResponse();
|
||||
}
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -18,13 +18,14 @@
|
|||
|
||||
package org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class InvokeHandlerMethodInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
|
|
@ -42,6 +43,5 @@ public class InvokeHandlerMethodInterceptor implements InstanceMethodsAroundInte
|
|||
|
||||
@Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
|
||||
Class<?>[] argumentsTypes, Throwable t) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,16 +19,17 @@
|
|||
|
||||
package org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* The <code>RequestMappingMethodInterceptor</code> only use the first mapping value.
|
||||
* it will inteceptor with <code>@RequestMapping</code>
|
||||
*
|
||||
* @author clevertension
|
||||
*/
|
||||
public class RequestMappingMethodInterceptor extends AbstractMethodInteceptor {
|
||||
public class RequestMappingMethodInterceptor extends AbstractMethodInterceptor {
|
||||
@Override
|
||||
public String getRequestURL(Method method) {
|
||||
String requestURL = "";
|
||||
|
|
|
|||
|
|
@ -19,12 +19,9 @@
|
|||
|
||||
package org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
|
||||
/**
|
||||
* The <code>RestMappingMethodInterceptor</code> only use the first mapping value.
|
||||
|
|
@ -34,7 +31,7 @@ import org.springframework.web.bind.annotation.PutMapping;
|
|||
*
|
||||
* @author clevertension
|
||||
*/
|
||||
public class RestMappingMethodInterceptor extends AbstractMethodInteceptor {
|
||||
public class RestMappingMethodInterceptor extends AbstractMethodInterceptor {
|
||||
@Override
|
||||
public String getRequestURL(Method method) {
|
||||
String requestURL = "";
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
* [项目简介](/README_ZH.md)
|
||||
* [快速入门](cn/Quick-start-CN.md)
|
||||
* [部署Collector镜像](cn/Deploy-docker-image.CN.md)
|
||||
* [部署Collector镜像](cn/Deploy-docker-image-CN.md)
|
||||
* [中间件,框架与类库支持列表](Supported-list.md)
|
||||
* [如何关闭特定插件](cn/How-to-disable-plugin-CN.md)
|
||||
* APM相关介绍资料
|
||||
|
|
|
|||
|
|
@ -16,3 +16,11 @@
|
|||
- **apm-protocol/apm-network/target/generated-sources/protobuf**目录下的`grpc-java`和`java`目录
|
||||
- **apm-collector/apm-collector-remote/apm-remote-grpc-provider/target/protobuf**目录下的`grpc-java`和`java`目录
|
||||
|
||||
## 编译Resin-3, Resin-4 和 Oracle JDBC 驱动插件
|
||||
为了遵守Apache关于协议(License)的相关要求,不符合Apache相关要求的类库所对应的Plugin不会自动编译。如需编译对应的插件,
|
||||
需要手动下载驱动或类库,并将文件拷贝到`ci-dependencies/`中,运行`mvn package`进行编译。
|
||||
|
||||
`ci-dependencies/`下对应的类库文件名为:
|
||||
* resin-3.0.9.jar
|
||||
* resin-4.0.41.jar
|
||||
* ojdbc14-10.2.0.4.0.jar
|
||||
32
pom.xml
32
pom.xml
|
|
@ -323,43 +323,13 @@
|
|||
</profile>
|
||||
<profile>
|
||||
<!-- resin is not Apache license compatible, so it must be manually downloaded first -->
|
||||
<!-- Use resin 3.x jar file as a beacon only -->
|
||||
<id>install-resin-3</id>
|
||||
<activation>
|
||||
<file>
|
||||
<exists>${basedir}/ci-dependencies/resin-3.0.9.jar</exists>
|
||||
</file>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>install-resin-3</id>
|
||||
<inherited>false</inherited>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>mvn</executable>
|
||||
<arguments>
|
||||
<argument>install:install-file</argument>
|
||||
<argument>-Dfile=resin-3.0.9.jar</argument>
|
||||
<argument>-DgroupId=com.caucho</argument>
|
||||
<argument>-DartifactId=resin</argument>
|
||||
<argument>-Dversion=3.0.9</argument>
|
||||
<argument>-Dpackaging=jar</argument>
|
||||
</arguments>
|
||||
<workingDirectory>${project.basedir}/ci-dependencies</workingDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<!-- resin is not Apache license compatible, so it must be manually downloaded first -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue