Make sure the DB service could be generated. (#4757)

This commit is contained in:
吴晟 Wu Sheng 2020-05-08 11:14:16 +08:00 committed by GitHub
parent d713076f01
commit 377315edbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 61 additions and 22 deletions

View File

@ -58,8 +58,8 @@ In this case, all input are requests of each endpoint, condition is `endpoint.st
In this case, calls of each service.
- `thermodynamic`. Read [Heatmap in WIKI](https://en.wikipedia.org/wiki/Heat_map)
> All_heatmap = from(All.latency).thermodynamic(100, 20);
- `histogram`. Read [Heatmap in WIKI](https://en.wikipedia.org/wiki/Heat_map)
> All_heatmap = from(All.latency).histogram(100, 20);
In this case, thermodynamic heatmap of all incoming requests.
The parameter (1) is the precision of latency calculation, such as in above case, 113ms and 193ms are considered same in the 101-200ms group.

View File

@ -20,11 +20,11 @@ package org.apache.skywalking.oap.server.core.analysis.manual.service;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.analysis.worker.MetricsStreamProcessor;
import org.apache.skywalking.oap.server.core.source.ServiceUpdate;
import org.apache.skywalking.oap.server.core.source.ServiceMeta;
public class ServiceUpdateDispatcher implements SourceDispatcher<ServiceUpdate> {
public class ServiceMetaDispatcher implements SourceDispatcher<ServiceMeta> {
@Override
public void dispatch(final ServiceUpdate source) {
public void dispatch(final ServiceMeta source) {
ServiceTraffic traffic = new ServiceTraffic();
traffic.setTimeBucket(source.getTimeBucket());
traffic.setName(source.getName());

View File

@ -63,7 +63,7 @@ public class DefaultScopeDefine {
public static final int PROFILE_TASK = 26;
public static final int PROFILE_TASK_LOG = 27;
public static final int PROFILE_TASK_SEGMENT_SNAPSHOT = 28;
public static final int SERVICE_UPDATE = 29;
public static final int SERVICE_META = 29;
public static final int SERVICE_INSTANCE_UPDATE = 30;
public static final int NETWORK_ADDRESS_ALIAS = 31;

View File

@ -23,16 +23,16 @@ import lombok.Setter;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.NodeType;
import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_UPDATE;
import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_META;
@Getter
@Setter
@ScopeDeclaration(id = SERVICE_UPDATE, name = "ServiceUpdate")
@ScopeDeclaration(id = SERVICE_META, name = "ServiceMeta")
@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
public class ServiceUpdate extends Source {
public class ServiceMeta extends Source {
@Override
public int scope() {
return DefaultScopeDefine.SERVICE_UPDATE;
return DefaultScopeDefine.SERVICE_META;
}
@Override

View File

@ -35,7 +35,7 @@ import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
import org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic;
import org.apache.skywalking.oap.server.core.config.NamingLengthControl;
import org.apache.skywalking.oap.server.core.source.ServiceInstanceUpdate;
import org.apache.skywalking.oap.server.core.source.ServiceUpdate;
import org.apache.skywalking.oap.server.core.source.ServiceMeta;
import org.apache.skywalking.oap.server.core.source.SourceReceiver;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.server.grpc.GRPCHandler;
@ -91,11 +91,11 @@ public class ManagementServiceHandler extends ManagementServiceGrpc.ManagementSe
serviceInstanceUpdate.setTimeBucket(timeBucket);
sourceReceiver.receive(serviceInstanceUpdate);
ServiceUpdate serviceUpdate = new ServiceUpdate();
serviceUpdate.setName(serviceName);
serviceUpdate.setNodeType(NodeType.Normal);
serviceUpdate.setTimeBucket(timeBucket);
sourceReceiver.receive(serviceUpdate);
ServiceMeta serviceMeta = new ServiceMeta();
serviceMeta.setName(serviceName);
serviceMeta.setNodeType(NodeType.Normal);
serviceMeta.setTimeBucket(timeBucket);
sourceReceiver.receive(serviceMeta);
responseObserver.onNext(Commands.newBuilder().build());
responseObserver.onCompleted();

View File

@ -31,7 +31,7 @@ import org.apache.skywalking.oap.server.core.analysis.NodeType;
import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
import org.apache.skywalking.oap.server.core.config.NamingLengthControl;
import org.apache.skywalking.oap.server.core.source.ServiceInstanceUpdate;
import org.apache.skywalking.oap.server.core.source.ServiceUpdate;
import org.apache.skywalking.oap.server.core.source.ServiceMeta;
import org.apache.skywalking.oap.server.core.source.SourceReceiver;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.server.jetty.ArgumentsParseException;
@ -70,11 +70,11 @@ public class ManagementServiceKeepAliveHandler extends JettyJsonHandler {
serviceInstanceUpdate.setTimeBucket(timeBucket);
sourceReceiver.receive(serviceInstanceUpdate);
ServiceUpdate serviceUpdate = new ServiceUpdate();
serviceUpdate.setName(serviceName);
serviceUpdate.setNodeType(NodeType.Normal);
serviceUpdate.setTimeBucket(timeBucket);
sourceReceiver.receive(serviceUpdate);
ServiceMeta serviceMeta = new ServiceMeta();
serviceMeta.setName(serviceName);
serviceMeta.setNodeType(NodeType.Normal);
serviceMeta.setTimeBucket(timeBucket);
sourceReceiver.receive(serviceMeta);
return gson.fromJson(ProtoBufJsonUtils.toJSON(Commands.newBuilder().build()), JsonElement.class);
}

View File

@ -286,6 +286,7 @@ public class MultiScopesAnalysisListener implements EntryAnalysisListener, ExitA
sourceReceiver.receive(serviceInstanceRelation);
}
if (RequestType.DATABASE.equals(exitSourceBuilder.getType())) {
sourceReceiver.receive(exitSourceBuilder.toServiceMeta());
sourceReceiver.receive(exitSourceBuilder.toDatabaseAccess());
}
});

View File

@ -33,6 +33,7 @@ import org.apache.skywalking.oap.server.core.source.RequestType;
import org.apache.skywalking.oap.server.core.source.Service;
import org.apache.skywalking.oap.server.core.source.ServiceInstance;
import org.apache.skywalking.oap.server.core.source.ServiceInstanceRelation;
import org.apache.skywalking.oap.server.core.source.ServiceMeta;
import org.apache.skywalking.oap.server.core.source.ServiceRelation;
@RequiredArgsConstructor
@ -109,6 +110,9 @@ class SourceBuilder {
@Setter
private long timeBucket;
/**
* The global level metrics source
*/
All toAll() {
All all = new All();
all.setName(destServiceName);
@ -122,6 +126,9 @@ class SourceBuilder {
return all;
}
/**
* Service meta and metrics related source of {@link #destServiceName}. The metrics base on the OAL scripts.
*/
Service toService() {
Service service = new Service();
service.setName(destServiceName);
@ -136,6 +143,9 @@ class SourceBuilder {
return service;
}
/**
* Service topology meta and metrics related source. The metrics base on the OAL scripts.
*/
ServiceRelation toServiceRelation() {
ServiceRelation serviceRelation = new ServiceRelation();
serviceRelation.setSourceServiceName(sourceServiceName);
@ -155,6 +165,10 @@ class SourceBuilder {
return serviceRelation;
}
/**
* Service instance meta and metrics of {@link #destServiceInstanceName} related source. The metrics base on the OAL
* scripts.
*/
ServiceInstance toServiceInstance() {
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setName(destServiceInstanceName);
@ -169,6 +183,9 @@ class SourceBuilder {
return serviceInstance;
}
/**
* Service instance topology/dependency meta and metrics related source. The metrics base on the OAL scripts.
*/
ServiceInstanceRelation toServiceInstanceRelation() {
if (StringUtil.isEmpty(sourceServiceInstanceName) || StringUtil.isEmpty(destServiceInstanceName)) {
return null;
@ -191,6 +208,9 @@ class SourceBuilder {
return serviceInstanceRelation;
}
/**
* Endpoint meta and metrics of {@link #destEndpointName} related source. The metrics base on the OAL scripts.
*/
Endpoint toEndpoint() {
Endpoint endpoint = new Endpoint();
endpoint.setName(destEndpointName);
@ -205,6 +225,9 @@ class SourceBuilder {
return endpoint;
}
/**
* Endpoint depedency meta and metrics related source. The metrics base on the OAL scripts.
*/
EndpointRelation toEndpointRelation() {
if (StringUtil.isEmpty(sourceEndpointName) || StringUtil.isEmpty(destEndpointName)) {
return null;
@ -228,6 +251,21 @@ class SourceBuilder {
return endpointRelation;
}
/**
* Service meta is only for building the service list, but wouldn't be same as {@link #toService()}, which could
* generate traffic and metrics both.
*/
ServiceMeta toServiceMeta() {
ServiceMeta service = new ServiceMeta();
service.setName(destServiceName);
service.setNodeType(destNodeType);
service.setTimeBucket(timeBucket);
return service;
}
/**
* Database traffic metrics source. The metrics base on the OAL scripts.
*/
DatabaseAccess toDatabaseAccess() {
if (!RequestType.DATABASE.equals(type)) {
return null;