Rename metric and indicator to metrics. (#2643)

* Rename metric to metrics.

* Fixed test case execute failure issues.
This commit is contained in:
彭勇升 pengys 2019-05-10 08:05:37 +08:00 committed by 吴晟 Wu Sheng
parent c46554a1ae
commit ed78dabe8b
228 changed files with 1967 additions and 2177 deletions

View File

@ -32,7 +32,7 @@ Release Notes.
**Performance improved, especially in CPU limited environment. 3x improvement in service mesh scenario(no trace) in 8C16G VM.
Significantly cost less CPU in low payload.**
- Support database metric and SLOW SQL detection.
- Support database metrics and SLOW SQL detection.
- Support to set max size of metadata query. And change default to 5000 from 100.
- Support ElasticSearch template for new feature in the future.
- Support shutdown Zipkin trace analysis, because it doesn't fit production environment.
@ -42,10 +42,10 @@ Significantly cost less CPU in low payload.**
- Support group endpoint name by regax rules in mesh receiver.
- Support `disable` statement in OAL.
- Support basic auth in ElasticSearch connection.
- Support metric exporter module and gRPC implementor.
- Support metrics exporter module and gRPC implementor.
- Support `>, <, >=, <=` in OAL.
- Support role mode in backend.
- Support Envoy metric.
- Support Envoy metrics.
- Support query segment by service instance.
- Support to set host/port manually at cluster coordinator, rather than based on core settings.
- Make sure OAP shutdown when it faces startup error.
@ -62,7 +62,7 @@ Significantly cost less CPU in low payload.**
#### UI
- RocketBot UI has been accepted and bind in this release.
- Support CLR metric.
- Support CLR metrics.
#### Document
- Documents updated, matching Top Level Project requirement.
@ -183,10 +183,10 @@ The core and most important features in v6 are
1. Support to collect telemetry data from different sources, such as multiple language agents and service mesh.
1. Extensible stream analysis core. Make SQL and cache analysis available in core level, although haven't
provided in this release.
1. Provide **Observability Analysis Language(OAL)** to make analysis metric customization available.
1. Provide **Observability Analysis Language(OAL)** to make analysis metrics customization available.
1. New GraphQL query protocol. Not binding with UI now.
1. UI topology is better now.
1. New alarm core provided. In alpha, only on service related metric.
1. New alarm core provided. In alpha, only on service related metrics.
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/29?closed=1)

View File

@ -25,7 +25,7 @@ The core features are following.
- Slow services and endpoints detected
- Performance optimization
- Distributed tracing and context propagation
- Database access metric. Detect slow database access statements(including SQL statements).
- Database access metrics. Detect slow database access statements(including SQL statements).
- Alarm
@ -38,7 +38,7 @@ including
1. Istio telemetry format
1. Zipkin v1/v2 format
1. Jaeger gRPC format.
1. Envoy metrics format (the metric entries itself is prometheus client [metric family](https://github.com/prometheus/client_model/blob/fd36f4220a901265f90734c3183c5f0c91daa0b8/metrics.proto#L77))
1. Envoy metrics format (the metrics entries itself is prometheus client [metrics family](https://github.com/prometheus/client_model/blob/fd36f4220a901265f90734c3183c5f0c91daa0b8/metrics.proto#L77))
# Document

View File

@ -107,7 +107,7 @@ public class JVMService implements BootService, Runnable {
jvmBuilder.setTime(currentTimeMillis);
jvmBuilder.setCpu(CPUProvider.INSTANCE.getCpuMetric());
jvmBuilder.addAllMemory(MemoryProvider.INSTANCE.getMemoryMetricList());
jvmBuilder.addAllMemoryPool(MemoryPoolProvider.INSTANCE.getMemoryPoolMetricList());
jvmBuilder.addAllMemoryPool(MemoryPoolProvider.INSTANCE.getMemoryPoolMetricsList());
jvmBuilder.addAllGc(GCProvider.INSTANCE.getGCList());
JVMMetric jvmMetric = jvmBuilder.build();

View File

@ -20,17 +20,16 @@
package org.apache.skywalking.apm.agent.core.jvm.cpu;
import org.apache.skywalking.apm.network.common.CPU;
import org.apache.skywalking.apm.network.language.agent.*;
/**
* @author wusheng
*/
public abstract class CPUMetricAccessor {
public abstract class CPUMetricsAccessor {
private long lastCPUTimeNs;
private long lastSampleTimeNs;
private final int cpuCoreNum;
public CPUMetricAccessor(int cpuCoreNum) {
public CPUMetricsAccessor(int cpuCoreNum) {
this.cpuCoreNum = cpuCoreNum;
}
@ -41,7 +40,7 @@ public abstract class CPUMetricAccessor {
protected abstract long getCpuTime();
public CPU getCPUMetric() {
public CPU getCPUMetrics() {
long cpuTime = this.getCpuTime();
long cpuCost = cpuTime - lastCPUTimeNs;
long now = System.nanoTime();

View File

@ -23,29 +23,28 @@ import org.apache.skywalking.apm.agent.core.logging.api.ILog;
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
import org.apache.skywalking.apm.agent.core.os.ProcessorUtil;
import org.apache.skywalking.apm.network.common.CPU;
import org.apache.skywalking.apm.network.language.agent.*;
/**
* @author wusheng
*/
public enum CPUProvider {
INSTANCE;
private CPUMetricAccessor cpuMetricAccessor;
private CPUMetricsAccessor cpuMetricsAccessor;
CPUProvider() {
int processorNum = ProcessorUtil.getNumberOfProcessors();
try {
this.cpuMetricAccessor =
(CPUMetricAccessor)CPUProvider.class.getClassLoader().loadClass("org.apache.skywalking.apm.agent.core.jvm.cpu.SunCpuAccessor")
this.cpuMetricsAccessor =
(CPUMetricsAccessor)CPUProvider.class.getClassLoader().loadClass("org.apache.skywalking.apm.agent.core.jvm.cpu.SunCpuAccessor")
.getConstructor(int.class).newInstance(processorNum);
} catch (Exception e) {
this.cpuMetricAccessor = new NoSupportedCPUAccessor(processorNum);
this.cpuMetricsAccessor = new NoSupportedCPUAccessor(processorNum);
ILog logger = LogManager.getLogger(CPUProvider.class);
logger.error(e, "Only support accessing CPU metric in SUN JVM platform.");
logger.error(e, "Only support accessing CPU metrics in SUN JVM platform.");
}
}
public CPU getCpuMetric() {
return cpuMetricAccessor.getCPUMetric();
return cpuMetricsAccessor.getCPUMetrics();
}
}

View File

@ -22,7 +22,7 @@ package org.apache.skywalking.apm.agent.core.jvm.cpu;
/**
* @author wusheng
*/
public class NoSupportedCPUAccessor extends CPUMetricAccessor {
public class NoSupportedCPUAccessor extends CPUMetricsAccessor {
public NoSupportedCPUAccessor(int cpuCoreNum) {
super(cpuCoreNum);
}

View File

@ -25,7 +25,7 @@ import java.lang.management.ManagementFactory;
/**
* @author wusheng
*/
public class SunCpuAccessor extends CPUMetricAccessor {
public class SunCpuAccessor extends CPUMetricsAccessor {
private final OperatingSystemMXBean osMBean;
public SunCpuAccessor(int cpuCoreNum) {

View File

@ -16,15 +16,14 @@
*
*/
package org.apache.skywalking.apm.agent.core.jvm.memorypool;
import java.util.List;
import org.apache.skywalking.apm.network.language.agent.*;
import org.apache.skywalking.apm.network.language.agent.MemoryPool;
/**
* @author wusheng
*/
public interface MemoryPoolMetricAccessor {
List<MemoryPool> getMemoryPoolMetricList();
public interface MemoryPoolMetricsAccessor {
List<MemoryPool> getMemoryPoolMetricsList();
}

View File

@ -16,19 +16,16 @@
*
*/
package org.apache.skywalking.apm.agent.core.jvm.memorypool;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryUsage;
import java.util.LinkedList;
import java.util.List;
import java.lang.management.*;
import java.util.*;
import org.apache.skywalking.apm.network.language.agent.*;
/**
* @author wusheng
*/
public abstract class MemoryPoolModule implements MemoryPoolMetricAccessor {
public abstract class MemoryPoolModule implements MemoryPoolMetricsAccessor {
private List<MemoryPoolMXBean> beans;
public MemoryPoolModule(List<MemoryPoolMXBean> beans) {
@ -36,7 +33,7 @@ public abstract class MemoryPoolModule implements MemoryPoolMetricAccessor {
}
@Override
public List<MemoryPool> getMemoryPoolMetricList() {
public List<MemoryPool> getMemoryPoolMetricsList() {
List<MemoryPool> poolList = new LinkedList<MemoryPool>();
for (MemoryPoolMXBean bean : beans) {
String name = bean.getName();

View File

@ -19,10 +19,9 @@
package org.apache.skywalking.apm.agent.core.jvm.memorypool;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.*;
import java.util.List;
import org.apache.skywalking.apm.network.language.agent.*;
import org.apache.skywalking.apm.network.language.agent.MemoryPool;
/**
* @author wusheng
@ -30,14 +29,14 @@ import org.apache.skywalking.apm.network.language.agent.*;
public enum MemoryPoolProvider {
INSTANCE;
private MemoryPoolMetricAccessor metricAccessor;
private MemoryPoolMetricsAccessor metricAccessor;
private List<MemoryPoolMXBean> beans;
MemoryPoolProvider() {
beans = ManagementFactory.getMemoryPoolMXBeans();
for (MemoryPoolMXBean bean : beans) {
String name = bean.getName();
MemoryPoolMetricAccessor accessor = findByBeanName(name);
MemoryPoolMetricsAccessor accessor = findByBeanName(name);
if (accessor != null) {
metricAccessor = accessor;
break;
@ -48,11 +47,11 @@ public enum MemoryPoolProvider {
}
}
public List<MemoryPool> getMemoryPoolMetricList() {
return metricAccessor.getMemoryPoolMetricList();
public List<MemoryPool> getMemoryPoolMetricsList() {
return metricAccessor.getMemoryPoolMetricsList();
}
private MemoryPoolMetricAccessor findByBeanName(String name) {
private MemoryPoolMetricsAccessor findByBeanName(String name) {
if (name.indexOf("PS") > -1) {
//Parallel (Old) collector ( -XX:+UseParallelOldGC )
return new ParallelCollectorModule(beans);

View File

@ -26,9 +26,9 @@ import org.apache.skywalking.apm.network.language.agent.*;
/**
* @author wusheng
*/
public class UnknownMemoryPool implements MemoryPoolMetricAccessor {
public class UnknownMemoryPool implements MemoryPoolMetricsAccessor {
@Override
public List<MemoryPool> getMemoryPoolMetricList() {
public List<MemoryPool> getMemoryPoolMetricsList() {
List<MemoryPool> poolList = new LinkedList<MemoryPool>();
poolList.add(MemoryPool.newBuilder().setType(PoolType.CODE_CACHE_USAGE).build());
poolList.add(MemoryPool.newBuilder().setType(PoolType.NEWGEN_USAGE).build());

View File

@ -18,7 +18,7 @@
rules:
# Rule unique name, must be ended with `_rule`.
service_resp_time_rule:
indicator-name: service_resp_time
metrics-name: service_resp_time
op: ">"
threshold: 1000
period: 10
@ -26,8 +26,8 @@ rules:
silence-period: 5
message: Response time of service {name} is more than 1000ms in last 3 minutes.
service_sla_rule:
# Indicator value need to be long, double or int
indicator-name: service_sla
# Metrics value need to be long, double or int
metrics-name: service_sla
op: "<"
threshold: 8000
# The length of time to evaluate the metric
@ -38,8 +38,8 @@ rules:
silence-period: 3
message: Successful rate of service {name} is lower than 80% in last 2 minutes.
service_p90_sla_rule:
# Indicator value need to be long, double or int
indicator-name: service_p90
# Metrics value need to be long, double or int
metrics-name: service_p90
op: ">"
threshold: 1000
period: 10
@ -47,7 +47,7 @@ rules:
silence-period: 5
message: 90% response time of service {name} is more than 1000ms in last 3 minutes
service_instance_resp_time_rule:
indicator-name: service_instance_resp_time
metrics-name: service_instance_resp_time
op: ">"
threshold: 1000
period: 10
@ -58,7 +58,7 @@ rules:
# Because the number of endpoint is much more than service and instance.
#
# endpoint_avg_rule:
# indicator-name: endpoint_avg
# metrics-name: endpoint_avg
# op: ">"
# threshold: 1000
# period: 10

View File

@ -18,6 +18,6 @@ SkyWalking already support.
- Backend
- [Overview](backend-overview.md). Provides a high level introduction about the OAP backend.
- [Observability Analysis Language](oal.md). Introduces the core languages, which is designed for aggregation behaviour definition.
- [Query in OAP](../protocols/README.md#query-protocol). A set of query protocol provided, based on the Observability Analysis Language metric definition.
- [Query in OAP](../protocols/README.md#query-protocol). A set of query protocol provided, based on the Observability Analysis Language metrics definition.
- UI
- [Overview](ui-overview.md). A simple brief about SkyWalking UI.

View File

@ -3,11 +3,11 @@ OAP(Observability Analysis Platform) is a new concept, which starts in SkyWalkin
old SkyWalking whole backend. The capabilities of the platform are following.
## OAP capabilities
OAP accepts data from more sources, which belongs two groups: **Tracing** and **Metric**.
OAP accepts data from more sources, which belongs two groups: **Tracing** and **Metrics**.
- **Tracing**. Including, SkyWalking native data formats. Zipkin v1,v2 data formats and Jaeger data formats.
- **Metric**. SkyWalking integrates with Service Mesh platforms, such as Istio, Envoy, Linkerd, to provide observability from data panel
or control panel. Also, SkyWalking native agents can run in metric mode, which highly improve the
- **Metrics**. SkyWalking integrates with Service Mesh platforms, such as Istio, Envoy, Linkerd, to provide observability from data panel
or control panel. Also, SkyWalking native agents can run in metrics mode, which highly improve the
performance.
At the same time by using any integration solution provided, such as SkyWalking log plugin or toolkits,
@ -19,16 +19,16 @@ As usual, all services provided by gRPC and HTTP protocol to make integration ea
## Tracing in OAP
Tracing in OAP has two ways to process.
1. Traditional way in SkyWalking 5 series. Format tracing data in SkyWalking trace segment and span formats,
even for Zipkin data format. The OAP analysis the segments to get metrics, and push the metric data into
even for Zipkin data format. The OAP analysis the segments to get metrics, and push the metrics data into
the streaming aggregation.
1. Consider tracing as some kinds of logging only. Just provide save and visualization capabilities for trace.
Also, SkyWalking accepts trace formats from other project, such as Zipkin, Jeager, OpenCensus.
These formats could be processed in the two ways too.
## Metric in OAP
Metric in OAP is totally new feature in 6 series. Build observability for a distributed system based on metric of connected nodes.
## Metrics in OAP
Metrics in OAP is totally new feature in 6 series. Build observability for a distributed system based on metrics of connected nodes.
No tracing data is required.
Metric data are aggregated inside OAP cluster in streaming mode. See about [Observability Analysis Language](oal.md),
Metrics data are aggregated inside OAP cluster in streaming mode. See about [Observability Analysis Language](oal.md),
which provides the easy way to do aggregation and analysis in script style.

View File

@ -1,7 +1,7 @@
# Observability Analysis Language
Provide OAL(Observability Analysis Language) to analysis incoming data in streaming mode.
OAL focuses on metric in Service, Service Instance and Endpoint. Because of that, the language is easy to
OAL focuses on metrics in Service, Service Instance and Endpoint. Because of that, the language is easy to
learn and use.
Considering performance, reading and debugging, OAL is defined as a compile language.
@ -10,13 +10,13 @@ The OAL scripts will be compiled to normal Java codes in package stage.
## Grammar
Scripts should be named as `*.oal`
```
// Declare the metric.
METRIC_NAME = from(SCOPE.(* | [FIELD][,FIELD ...]))
// Declare the metrics.
METRICS_NAME = from(SCOPE.(* | [FIELD][,FIELD ...]))
[.filter(FIELD OP [INT | STRING])]
.FUNCTION([PARAM][, PARAM ...])
// Disable hard code
disable(METRIC_NAME);
disable(METRICS_NAME);
```
## Scope
@ -62,17 +62,17 @@ In this case, p99 value of all incoming requests.
In this case, thermodynamic heatmap of all incoming requests.
## Metric name
The metric name for storage implementor, alarm and query modules. The type inference supported by core.
## Metrics name
The metrics name for storage implementor, alarm and query modules. The type inference supported by core.
## Group
All metric data will be grouped by Scope.ID and min-level TimeBucket.
All metrics data will be grouped by Scope.ID and min-level TimeBucket.
- In `Endpoint` scope, the Scope.ID = Endpoint id (the unique id based on service and its Endpoint)
## Disable
`Disable` is an advanced statement in OAL, which is only used in certain case.
Some of the aggregation and metric are defined through core hard codes,
Some of the aggregation and metrics are defined through core hard codes,
this `disable` statement is designed for make them de-active,
such as `segment`, `top_n_database_statement`.
In default, no one is being disable.
@ -89,7 +89,7 @@ serv_Endpoint_p99 = from(Endpoint.latency).filter(name like ("serv%")).summary(0
Endpoint_avg = from(Endpoint.latency).avg()
// Caculate the histogram of each Endpoint by 50 ms steps.
// Always thermodynamic diagram in UI matches this metric.
// Always thermodynamic diagram in UI matches this metrics.
Endpoint_histogram = from(Endpoint.latency).histogram(50)
// Caculate the percent of response status is true, for each service.

View File

@ -1,6 +1,6 @@
# Probe Introduction
In SkyWalking, probe means an agent or SDK library integrated into target system, which take charge of
collecting telemetry data including tracing and metric. Based on the target system tech stack, probe could use very different
collecting telemetry data including tracing and metrics. Based on the target system tech stack, probe could use very different
ways to do so. But ultimately they are same, just collect and reformat data, then send to backend.
In high level, there are three typical groups in all SkyWalking probes.
@ -13,11 +13,11 @@ of agents based on languages and libraries.
is only used as ingress of the whole cluster, but with the Service Mesh and sidecar, now we can do observe based on that.
- **3rd-party instrument library**. SkyWalking accepts other popular used instrument libraries data format. It analysis the
data, transfer it to SkyWalking formats of trace, metric or both. This feature starts with accepting Zipkin span data. See
data, transfer it to SkyWalking formats of trace, metrics or both. This feature starts with accepting Zipkin span data. See
[Receiver for other tracers](../setup/backend/backend-receivers.md) to know more.
You don't need to use **Language based native agent** and **Service Mesh probe** at the same time, because they both collect
metric data. As a result of that, your system suffers twice payloads, and the analytic numbers are doubled.
metrics data. As a result of that, your system suffers twice payloads, and the analytic numbers are doubled.
There are several recommend ways in using these probes:
1. Use **Language based native agent** only.

View File

@ -4,9 +4,9 @@ The document outlines the core design goals for SkyWalking project.
- **Keep Observability**. No matter how does the target system deploy, SkyWalking could provide a solution or
integration way to keep observability for it. Based on this, SkyWalking provides several runtime forms and probes.
- **Topology, Metric and Trace Together**. The first step to see and understand a distributed system should be
- **Topology, Metrics and Trace Together**. The first step to see and understand a distributed system should be
from topology map. It visualizes the whole complex system as an easy map. Under that topology, OSS people requires
more about metric for service, instance, endpoint and calls. Trace exists as detail logs for making sense of those metric.
more about metrics for service, instance, endpoint and calls. Trace exists as detail logs for making sense of those metrics.
Such as when endpoint latency becomes long, you want to see the slowest the trace to find out why. So you can see,
they are from big picture to details, they are all needed. SkyWalking integrates and provides a lot of features to
make this possible and easy understand.

View File

@ -13,7 +13,7 @@ By using Aggregation Function, the requests will group by time and **Group Key(s
### SCOPE `Service`
Calculate the metric data from each request of the service.
Calculate the metrics data from each request of the service.
| Name | Remarks | Group Key | Type |
|---|---|---|---|
@ -28,7 +28,7 @@ Calculate the metric data from each request of the service.
### SCOPE `ServiceInstance`
Calculate the metric data from each request of the service instance.
Calculate the metrics data from each request of the service instance.
| Name | Remarks | Group Key | Type |
|---|---|---|---|
@ -43,7 +43,7 @@ Calculate the metric data from each request of the service instance.
#### Secondary scopes of `ServiceInstance`
Calculate the metric data if the service instance is a JVM and collected by javaagent.
Calculate the metrics data if the service instance is a JVM and collected by javaagent.
1. SCOPE `ServiceInstanceJVMCPU`
@ -61,7 +61,7 @@ Calculate the metric data if the service instance is a JVM and collected by java
| id | Represent the unique id of the service instance, usually a number. | yes | int |
| name | Represent the name of the service instance. Such as `ip:port@Service Name`. **Notice**: current native agent uses `processId@Service name` as instance name, which is useless when you want to setup a filter in aggregation. | | string|
| serviceName | Represent the name of the service. | | string |
| heapStatus | Represent this value the memory metric values are heap or not | | bool |
| heapStatus | Represent this value the memory metrics values are heap or not | | bool |
| init | See JVM document | | long |
| max | See JVM document | | long |
| used | See JVM document | | long |
@ -93,7 +93,7 @@ Calculate the metric data if the service instance is a JVM and collected by java
### SCOPE `Endpoint`
Calculate the metric data from each request of the endpoint in the service.
Calculate the metrics data from each request of the endpoint in the service.
| Name | Remarks | Group Key | Type |
|---|---|---|---|
@ -108,7 +108,7 @@ Calculate the metric data from each request of the endpoint in the service.
### SCOPE `ServiceRelation`
Calculate the metric data from each request between one service and the other service
Calculate the metrics data from each request between one service and the other service
| Name | Remarks | Group Key | Type |
|---|---|---|---|
@ -129,7 +129,7 @@ Calculate the metric data from each request between one service and the other se
### SCOPE `ServiceInstanceRelation`
Calculate the metric data from each request between one service instance and the other service instance
Calculate the metrics data from each request between one service instance and the other service instance
| Name | Remarks | Group Key | Type |
|---|---|---|---|
@ -149,7 +149,7 @@ Calculate the metric data from each request between one service instance and the
### SCOPE `EndpointRelation`
Calculate the metric data of the dependency between one endpoint and the other endpoint.
Calculate the metrics data of the dependency between one endpoint and the other endpoint.
This relation is hard to detect, also depends on tracing lib to propagate the prev endpoint.
So `EndpointRelation` scope aggregation effects only in service under tracing by SkyWalking native agents,
including auto instrument agents(like Java, .NET), OpenCensus SkyWalking exporter implementation or others propagate tracing context in SkyWalking spec.

View File

@ -24,9 +24,9 @@ platform still works?
Service Mesh probes collects telemetry data from each request, so it knows the source, destination,
endpoint, latency and status. By those, backend can tell the whole topology map by combining these call
as lines, and also the metric of each nodes through their incoming request. Backend asked for the same
metric data from parsing tracing data. So, the right expression is:
**Service Mesh metric are exact the metric, what the traces parsers generate. They are same.**
as lines, and also the metrics of each nodes through their incoming request. Backend asked for the same
metrics data from parsing tracing data. So, the right expression is:
**Service Mesh metrics are exact the metrics, what the traces parsers generate. They are same.**
## What is Next?
- If you want to use the service mesh probe, read [set SkyWalking on Service Mesh](../setup/README.md#on-service-mesh) document.

View File

@ -36,8 +36,8 @@ and private plugin developer should read this.
- If you want to build a new probe or plugin in any language, please read [Component library definition and extension](Component-library-settings.md) document.
- [Storage extension development guide](storage-extention.md). Help potential contributors to build a new
storage implementor besides the official.
- [Customize analysis by oal script](write-oal.md). Guide you to use oal script to make your own metric available.
- [Source and scope extension for new metric](source-extension.md). If you want to analysis a new metric, which SkyWalking
- [Customize analysis by oal script](write-oal.md). Guide you to use oal script to make your own metrics available.
- [Source and scope extension for new metrics](source-extension.md). If you want to analysis a new metrics, which SkyWalking
haven't provide. You need to
add a new receiver rather than choosing [existed receiver](../setup/backend/backend-receivers.md).
At that moment,

View File

@ -9,7 +9,7 @@ You need to use OAL tool code generator to build the real analysis codes from it
All generated codes are under `oal` folder in **oap-server/generated-analysis/target/generated-sources**.
All metrics named in this script could be used in alarm and UI query. Of course, you can change this
scripts and re-generate the analysis process and metric, such as adding filter condition.
scripts and re-generate the analysis process and metrics, such as adding filter condition.
If you try to add or remove some metric, UI may break, we only recommend you to do this when you plan
If you try to add or remove some metrics, UI may break, we only recommend you to do this when you plan
to build your own UI based on the customization analysis core.

View File

@ -5,7 +5,7 @@ SkyWalking includes four inventory entities.
- Endpoint Inventory
- Network Address Inventory
All metric, topology, trace and alarm are related to these entity IDs.
All metrics, topology, trace and alarm are related to these entity IDs.
For understanding the **Service**, **Service Instance** and **Endpoint** concepts,
please read [Project Overview](../concepts-and-designs/overview.md#why-use-skywalking).

View File

@ -1,4 +1,4 @@
# Source and Scope extension for new metric
# Source and Scope extension for new metrics
From [OAL scope introduction](../concepts-and-designs/oal.md#scope), you should already have understood what the scope is.
At here, as you want to do more extension, you need understand deeper, which is the **Source**.
@ -53,11 +53,11 @@ This value is used in [OAL group mechanism](../concepts-and-designs/oal.md#group
7. Set the default columns for new scope, at `generator-scope-meta.yml` file in `generated-analysis/src/main/resources`.
If you want to understand why need these columns, you have to understand all existing query(s). But there is an easy way,
follow other existing scopes. Such as, if you are adding metric, connection number for service instance, follow existing `ServiceInstance`.
follow other existing scopes. Such as, if you are adding metrics, connection number for service instance, follow existing `ServiceInstance`.
___
After you done all of these, you could build a receiver, which do
1. Get the original data of the metric,
1. Get the original data of the metrics,
1. Build the source, send into `SourceReceiver`.
1. Write your whole OAL scripts.
1. Repackage the project.

View File

@ -22,7 +22,7 @@ Here is the list of all DAO interfaces in storage
1. StorageDAO
1. IRegisterLockDAO
1. H2TopologyQueryDAO
1. IMetricQueryDAO
1. IMetricsQueryDAO
1. ITraceQueryDAO
1. IMetadataQueryDAO
1. IAggregationQueryDAO

View File

@ -1,7 +1,7 @@
# Protocols
There are two types of protocols list here.
- [**Probe Protocol**](#probe-protocols). Include the descriptions and definitions about how agent send collected metric data and traces, also the formats of each entities.
- [**Probe Protocol**](#probe-protocols). Include the descriptions and definitions about how agent send collected metrics data and traces, also the formats of each entities.
- [**Query Protocol**](#query-protocol). The backend provide query capability to SkyWalking own UI and others. These queries are based on GraphQL.
@ -66,20 +66,20 @@ There are 5 dimensionality data is provided.
1. Metadata. Metadata includes the brief info of the whole under monitoring services and their instances, endpoints, etc.
Use multiple ways to query this meta data.
1. Topology. Show the topology and dependency graph of services or endpoints. Including direct relationship or global map.
1. Metric. Metric query targets all the objects defined in [OAL script](../concepts-and-designs/oal.md). You could get the
metric data in linear or thermodynamic matrix formats based on the aggregation functions in script.
1. Aggregation. Aggregation query means the metric data need a secondary aggregation in query stage, which makes the query
1. Metrics. Metrics query targets all the objects defined in [OAL script](../concepts-and-designs/oal.md). You could get the
metrics data in linear or thermodynamic matrix formats based on the aggregation functions in script.
1. Aggregation. Aggregation query means the metrics data need a secondary aggregation in query stage, which makes the query
interfaces have some different arguments. Such as, `TopN` list of services is a very typical aggregation query,
metric stream aggregation just calculates the metric values of each service, but the expected list needs ordering metric data
metrics stream aggregation just calculates the metrics values of each service, but the expected list needs ordering metrics data
by the values.
1. Trace. Query distributed traces by this.
1. Alarm. Through alarm query, you can have alarm trend and details.
The actual query GraphQL scrips could be found inside `query-protocol` folder in [here](../../../oap-server/server-query-plugin/query-graphql-plugin/src/main/resources).
Here is the list of all existing metric names, based on [official_analysis.oal](../../../oap-server/generated-analysis/src/main/resources/official_analysis.oal)
Here is the list of all existing metrics names, based on [official_analysis.oal](../../../oap-server/generated-analysis/src/main/resources/official_analysis.oal)
**Global metric**
**Global metrics**
- all_p99, p99 response time of all services
- all_p95
- all_p90
@ -87,7 +87,7 @@ Here is the list of all existing metric names, based on [official_analysis.oal](
- all_p70
- all_heatmap, the response time heatmap of all services
**Service metric**
**Service metrics**
- service_resp_time, avg response time of service
- service_sla, successful rate of service
- service_cpm, calls per minute of service
@ -97,12 +97,12 @@ Here is the list of all existing metric names, based on [official_analysis.oal](
- service_p75
- service_p50
**Service instance metric**
**Service instance metrics**
- service_instance_sla, successful rate of service instance
- service_instance_resp_time, avg response time of service instance
- service_instance_cpm, calls per minute of service instance
**Endpoint metric**
**Endpoint metrics**
- endpoint_cpm, calls per minute of endpoint
- endpoint_avg, avg response time of endpoint
- endpoint_sla, successful rate of endpoint
@ -112,7 +112,7 @@ Here is the list of all existing metric names, based on [official_analysis.oal](
- endpoint_p75
- endpoint_p50
**JVM metric**, JVM related metric, only work when javaagent is active
**JVM metrics**, JVM related metrics, only work when javaagent is active
- instance_jvm_cpu
- instance_jvm_memory_heap
- instance_jvm_memory_noheap
@ -123,8 +123,8 @@ Here is the list of all existing metric names, based on [official_analysis.oal](
- instance_jvm_young_gc_count
- instance_jvm_old_gc_count
**Service relation metric**, represents the metric of calls between service.
The metric ID could be
**Service relation metrics**, represents the metrics of calls between service.
The metrics ID could be
got in topology query only.
- service_relation_client_cpm, calls per minute detected at client side
- service_relation_server_cpm, calls per minute detected at server side
@ -133,7 +133,7 @@ got in topology query only.
- service_relation_client_resp_time, avg response time detected at client side
- service_relation_server_resp_time, avg response time detected at server side
**Endpoint relation metric**, represents the metric between dependency endpoints. Only work when tracing agent.
The metric ID could be got in topology query only.
**Endpoint relation metrics**, represents the metrics between dependency endpoints. Only work when tracing agent.
The metrics ID could be got in topology query only.
- endpoint_relation_cpm
- endpoint_relation_resp_time

View File

@ -5,7 +5,7 @@ Trace Data Protocol describes the data format between SkyWalking agent/sniffer a
Trace data protocol is defined and provided in [gRPC format](https://github.com/apache/skywalking-data-collect-protocol).
For each agent/SDK, it needs to register service id and service instance id before reporting any kind of trace
or metric data.
or metrics data.
### Step 1. Do register
[Register service](https://github.com/apache/skywalking-data-collect-protocol/tree/master/register/Register.proto) takes charge of
@ -23,8 +23,8 @@ In most cases, you need to set a timer to call these services repeated, until yo
Because batch is supported, even for most language agent/SDK, no scenario to do batch register. We suggest to check the `serviceName`
and `UUID` in response, and match with your expected value.
### Step 2. Send trace and metric
After you have service id and service instance id, you could send traces and metric. Now we
### Step 2. Send trace and metrics
After you have service id and service instance id, you could send traces and metrics. Now we
have
1. `TraceSegmentReportService#collect` for skywalking native trace format
1. `JVMMetricReportService#collect` for skywalking native jvm format

View File

@ -1,14 +1,14 @@
# Alarm
Alarm core is driven a collection of rules, which are defined in `config/alarm-settings.yml`.
There are two parts in alarm rule definition.
1. Alarm rules. They define how metric alarm should be triggered, what conditions should be considered.
1. Alarm rules. They define how metrics alarm should be triggered, what conditions should be considered.
1. Webhooks. The list of web service endpoint, which should be called after the alarm is triggered.
## Rules
Alarm rule is constituted by following keys
- **Rule name**. Unique name, show in alarm message. Must end with `_rule`.
- **Indicator name**. A.K.A. metric name in oal script. Only long, double, int types are supported. See
[List of all potential metric name](#list-of-all-potential-metric-name).
- **Metrics name**. A.K.A. metrics name in oal script. Only long, double, int types are supported. See
[List of all potential metrics name](#list-of-all-potential-metrics-name).
- **Include names**. The following entity names are included in this rule. Such as Service name,
endpoint name.
- **Threshold**. The target value.
@ -19,27 +19,27 @@ backend deployment env time.
should send.
- **Silence period**. After alarm is triggered in Time-N, then keep silence in the **TN -> TN + period**.
By default, it is as same as **Period**, which means in a period, same alarm(same ID in same
indicator name) will be trigger once.
metrics name) will be trigger once.
```yaml
rules:
# Rule unique name, must be ended with `_rule`.
endpoint_percent_rule:
# Indicator value need to be long, double or int
indicator-name: endpoint_percent
# Metrics value need to be long, double or int
metrics-name: endpoint_percent
threshold: 75
op: <
# The length of time to evaluate the metric
# The length of time to evaluate the metrics
period: 10
# How many times after the metric match the condition, will trigger alarm
# How many times after the metrics match the condition, will trigger alarm
count: 3
# How many times of checks, the alarm keeps silence after alarm triggered, default as same as period.
silence-period: 10
service_percent_rule:
indicator-name: service_percent
# [Optional] Default, match all services in this indicator
metrics-name: service_percent
# [Optional] Default, match all services in this metrics
include-names:
- service_a
- service_b
@ -59,8 +59,8 @@ We provided a default `alarm-setting.yml` in our distribution only for convenien
## List of all potential metric name
The metric names are defined in official [OAL scripts](../../guides/backend-oal-scripts.md), right now
metric from **Service**, **Service Instance**, **Endpoint** scopes could be used in Alarm, we will extend in further versions.
## List of all potential metrics name
The metrics names are defined in official [OAL scripts](../../guides/backend-oal-scripts.md), right now
metrics from **Service**, **Service Instance**, **Endpoint** scopes could be used in Alarm, we will extend in further versions.
Submit issue or pull request if you want to support any other scope in alarm.

View File

@ -8,9 +8,9 @@ We have following receivers, and `default` implementors are provided in our Apac
1. **receiver-trace**. gRPC and HTTPRestful services to accept SkyWalking format traces.
1. **receiver-register**. gRPC and HTTPRestful services to provide service, service instance and endpoint register.
1. **service-mesh**. gRPC services accept data from inbound mesh probes.
1. **receiver-jvm**. gRPC services accept JVM metric data.
1. **receiver-jvm**. gRPC services accept JVM metrics data.
1. **istio-telemetry**. Istio telemetry is from Istio official bypass adaptor, this receiver match its gRPC services.
1. **envoy-metric**. Envoy `metrics_service` supported by this receiver. OAL script support all GAUGE type metrics.
1. **envoy-metrics**. Envoy `metrics_service` supported by this receiver. OAL script support all GAUGE type metrics.
1. **receiver_zipkin**. See [details](#zipkin-receiver).
1. **receiver_jaeger**. See [details](#jaeger-receiver).
@ -35,7 +35,7 @@ service-mesh:
bufferFileCleanWhenRestart: false
istio-telemetry:
default:
envoy-metric:
envoy-metrics:
default:
receiver_zipkin:
default:
@ -66,7 +66,7 @@ Zipkin receiver could work in two different mode.
1. Tracing mode(default). Tracing mode is that, skywalking OAP acts like zipkin collector,
fully supports Zipkin v1/v2 formats through HTTP service,
also provide persistence and query in skywalking UI.
But it wouldn't analysis metric from them. In most case, I suggest you could use this feature, when metrics come from service mesh.
But it wouldn't analysis metrics from them. In most case, I suggest you could use this feature, when metrics come from service mesh.
Notice, in this mode, Zipkin receiver requires `zipkin-elasticsearch` storage implementation active.
Read [this](backend-storage.md#elasticsearch-6-with-zipkin-trace-extension) to know
how to active.

View File

@ -66,20 +66,20 @@ DB. But clearly, it doesn't fit the product env. In here, you could find what ot
Choose the one you like, we are also welcome anyone to contribute new storage implementor,
1. [Set receivers](backend-receivers.md). You could choose receivers by your requirements, most receivers
are harmless, at least our default receivers are. You would set and active all receivers provided.
1. Do [trace sampling](trace-sampling.md) at backend. This sample keep the metric accurate, only don't save some of traces
1. Do [trace sampling](trace-sampling.md) at backend. This sample keep the metrics accurate, only don't save some of traces
in storage based on rate.
1. Follow [slow DB statement threshold](slow-db-statement.md) config document to understand that,
how to detect the Slow database statements(including SQL statements) in your system.
1. Official [OAL scripts](../../guides/backend-oal-scripts.md). As you known from our [OAL introduction](../../concepts-and-designs/oal.md),
most of backend analysis capabilities based on the scripts. Here is the description of official scripts,
which helps you to understand which metric data are in process, also could be used in alarm.
which helps you to understand which metrics data are in process, also could be used in alarm.
1. [Alarm](backend-alarm.md). Alarm provides a time-series based check mechanism. You could set alarm
rules targeting the analysis oal metric objects.
rules targeting the analysis oal metrics objects.
1. [Advanced deployment options](advanced-deployment.md). If you want to deploy backend in very large
scale and support high payload, you may need this.
1. [Metric exporter](metric-exporter.md). Use metric data exporter to forward metric data to 3rd party
1. [Metrics exporter](metrics-exporter.md). Use metrics data exporter to forward metrics data to 3rd party
system.
1. [Time To Live (TTL)](ttl.md). Metric and trace are time series data, they would be saved forever, you could
1. [Time To Live (TTL)](ttl.md). Metrics and trace are time series data, they would be saved forever, you could
set the expired time for each dimension.
## Telemetry for backend
@ -89,11 +89,11 @@ we provide the telemetry for OAP backend itself. Follow [document](backend-telem
## FAQs
#### When and why do we need to set Timezone?
SkyWalking provides downsampling time series metric features.
Query and storage at each time dimension(minute, hour, day, month metric indexes)
SkyWalking provides downsampling time series metrics features.
Query and storage at each time dimension(minute, hour, day, month metrics indexes)
related to timezone when doing time format.
For example, metric time will be formatted like YYYYMMDDHHmm in minute dimension metric,
For example, metrics time will be formatted like YYYYMMDDHHmm in minute dimension metrics,
which format process is timezone related.
In default, SkyWalking OAP backend choose the OS default timezone.

View File

@ -7,7 +7,7 @@ telemetry:
## Prometheus
Prometheus is supported as telemetry implementor.
By using this, prometheus collects metric from skywalking backend.
By using this, prometheus collects metrics from skywalking backend.
Set `prometheus` to provider. The endpoint open at `http://0.0.0.0:1234/` and `http://0.0.0.0:1234/metrics`.
```yaml

View File

@ -1,9 +1,9 @@
# Metric Exporter
SkyWalking provides basic and most important metric aggregation, alarm and analysis.
# Metrics Exporter
SkyWalking provides basic and most important metrics aggregation, alarm and analysis.
In real world, people may want to forward the data to their 3rd party system, for deeper analysis or anything else.
**Metric Exporter** makes that possible.
**Metrics Exporter** makes that possible.
Metric exporter is an independent module, you need manually active it.
Metrics exporter is an independent module, you need manually active it.
Right now, we provide the following exporters
1. gRPC exporter
@ -59,9 +59,9 @@ exporter:
## For target exporter service
### subscription implementation
Return the expected metric name list, all the names must match the OAL script definition. Return empty list, if you want
Return the expected metrics name list, all the names must match the OAL script definition. Return empty list, if you want
to export all metrics.
### export implementation
Stream service, all subscribed metrics will be sent to here, based on OAP core schedule. Also, if the OAP deployed as cluster,
then this method will be called concurrently. For metric value, you need follow `#type` to choose `#longValue` or `#doubleValue`.
then this method will be called concurrently. For metrics value, you need follow `#type` to choose `#longValue` or `#doubleValue`.

View File

@ -1026,7 +1026,7 @@
"steppedLine": false,
"targets": [
{
"expr": "sum(rate(indicator_aggregation {dimensionality=\"min\"} [1m])) by (level)",
"expr": "sum(rate(metrics_aggregation {dimensionality=\"min\"} [1m])) by (level)",
"format": "time_series",
"hide": false,
"intervalFactor": 1,

View File

@ -1110,7 +1110,7 @@
"steppedLine": false,
"targets": [
{
"expr": "sum(rate(indicator_aggregation {dimensionality=\"min\"} [1m])) by (level)",
"expr": "sum(rate(metrics_aggregation {dimensionality=\"min\"} [1m])) by (level)",
"format": "time_series",
"hide": false,
"intervalFactor": 1,

View File

@ -1,6 +1,6 @@
# Trace Sampling at server side
When we run a distributed tracing system, the trace bring us detailed info, but cost a lot at storage.
Open server side trace sampling mechanism, the metric of service, service instance, endpoint and topology are all accurate
Open server side trace sampling mechanism, the metrics of service, service instance, endpoint and topology are all accurate
as before, but only don't save all the traces into storage.
Of course, even you open sampling, the traces will be kept as consistent as possible. **Consistent** means, once the trace

View File

@ -6,7 +6,7 @@ Metric is separated in minute/hour/day/month dimensions in storage, different in
You have following settings for different types.
```yaml
# Set a timeout on metric data. After the timeout has expired, the metric data will automatically be deleted.
# Set a timeout on metrics data. After the timeout has expired, the metrics data will automatically be deleted.
recordDataTTL: ${SW_CORE_RECORD_DATA_TTL:90} # Unit is minute
minuteMetricsDataTTL: ${SW_CORE_MINUTE_METRIC_DATA_TTL:90} # Unit is minute
hourMetricsDataTTL: ${SW_CORE_HOUR_METRIC_DATA_TTL:36} # Unit is hour
@ -16,4 +16,4 @@ You have following settings for different types.
- `recordDataTTL` affects **Record** data.
- `minuteMetricsDataTTL`, `hourMetricsDataTTL`, `dayMetricsDataTTL` and `monthMetricsDataTTL` affects
metric data in minute/hour/day/month dimensions.
metrics data in minute/hour/day/month dimensions.

View File

@ -1,6 +1,6 @@
# Work with Istio
Instructions for transport Istio's metrics to skywalking oap server.
Instructions for transport Istio's metrics to SkyWalking OAP server.
## Prerequisites
@ -13,6 +13,6 @@ Follow the [deploying backend in kubernetes](../backend/backend-k8s.md) to insta
## Setup Istio to send metrics to oap
Follow instructions in the [setup Istio to send metric to oap](https://github.com/apache/skywalking-kubernetes#setup-istio-to-send-metric-to-oap)
Follow instructions in the [setup Istio to send metrics to oap](https://github.com/apache/skywalking-kubernetes#setup-istio-to-send-metrics-to-oap)
to setup Istio with oap.

View File

@ -19,7 +19,7 @@
package org.apache.skywalking.oap.server.exporter.provider;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.*;
import org.apache.skywalking.oap.server.core.cache.*;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
@ -32,7 +32,7 @@ public class MetricFormatter {
private ServiceInstanceInventoryCache serviceInstanceInventoryCache;
private EndpointInventoryCache endpointInventoryCache;
protected String getEntityName(IndicatorMetaInfo meta) {
protected String getEntityName(MetricsMetaInfo meta) {
int scope = meta.getScope();
if (DefaultScopeDefine.inServiceCatalog(scope)) {
return serviceInventoryCache.get(scope).getName();

View File

@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import lombok.*;
import org.apache.skywalking.apm.commons.datacarrier.DataCarrier;
import org.apache.skywalking.apm.commons.datacarrier.consumer.IConsumer;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.*;
import org.apache.skywalking.oap.server.core.exporter.MetricValuesExportService;
import org.apache.skywalking.oap.server.exporter.grpc.*;
import org.apache.skywalking.oap.server.exporter.provider.MetricFormatter;
@ -56,9 +56,9 @@ public class GRPCExporter extends MetricFormatter implements MetricValuesExportS
subscriptionSet = new HashSet<>();
}
@Override public void export(IndicatorMetaInfo meta, Indicator indicator) {
if (subscriptionSet.size() == 0 || subscriptionSet.contains(meta.getIndicatorName())) {
exportBuffer.produce(new ExportData(meta, indicator));
@Override public void export(MetricsMetaInfo meta, Metrics metrics) {
if (subscriptionSet.size() == 0 || subscriptionSet.contains(meta.getMetricsName())) {
exportBuffer.produce(new ExportData(meta, metrics));
}
}
@ -97,25 +97,25 @@ public class GRPCExporter extends MetricFormatter implements MetricValuesExportS
data.forEach(row -> {
ExportMetricValue.Builder builder = ExportMetricValue.newBuilder();
Indicator indicator = row.getIndicator();
if (indicator instanceof LongValueHolder) {
long value = ((LongValueHolder)indicator).getValue();
Metrics metrics = row.getMetrics();
if (metrics instanceof LongValueHolder) {
long value = ((LongValueHolder)metrics).getValue();
builder.setLongValue(value);
builder.setType(ValueType.LONG);
} else if (indicator instanceof IntValueHolder) {
long value = ((IntValueHolder)indicator).getValue();
} else if (metrics instanceof IntValueHolder) {
long value = ((IntValueHolder)metrics).getValue();
builder.setLongValue(value);
builder.setType(ValueType.LONG);
} else if (indicator instanceof DoubleValueHolder) {
double value = ((DoubleValueHolder)indicator).getValue();
} else if (metrics instanceof DoubleValueHolder) {
double value = ((DoubleValueHolder)metrics).getValue();
builder.setDoubleValue(value);
builder.setType(ValueType.DOUBLE);
} else {
return;
}
IndicatorMetaInfo meta = row.getMeta();
builder.setMetricName(meta.getIndicatorName());
MetricsMetaInfo meta = row.getMeta();
builder.setMetricName(meta.getMetricsName());
String entityName = getEntityName(meta);
if (entityName == null) {
return;
@ -123,7 +123,7 @@ public class GRPCExporter extends MetricFormatter implements MetricValuesExportS
builder.setEntityName(entityName);
builder.setEntityId(meta.getId());
builder.setTimeBucket(indicator.getTimeBucket());
builder.setTimeBucket(metrics.getTimeBucket());
streamObserver.onNext(builder.build());
exportNum.getAndIncrement();
@ -144,13 +144,13 @@ public class GRPCExporter extends MetricFormatter implements MetricValuesExportS
}
if (sleepTime > 2000L) {
logger.warn("Export {} metric(s) to {}:{}, wait {} milliseconds.",
logger.warn("Export {} metrics to {}:{}, wait {} milliseconds.",
exportNum.get(), setting.getTargetHost(), setting.getTargetPort(), sleepTime);
cycle = 2000L;
}
}
logger.debug("Exported {} metric(s) to {}:{} in {} milliseconds.",
logger.debug("Exported {} metrics to {}:{} in {} milliseconds.",
exportNum.get(), setting.getTargetHost(), setting.getTargetPort(), sleepTime);
}
@ -164,12 +164,12 @@ public class GRPCExporter extends MetricFormatter implements MetricValuesExportS
@Getter(AccessLevel.PRIVATE)
public class ExportData {
private IndicatorMetaInfo meta;
private Indicator indicator;
private MetricsMetaInfo meta;
private Metrics metrics;
public ExportData(IndicatorMetaInfo meta, Indicator indicator) {
public ExportData(MetricsMetaInfo meta, Metrics metrics) {
this.meta = meta;
this.indicator = indicator;
this.metrics = metrics;
}
}

View File

@ -19,7 +19,7 @@
package org.apache.skywalking.oap.server.exporter.provider.grpc;
import io.grpc.testing.GrpcServerRule;
import org.apache.skywalking.oap.server.core.analysis.indicator.IndicatorMetaInfo;
import org.apache.skywalking.oap.server.core.analysis.metrics.MetricsMetaInfo;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
import org.apache.skywalking.oap.server.exporter.grpc.MetricExportServiceGrpc;
import org.junit.Before;
@ -42,7 +42,7 @@ public class GRPCExporterTest {
public final GrpcServerRule grpcServerRule = new GrpcServerRule().directExecutor();
private MetricExportServiceGrpc.MetricExportServiceImplBase server = new MockMetricExportServiceImpl();
private IndicatorMetaInfo metaInfo = new IndicatorMetaInfo("mock-indicator", DefaultScopeDefine.ALL);
private MetricsMetaInfo metaInfo = new MetricsMetaInfo("mock-metrics", DefaultScopeDefine.ALL);
private MetricExportServiceGrpc.MetricExportServiceBlockingStub stub;
@ -58,7 +58,7 @@ public class GRPCExporterTest {
@Test
public void export() {
exporter.export(metaInfo, new MockIndicator());
exporter.export(metaInfo, new MockMetrics());
}
@Test
@ -94,10 +94,10 @@ public class GRPCExporterTest {
private List<GRPCExporter.ExportData> dataList() {
List<GRPCExporter.ExportData> dataList = new LinkedList<>();
dataList.add(exporter.new ExportData(metaInfo, new MockIndicator()));
dataList.add(exporter.new ExportData(metaInfo, new MockIntValueIndicator()));
dataList.add(exporter.new ExportData(metaInfo, new MockLongValueIndicator()));
dataList.add(exporter.new ExportData(metaInfo, new MockDoubleValueIndicator()));
dataList.add(exporter.new ExportData(metaInfo, new MockMetrics()));
dataList.add(exporter.new ExportData(metaInfo, new MockIntValueMetrics()));
dataList.add(exporter.new ExportData(metaInfo, new MockLongValueMetrics()));
dataList.add(exporter.new ExportData(metaInfo, new MockDoubleValueMetrics()));
return dataList;
}
}

View File

@ -18,12 +18,12 @@
package org.apache.skywalking.oap.server.exporter.provider.grpc;
import org.apache.skywalking.oap.server.core.analysis.indicator.DoubleValueHolder;
import org.apache.skywalking.oap.server.core.analysis.metrics.DoubleValueHolder;
/**
* Created by dengming, 2019.04.20
*/
public class MockDoubleValueIndicator extends MockIndicator implements DoubleValueHolder {
public class MockDoubleValueMetrics extends MockMetrics implements DoubleValueHolder {
@Override
public double getValue() {
return 2.3;

View File

@ -18,12 +18,12 @@
package org.apache.skywalking.oap.server.exporter.provider.grpc;
import org.apache.skywalking.oap.server.core.analysis.indicator.IntValueHolder;
import org.apache.skywalking.oap.server.core.analysis.metrics.IntValueHolder;
/**
* Created by dengming, 2019.04.20
*/
public class MockIntValueIndicator extends MockIndicator implements IntValueHolder {
public class MockIntValueMetrics extends MockMetrics implements IntValueHolder {
@Override
public int getValue() {
return 12;

View File

@ -18,12 +18,12 @@
package org.apache.skywalking.oap.server.exporter.provider.grpc;
import org.apache.skywalking.oap.server.core.analysis.indicator.LongValueHolder;
import org.apache.skywalking.oap.server.core.analysis.metrics.LongValueHolder;
/**
* Created by dengming, 2019.04.20
*/
public class MockLongValueIndicator extends MockIndicator implements LongValueHolder {
public class MockLongValueMetrics extends MockMetrics implements LongValueHolder {
@Override
public long getValue() {
return 1234567891234563312L;

View File

@ -18,21 +18,21 @@
package org.apache.skywalking.oap.server.exporter.provider.grpc;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
/**
* Created by dengming, 2019.04.20
*/
public class MockIndicator extends Indicator {
public class MockMetrics extends Metrics {
@Override
public String id() {
return "mock-indicator";
return "mock-metrics";
}
@Override
public void combine(Indicator indicator) {
public void combine(Metrics metrics) {
}
@ -42,17 +42,17 @@ public class MockIndicator extends Indicator {
}
@Override
public Indicator toHour() {
public Metrics toHour() {
return this;
}
@Override
public Indicator toDay() {
public Metrics toDay() {
return this;
}
@Override
public Indicator toMonth() {
public Metrics toMonth() {
return this;
}

View File

@ -41,7 +41,7 @@ public class Main {
"org", "apache", "skywalking", "oap", "server", "core", "analysis");
String metaFilePath = StringUtil.join(File.separatorChar, modulePath, "src", "main", "resources", "generator-scope-meta.yml");
Indicators.init();
MetricsHolder.init();
File scriptFile = new File(scriptFilePath);
if (!scriptFile.exists()) {

View File

@ -27,5 +27,5 @@ import org.apache.skywalking.oal.tool.parser.AnalysisResult;
public class DispatcherContext {
private String source;
private String packageName;
private List<AnalysisResult> indicators = new ArrayList<>();
private List<AnalysisResult> metrics = new ArrayList<>();
}

View File

@ -31,7 +31,7 @@ public class FileGenerator {
private AllDispatcherContext allDispatcherContext;
public FileGenerator(OALScripts oalScripts, String outputPath) {
this.results = oalScripts.getIndicatorStmts();
this.results = oalScripts.getMetricsStmts();
this.collection = oalScripts.getDisableCollection();
this.outputPath = outputPath;
configuration = new Configuration(new Version("2.3.28"));
@ -43,7 +43,7 @@ public class FileGenerator {
public void generate() throws IOException, TemplateException {
for (AnalysisResult result : results) {
generate(result, "Indicator.java", writer -> generateIndicatorImplementor(result, writer));
generate(result, "Metrics.java", writer -> generateMetricsImplementor(result, writer));
String scopeName = result.getSourceName();
File file = new File(outputPath, "generated/" + scopeName.toLowerCase() + "/" + scopeName + "Dispatcher.java");
@ -77,11 +77,11 @@ public class FileGenerator {
private String buildSubFolderName(AnalysisResult result, String suffix) {
return "generated/"
+ result.getSourceName().toLowerCase() + "/"
+ result.getMetricName() + suffix;
+ result.getMetricsName() + suffix;
}
void generateIndicatorImplementor(AnalysisResult result, Writer output) throws IOException, TemplateException {
configuration.getTemplate("IndicatorImplementor.ftl").process(result, output);
void generateMetricsImplementor(AnalysisResult result, Writer output) throws IOException, TemplateException {
configuration.getTemplate("MetricsImplementor.ftl").process(result, output);
}
void generateDispatcher(AnalysisResult result, Writer output) throws IOException, TemplateException {
@ -103,7 +103,7 @@ public class FileGenerator {
context.setPackageName(sourceName.toLowerCase());
allDispatcherContext.getAllContext().put(sourceName, context);
}
context.getIndicators().add(result);
context.getMetrics().add(result);
}
}

View File

@ -26,7 +26,7 @@ import lombok.*;
public class AnalysisResult {
private String varName;
private String metricName;
private String metricsName;
private String tableName;
@ -40,7 +40,7 @@ public class AnalysisResult {
private String aggregationFunctionName;
private String indicatorClassName;
private String metricsClassName;
private EntryMethod entryMethod;

View File

@ -22,19 +22,18 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.*;
import java.util.List;
import org.apache.skywalking.oal.tool.util.ClassMethodUtil;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
public class DeepAnalysis {
public AnalysisResult analysis(AnalysisResult result) {
// 1. Set sub package name by source.metric
// 1. Set sub package name by source.metrics
result.setPackageName(result.getSourceName().toLowerCase());
Class<? extends Indicator> indicatorClass = Indicators.find(result.getAggregationFunctionName());
String indicatorClassSimpleName = indicatorClass.getSimpleName();
Class<? extends org.apache.skywalking.oap.server.core.analysis.metrics.Metrics> metricsClass = MetricsHolder.find(result.getAggregationFunctionName());
String metricsClassSimpleName = metricsClass.getSimpleName();
result.setIndicatorClassName(indicatorClassSimpleName);
result.setMetricsClassName(metricsClassSimpleName);
// Optional for filter
List<ConditionExpression> expressions = result.getFilterExpressionsParserResult();
@ -77,8 +76,8 @@ public class DeepAnalysis {
}
}
// 3. Find Entrance method of this indicator
Class c = indicatorClass;
// 3. Find Entrance method of this metrics
Class c = metricsClass;
Method entranceMethod = null;
SearchEntrance:
while (!c.equals(Object.class)) {
@ -92,7 +91,7 @@ public class DeepAnalysis {
c = c.getSuperclass();
}
if (entranceMethod == null) {
throw new IllegalArgumentException("Can't find Entrance method in class: " + indicatorClass.getName());
throw new IllegalArgumentException("Can't find Entrance method in class: " + metricsClass.getName());
}
EntryMethod entryMethod = new EntryMethod();
result.setEntryMethod(entryMethod);
@ -138,8 +137,8 @@ public class DeepAnalysis {
}
}
// 5. Get all column declared in Indicator class.
c = indicatorClass;
// 5. Get all column declared in MetricsHolder class.
c = metricsClass;
while (!c.equals(Object.class)) {
for (Field field : c.getDeclaredFields()) {
Column column = field.getAnnotation(Column.class);

View File

@ -22,31 +22,30 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.util.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorFunction;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsFunction;
public class Indicators {
private static Map<String, Class<? extends Indicator>> REGISTER = new HashMap<>();
public class MetricsHolder {
private static Map<String, Class<? extends org.apache.skywalking.oap.server.core.analysis.metrics.Metrics>> REGISTER = new HashMap<>();
public static void init() throws IOException {
ClassPath classpath = ClassPath.from(Indicators.class.getClassLoader());
ClassPath classpath = ClassPath.from(MetricsHolder.class.getClassLoader());
ImmutableSet<ClassPath.ClassInfo> classes = classpath.getTopLevelClassesRecursive("org.apache.skywalking");
for (ClassPath.ClassInfo classInfo : classes) {
Class<?> aClass = classInfo.load();
if (aClass.isAnnotationPresent(IndicatorFunction.class)) {
IndicatorFunction indicatorFunction = aClass.getAnnotation(IndicatorFunction.class);
REGISTER.put(indicatorFunction.functionName(), (Class<? extends Indicator>)aClass);
if (aClass.isAnnotationPresent(MetricsFunction.class)) {
MetricsFunction metricsFunction = aClass.getAnnotation(MetricsFunction.class);
REGISTER.put(metricsFunction.functionName(), (Class<? extends org.apache.skywalking.oap.server.core.analysis.metrics.Metrics>)aClass);
}
}
}
public static Class<? extends Indicator> find(String functionName) {
public static Class<? extends org.apache.skywalking.oap.server.core.analysis.metrics.Metrics> find(String functionName) {
String func = functionName;
Class<? extends Indicator> indicatorClass = REGISTER.get(func);
if (indicatorClass == null) {
throw new IllegalArgumentException("Can't find indicator.");
Class<? extends org.apache.skywalking.oap.server.core.analysis.metrics.Metrics> metricsClass = REGISTER.get(func);
if (metricsClass == null) {
throw new IllegalArgumentException("Can't find metrics.");
}
return indicatorClass;
return metricsClass;
}
}

View File

@ -31,7 +31,7 @@ public class OALListener extends OALParserBaseListener {
private ConditionExpression conditionExpression;
public OALListener(OALScripts scripts) {
this.results = scripts.getIndicatorStmts();
this.results = scripts.getMetricsStmts();
this.collection = scripts.getDisableCollection();
}
@ -49,7 +49,7 @@ public class OALListener extends OALParserBaseListener {
@Override public void enterSource(OALParser.SourceContext ctx) {
current.setSourceName(ctx.getText());
current.setSourceScopeId(DefaultScopeDefine.valueOf(metricNameFormat(ctx.getText())));
current.setSourceScopeId(DefaultScopeDefine.valueOf(metricsNameFormat(ctx.getText())));
}
@Override
@ -62,7 +62,7 @@ public class OALListener extends OALParserBaseListener {
@Override public void exitVariable(OALParser.VariableContext ctx) {
current.setVarName(ctx.getText());
current.setMetricName(metricNameFormat(ctx.getText()));
current.setMetricsName(metricsNameFormat(ctx.getText()));
current.setTableName(ctx.getText().toLowerCase());
}
@ -143,7 +143,7 @@ public class OALListener extends OALParserBaseListener {
current.addFuncArg(ctx.getText());
}
private String metricNameFormat(String source) {
private String metricsNameFormat(String source) {
source = firstLetterUpper(source);
int idx;
while ((idx = source.indexOf("_")) > -1) {

View File

@ -23,11 +23,11 @@ import lombok.*;
@Getter
public class OALScripts {
private List<AnalysisResult> indicatorStmts;
private List<AnalysisResult> metricsStmts;
private DisableCollection disableCollection;
public OALScripts() {
indicatorStmts = new LinkedList<>();
metricsStmts = new LinkedList<>();
disableCollection = new DisableCollection();
}
}

View File

@ -19,11 +19,11 @@
package org.apache.skywalking.oap.server.core.analysis.generated.${packageName};
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
<#if (indicators?size>0)>
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
<#list indicators as indicator>
<#if indicator.filterExpressions??>
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
<#if (metrics?size>0)>
import org.apache.skywalking.oap.server.core.analysis.worker.MetricsProcess;
<#list metrics as metrics>
<#if metrics.filterExpressions??>
import org.apache.skywalking.oap.server.core.analysis.metrics.expression.*;
<#break>
</#if>
</#list>
@ -38,17 +38,17 @@ import org.apache.skywalking.oap.server.core.source.*;
public class ${source}Dispatcher implements SourceDispatcher<${source}> {
@Override public void dispatch(${source} source) {
<#list indicators as indicator>
do${indicator.metricName}(source);
<#list metrics as metrics>
do${metrics.metricsName}(source);
</#list>
}
<#list indicators as indicator>
private void do${indicator.metricName}(${source} source) {
${indicator.metricName}Indicator indicator = new ${indicator.metricName}Indicator();
<#list metrics as metrics>
private void do${metrics.metricsName}(${source} source) {
${metrics.metricsName}Metrics metrics = new ${metrics.metricsName}Metrics();
<#if indicator.filterExpressions??>
<#list indicator.filterExpressions as filterExpression>
<#if metrics.filterExpressions??>
<#list metrics.filterExpressions as filterExpression>
<#if filterExpression.expressionObject == "GreaterMatch" || filterExpression.expressionObject == "LessMatch" || filterExpression.expressionObject == "GreaterEqualMatch" || filterExpression.expressionObject == "LessEqualMatch">
if (!new ${filterExpression.expressionObject}().match(${filterExpression.left}, ${filterExpression.right})) {
return;
@ -61,12 +61,12 @@ public class ${source}Dispatcher implements SourceDispatcher<${source}> {
</#list>
</#if>
indicator.setTimeBucket(source.getTimeBucket());
<#list indicator.fieldsFromSource as field>
indicator.${field.fieldSetter}(source.${field.fieldGetter}());
metrics.setTimeBucket(source.getTimeBucket());
<#list metrics.fieldsFromSource as field>
metrics.${field.fieldSetter}(source.${field.fieldGetter}());
</#list>
indicator.${indicator.entryMethod.methodName}(<#list indicator.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, </#if></#list>);
IndicatorProcess.INSTANCE.in(indicator);
metrics.${metrics.entryMethod.methodName}(<#list metrics.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, </#if></#list>);
MetricsProcess.INSTANCE.in(metrics);
}
</#list>
}

View File

@ -28,8 +28,8 @@ import org.apache.skywalking.oap.server.core.Const;
<#break>
</#if>
</#list>
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.analysis.metrics.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
@ -40,10 +40,10 @@ import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@MetricsType
@StreamData
@StorageEntity(name = "${tableName}", builder = ${metricName}Indicator.Builder.class, sourceScopeId = ${sourceScopeId})
public class ${metricName}Indicator extends ${indicatorClassName} implements WithMetadata {
@StorageEntity(name = "${tableName}", builder = ${metricsName}Metrics.Builder.class, sourceScopeId = ${sourceScopeId})
public class ${metricsName}Metrics extends ${metricsClassName} implements WithMetadata {
<#list fieldsFromSource as sourceField>
@Setter @Getter @Column(columnName = "${sourceField.columnName}") <#if sourceField.isID()>@IDColumn</#if> private ${sourceField.typeName} ${sourceField.fieldName};
@ -100,19 +100,19 @@ public class ${metricName}Indicator extends ${indicatorClassName} implements Wit
if (getClass() != obj.getClass())
return false;
${metricName}Indicator indicator = (${metricName}Indicator)obj;
${metricsName}Metrics metrics = (${metricsName}Metrics)obj;
<#list fieldsFromSource as sourceField>
<#if sourceField.isID()>
<#if sourceField.getTypeName() == "java.lang.String">
if (!${sourceField.fieldName}.equals(indicator.${sourceField.fieldName}))
if (!${sourceField.fieldName}.equals(metrics.${sourceField.fieldName}))
<#else>
if (${sourceField.fieldName} != indicator.${sourceField.fieldName})
if (${sourceField.fieldName} != metrics.${sourceField.fieldName})
</#if>
return false;
</#if>
</#list>
if (getTimeBucket() != indicator.getTimeBucket())
if (getTimeBucket() != metrics.getTimeBucket())
return false;
return true;
@ -168,97 +168,97 @@ public class ${metricName}Indicator extends ${indicatorClassName} implements Wit
}
@Override public IndicatorMetaInfo getMeta() {
return new IndicatorMetaInfo("${varName}", ${sourceScopeId}<#if (fieldsFromSource?size>0) ><#list fieldsFromSource as field><#if field.isID()>, ${field.fieldName}</#if></#list></#if>);
@Override public MetricsMetaInfo getMeta() {
return new MetricsMetaInfo("${varName}", ${sourceScopeId}<#if (fieldsFromSource?size>0) ><#list fieldsFromSource as field><#if field.isID()>, ${field.fieldName}</#if></#list></#if>);
}
@Override
public Indicator toHour() {
${metricName}Indicator indicator = new ${metricName}Indicator();
public Metrics toHour() {
${metricsName}Metrics metrics = new ${metricsName}Metrics();
<#list fieldsFromSource as field>
<#if field.columnName == "time_bucket">
indicator.setTimeBucket(toTimeBucketInHour());
metrics.setTimeBucket(toTimeBucketInHour());
<#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(this.${field.fieldGetter}());
metrics.${field.fieldSetter}(this.${field.fieldGetter}());
<#else>
${field.typeName} newValue = new ${field.typeName}();
newValue.copyFrom(this.${field.fieldGetter}());
indicator.${field.fieldSetter}(newValue);
metrics.${field.fieldSetter}(newValue);
</#if>
</#list>
<#list persistentFields as field>
<#if field.columnName == "time_bucket">
indicator.setTimeBucket(toTimeBucketInHour());
metrics.setTimeBucket(toTimeBucketInHour());
<#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(this.${field.fieldGetter}());
metrics.${field.fieldSetter}(this.${field.fieldGetter}());
<#else>
${field.typeName} newValue = new ${field.typeName}();
newValue.copyFrom(this.${field.fieldGetter}());
indicator.${field.fieldSetter}(newValue);
metrics.${field.fieldSetter}(newValue);
</#if>
</#list>
return indicator;
return metrics;
}
@Override
public Indicator toDay() {
${metricName}Indicator indicator = new ${metricName}Indicator();
public Metrics toDay() {
${metricsName}Metrics metrics = new ${metricsName}Metrics();
<#list fieldsFromSource as field>
<#if field.columnName == "time_bucket">
indicator.setTimeBucket(toTimeBucketInDay());
metrics.setTimeBucket(toTimeBucketInDay());
<#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(this.${field.fieldGetter}());
metrics.${field.fieldSetter}(this.${field.fieldGetter}());
<#else>
${field.typeName} newValue = new ${field.typeName}();
newValue.copyFrom(this.${field.fieldGetter}());
indicator.${field.fieldSetter}(newValue);
metrics.${field.fieldSetter}(newValue);
</#if>
</#list>
<#list persistentFields as field>
<#if field.columnName == "time_bucket">
indicator.setTimeBucket(toTimeBucketInDay());
metrics.setTimeBucket(toTimeBucketInDay());
<#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(this.${field.fieldGetter}());
metrics.${field.fieldSetter}(this.${field.fieldGetter}());
<#else>
${field.typeName} newValue = new ${field.typeName}();
newValue.copyFrom(this.${field.fieldGetter}());
indicator.${field.fieldSetter}(newValue);
metrics.${field.fieldSetter}(newValue);
</#if>
</#list>
return indicator;
return metrics;
}
@Override
public Indicator toMonth() {
${metricName}Indicator indicator = new ${metricName}Indicator();
public Metrics toMonth() {
${metricsName}Metrics metrics = new ${metricsName}Metrics();
<#list fieldsFromSource as field>
<#if field.columnName == "time_bucket">
indicator.setTimeBucket(toTimeBucketInMonth());
metrics.setTimeBucket(toTimeBucketInMonth());
<#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(this.${field.fieldGetter}());
metrics.${field.fieldSetter}(this.${field.fieldGetter}());
<#else>
${field.typeName} newValue = new ${field.typeName}();
newValue.copyFrom(this.${field.fieldGetter}());
indicator.${field.fieldSetter}(newValue);
metrics.${field.fieldSetter}(newValue);
</#if>
</#list>
<#list persistentFields as field>
<#if field.columnName == "time_bucket">
indicator.setTimeBucket(toTimeBucketInMonth());
metrics.setTimeBucket(toTimeBucketInMonth());
<#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(this.${field.fieldGetter}());
metrics.${field.fieldSetter}(this.${field.fieldGetter}());
<#else>
${field.typeName} newValue = new ${field.typeName}();
newValue.copyFrom(this.${field.fieldGetter}());
indicator.${field.fieldSetter}(newValue);
metrics.${field.fieldSetter}(newValue);
</#if>
</#list>
return indicator;
return metrics;
}
public static class Builder implements StorageBuilder<${metricName}Indicator> {
public static class Builder implements StorageBuilder<${metricsName}Metrics> {
@Override public Map<String, Object> data2Map(${metricName}Indicator storageData) {
@Override public Map<String, Object> data2Map(${metricsName}Metrics storageData) {
Map<String, Object> map = new HashMap<>();
<#list fieldsFromSource as field>
map.put("${field.columnName}", storageData.${field.fieldGetter}());
@ -269,27 +269,27 @@ public class ${metricName}Indicator extends ${indicatorClassName} implements Wit
return map;
}
@Override public ${metricName}Indicator map2Data(Map<String, Object> dbMap) {
${metricName}Indicator indicator = new ${metricName}Indicator();
@Override public ${metricsName}Metrics map2Data(Map<String, Object> dbMap) {
${metricsName}Metrics metrics = new ${metricsName}Metrics();
<#list fieldsFromSource as field>
<#if field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(((Number)dbMap.get("${field.columnName}")).${field.typeName}Value());
metrics.${field.fieldSetter}(((Number)dbMap.get("${field.columnName}")).${field.typeName}Value());
<#elseif field.typeName == "java.lang.String">
indicator.${field.fieldSetter}((String)dbMap.get("${field.columnName}"));
metrics.${field.fieldSetter}((String)dbMap.get("${field.columnName}"));
<#else>
indicator.${field.fieldSetter}(new ${field.typeName}((String)dbMap.get("${field.columnName}")));
metrics.${field.fieldSetter}(new ${field.typeName}((String)dbMap.get("${field.columnName}")));
</#if>
</#list>
<#list persistentFields as field>
<#if field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(((Number)dbMap.get("${field.columnName}")).${field.typeName}Value());
metrics.${field.fieldSetter}(((Number)dbMap.get("${field.columnName}")).${field.typeName}Value());
<#elseif field.typeName == "java.lang.String">
indicator.${field.fieldSetter}((String)dbMap.get("${field.columnName}"));
metrics.${field.fieldSetter}((String)dbMap.get("${field.columnName}"));
<#else>
indicator.${field.fieldSetter}(new ${field.typeName}((String)dbMap.get("${field.columnName}")));
metrics.${field.fieldSetter}(new ${field.typeName}((String)dbMap.get("${field.columnName}")));
</#if>
</#list>
return indicator;
return metrics;
}
}
}

View File

@ -20,7 +20,7 @@ package org.apache.skywalking.oal.tool.output;
import freemarker.template.TemplateException;
import java.io.*;
import java.util.*;
import java.util.LinkedList;
import org.apache.skywalking.oal.tool.meta.*;
import org.apache.skywalking.oal.tool.parser.*;
import org.junit.*;
@ -36,15 +36,15 @@ public class FileGeneratorTest {
private AnalysisResult buildResult() {
AnalysisResult result = new AnalysisResult();
result.setVarName("generate_indicator");
result.setVarName("generate_metrics");
result.setSourceName("Service");
result.setSourceScopeId(1);
result.setPackageName("service.serviceavg");
result.setTableName("service_avg");
result.setSourceAttribute("latency");
result.setMetricName("ServiceAvg");
result.setMetricsName("ServiceAvg");
result.setAggregationFunctionName("avg");
result.setIndicatorClassName("LongAvgIndicator");
result.setMetricsClassName("LongAvgMetrics");
FilterExpression equalExpression = new FilterExpression();
equalExpression.setExpressionObject("EqualMatch");
@ -76,18 +76,18 @@ public class FileGeneratorTest {
}
@Test
public void testGenerateIndicatorImplementor() throws IOException, TemplateException {
public void testGenerateMetricsImplementor() throws IOException, TemplateException {
AnalysisResult result = buildResult();
OALScripts oalScripts = new OALScripts();
oalScripts.getIndicatorStmts().add(result);
oalScripts.getMetricsStmts().add(result);
FileGenerator fileGenerator = new FileGenerator(oalScripts, ".");
StringWriter writer = new StringWriter();
fileGenerator.generateIndicatorImplementor(result, writer);
Assert.assertEquals(readExpectedFile("IndicatorImplementorExpected.java"), writer.toString());
fileGenerator.generateMetricsImplementor(result, writer);
Assert.assertEquals(readExpectedFile("MetricsImplementorExpected.java"), writer.toString());
// fileGenerator.generateIndicatorImplementor(result, new OutputStreamWriter(System.out));
// fileGenerator.generateMetricsImplementor(result, new OutputStreamWriter(System.out));
}
@Test
@ -95,7 +95,7 @@ public class FileGeneratorTest {
AnalysisResult result = buildResult();
OALScripts oalScripts = new OALScripts();
oalScripts.getIndicatorStmts().add(result);
oalScripts.getMetricsStmts().add(result);
FileGenerator fileGenerator = new FileGenerator(oalScripts, ".");
StringWriter writer = new StringWriter();

View File

@ -30,7 +30,7 @@ public class DeepAnalysisTest {
InputStream stream = MetaReaderTest.class.getResourceAsStream("/scope-meta.yml");
MetaSettings metaSettings = reader.read(stream);
SourceColumnsFactory.setSettings(metaSettings);
Indicators.init();
MetricsHolder.init();
}
@Test
@ -39,7 +39,7 @@ public class DeepAnalysisTest {
result.setSourceName("Service");
result.setPackageName("service.serviceavg");
result.setSourceAttribute("latency");
result.setMetricName("ServiceAvg");
result.setMetricsName("ServiceAvg");
result.setAggregationFunctionName("longAvg");
DeepAnalysis analysis = new DeepAnalysis();
@ -63,7 +63,7 @@ public class DeepAnalysisTest {
result.setSourceName("Endpoint");
result.setPackageName("endpoint.endpointavg");
result.setSourceAttribute("latency");
result.setMetricName("EndpointAvg");
result.setMetricsName("EndpointAvg");
result.setAggregationFunctionName("longAvg");
DeepAnalysis analysis = new DeepAnalysis();
@ -87,7 +87,7 @@ public class DeepAnalysisTest {
result.setSourceName("Endpoint");
result.setPackageName("endpoint.endpointavg");
result.setSourceAttribute("latency");
result.setMetricName("EndpointAvg");
result.setMetricsName("EndpointAvg");
result.setAggregationFunctionName("longAvg");
ConditionExpression expression = new ConditionExpression();
expression.setExpressionType("stringMatch");

View File

@ -32,7 +32,7 @@ public class ScriptParserTest {
InputStream stream = MetaReaderTest.class.getResourceAsStream("/scope-meta.yml");
MetaSettings metaSettings = reader.read(stream);
SourceColumnsFactory.setSettings(metaSettings);
Indicators.init();
MetricsHolder.init();
AnnotationScan scopeScan = new AnnotationScan();
scopeScan.registerListener(new DefaultScopeDefine.Listener());
@ -50,18 +50,18 @@ public class ScriptParserTest {
"Endpoint_avg = from(Endpoint.latency).longAvg(); //comment test" + "\n" +
"Service_avg = from(Service.latency).longAvg()"
);
List<AnalysisResult> results = parser.parse().getIndicatorStmts();
List<AnalysisResult> results = parser.parse().getMetricsStmts();
Assert.assertEquals(2, results.size());
AnalysisResult endpointAvg = results.get(0);
Assert.assertEquals("EndpointAvg", endpointAvg.getMetricName());
Assert.assertEquals("EndpointAvg", endpointAvg.getMetricsName());
Assert.assertEquals("Endpoint", endpointAvg.getSourceName());
Assert.assertEquals("latency", endpointAvg.getSourceAttribute());
Assert.assertEquals("longAvg", endpointAvg.getAggregationFunctionName());
AnalysisResult serviceAvg = results.get(1);
Assert.assertEquals("ServiceAvg", serviceAvg.getMetricName());
Assert.assertEquals("ServiceAvg", serviceAvg.getMetricsName());
Assert.assertEquals("Service", serviceAvg.getSourceName());
Assert.assertEquals("latency", serviceAvg.getSourceAttribute());
Assert.assertEquals("longAvg", serviceAvg.getAggregationFunctionName());
@ -72,10 +72,10 @@ public class ScriptParserTest {
ScriptParser parser = ScriptParser.createFromScriptText(
"Endpoint_percent = from(Endpoint.*).percent(status == true);"
);
List<AnalysisResult> results = parser.parse().getIndicatorStmts();
List<AnalysisResult> results = parser.parse().getMetricsStmts();
AnalysisResult endpointPercent = results.get(0);
Assert.assertEquals("EndpointPercent", endpointPercent.getMetricName());
Assert.assertEquals("EndpointPercent", endpointPercent.getMetricsName());
Assert.assertEquals("Endpoint", endpointPercent.getSourceName());
Assert.assertEquals("*", endpointPercent.getSourceAttribute());
Assert.assertEquals("percent", endpointPercent.getAggregationFunctionName());
@ -91,10 +91,10 @@ public class ScriptParserTest {
ScriptParser parser = ScriptParser.createFromScriptText(
"Endpoint_percent = from(Endpoint.*).filter(status == true).filter(name == \"/product/abc\").longAvg();"
);
List<AnalysisResult> results = parser.parse().getIndicatorStmts();
List<AnalysisResult> results = parser.parse().getMetricsStmts();
AnalysisResult endpointPercent = results.get(0);
Assert.assertEquals("EndpointPercent", endpointPercent.getMetricName());
Assert.assertEquals("EndpointPercent", endpointPercent.getMetricsName());
Assert.assertEquals("Endpoint", endpointPercent.getSourceName());
Assert.assertEquals("*", endpointPercent.getSourceAttribute());
Assert.assertEquals("longAvg", endpointPercent.getAggregationFunctionName());
@ -121,10 +121,10 @@ public class ScriptParserTest {
"service_response_s3_summary = from(Service.latency).filter(latency >= 3000).sum();" + "\n" +
"service_response_s4_summary = from(Service.latency).filter(latency <= 4000).sum();"
);
List<AnalysisResult> results = parser.parse().getIndicatorStmts();
List<AnalysisResult> results = parser.parse().getMetricsStmts();
AnalysisResult responseSummary = results.get(0);
Assert.assertEquals("ServiceResponseS1Summary", responseSummary.getMetricName());
Assert.assertEquals("ServiceResponseS1Summary", responseSummary.getMetricsName());
Assert.assertEquals("Service", responseSummary.getSourceName());
Assert.assertEquals("latency", responseSummary.getSourceAttribute());
Assert.assertEquals("sum", responseSummary.getAggregationFunctionName());

View File

@ -21,8 +21,8 @@ package org.apache.skywalking.oap.server.core.analysis.generated.service.service
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.analysis.metrics.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
@ -33,10 +33,10 @@ import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@MetricsType
@StreamData
@StorageEntity(name = "service_avg", builder = ServiceAvgIndicator.Builder.class, sourceScopeId = 1)
public class ServiceAvgIndicator extends LongAvgIndicator implements WithMetadata {
@StorageEntity(name = "service_avg", builder = ServiceAvgMetrics.Builder.class, sourceScopeId = 1)
public class ServiceAvgMetrics extends LongAvgMetrics implements WithMetadata {
@Setter @Getter @Column(columnName = "entity_id") @IDColumn private java.lang.String entityId;
@ -67,11 +67,11 @@ public class ServiceAvgIndicator extends LongAvgIndicator implements WithMetadat
if (getClass() != obj.getClass())
return false;
ServiceAvgIndicator indicator = (ServiceAvgIndicator)obj;
if (!entityId.equals(indicator.entityId))
ServiceAvgMetrics metrics = (ServiceAvgMetrics)obj;
if (!entityId.equals(metrics.entityId))
return false;
if (getTimeBucket() != indicator.getTimeBucket())
if (getTimeBucket() != metrics.getTimeBucket())
return false;
return true;
@ -106,49 +106,49 @@ public class ServiceAvgIndicator extends LongAvgIndicator implements WithMetadat
}
@Override public IndicatorMetaInfo getMeta() {
return new IndicatorMetaInfo("generate_indicator", 1, entityId);
@Override public MetricsMetaInfo getMeta() {
return new MetricsMetaInfo("generate_metrics", 1, entityId);
}
@Override
public Indicator toHour() {
ServiceAvgIndicator indicator = new ServiceAvgIndicator();
indicator.setEntityId(this.getEntityId());
indicator.setSummation(this.getSummation());
indicator.setCount(this.getCount());
indicator.setValue(this.getValue());
indicator.setTimeBucket(toTimeBucketInHour());
indicator.setStringField(this.getStringField());
return indicator;
public Metrics toHour() {
ServiceAvgMetrics metrics = new ServiceAvgMetrics();
metrics.setEntityId(this.getEntityId());
metrics.setSummation(this.getSummation());
metrics.setCount(this.getCount());
metrics.setValue(this.getValue());
metrics.setTimeBucket(toTimeBucketInHour());
metrics.setStringField(this.getStringField());
return metrics;
}
@Override
public Indicator toDay() {
ServiceAvgIndicator indicator = new ServiceAvgIndicator();
indicator.setEntityId(this.getEntityId());
indicator.setSummation(this.getSummation());
indicator.setCount(this.getCount());
indicator.setValue(this.getValue());
indicator.setTimeBucket(toTimeBucketInDay());
indicator.setStringField(this.getStringField());
return indicator;
public Metrics toDay() {
ServiceAvgMetrics metrics = new ServiceAvgMetrics();
metrics.setEntityId(this.getEntityId());
metrics.setSummation(this.getSummation());
metrics.setCount(this.getCount());
metrics.setValue(this.getValue());
metrics.setTimeBucket(toTimeBucketInDay());
metrics.setStringField(this.getStringField());
return metrics;
}
@Override
public Indicator toMonth() {
ServiceAvgIndicator indicator = new ServiceAvgIndicator();
indicator.setEntityId(this.getEntityId());
indicator.setSummation(this.getSummation());
indicator.setCount(this.getCount());
indicator.setValue(this.getValue());
indicator.setTimeBucket(toTimeBucketInMonth());
indicator.setStringField(this.getStringField());
return indicator;
public Metrics toMonth() {
ServiceAvgMetrics metrics = new ServiceAvgMetrics();
metrics.setEntityId(this.getEntityId());
metrics.setSummation(this.getSummation());
metrics.setCount(this.getCount());
metrics.setValue(this.getValue());
metrics.setTimeBucket(toTimeBucketInMonth());
metrics.setStringField(this.getStringField());
return metrics;
}
public static class Builder implements StorageBuilder<ServiceAvgIndicator> {
public static class Builder implements StorageBuilder<ServiceAvgMetrics> {
@Override public Map<String, Object> data2Map(ServiceAvgIndicator storageData) {
@Override public Map<String, Object> data2Map(ServiceAvgMetrics storageData) {
Map<String, Object> map = new HashMap<>();
map.put("entity_id", storageData.getEntityId());
map.put("summation", storageData.getSummation());
@ -159,15 +159,15 @@ public class ServiceAvgIndicator extends LongAvgIndicator implements WithMetadat
return map;
}
@Override public ServiceAvgIndicator map2Data(Map<String, Object> dbMap) {
ServiceAvgIndicator indicator = new ServiceAvgIndicator();
indicator.setEntityId((String)dbMap.get("entity_id"));
indicator.setSummation(((Number)dbMap.get("summation")).longValue());
indicator.setCount(((Number)dbMap.get("count")).intValue());
indicator.setValue(((Number)dbMap.get("value")).longValue());
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
indicator.setStringField((String)dbMap.get("string_field"));
return indicator;
@Override public ServiceAvgMetrics map2Data(Map<String, Object> dbMap) {
ServiceAvgMetrics metrics = new ServiceAvgMetrics();
metrics.setEntityId((String)dbMap.get("entity_id"));
metrics.setSummation(((Number)dbMap.get("summation")).longValue());
metrics.setCount(((Number)dbMap.get("count")).intValue());
metrics.setValue(((Number)dbMap.get("value")).longValue());
metrics.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
metrics.setStringField((String)dbMap.get("string_field"));
return metrics;
}
}
}
}

View File

@ -19,8 +19,8 @@
package org.apache.skywalking.oap.server.core.analysis.generated.service;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
import org.apache.skywalking.oap.server.core.analysis.worker.MetricsProcess;
import org.apache.skywalking.oap.server.core.analysis.metrics.expression.*;
import org.apache.skywalking.oap.server.core.source.*;
/**
@ -35,7 +35,7 @@ public class ServiceDispatcher implements SourceDispatcher<Service> {
}
private void doServiceAvg(Service source) {
ServiceAvgIndicator indicator = new ServiceAvgIndicator();
ServiceAvgMetrics metrics = new ServiceAvgMetrics();
if (!new EqualMatch().setLeft(source.getName()).setRight("/service/prod/save").match()) {
return;
@ -44,9 +44,9 @@ public class ServiceDispatcher implements SourceDispatcher<Service> {
return;
}
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.combine(source.getLatency(), 1);
IndicatorProcess.INSTANCE.in(indicator);
metrics.setTimeBucket(source.getTimeBucket());
metrics.setEntityId(source.getEntityId());
metrics.combine(source.getLatency(), 1);
MetricsProcess.INSTANCE.in(metrics);
}
}

View File

@ -16,7 +16,7 @@
*
*/
// All scope metric
// All scope metrics
all_p99 = from(All.latency).p99(10);
all_p95 = from(All.latency).p95(10);
all_p90 = from(All.latency).p90(10);
@ -24,7 +24,7 @@ all_p75 = from(All.latency).p75(10);
all_p50 = from(All.latency).p50(10);
all_heatmap = from(All.latency).thermodynamic(100, 20);
// Service scope metric
// Service scope metrics
service_resp_time = from(Service.latency).longAvg();
service_sla = from(Service.*).percent(status == true);
service_cpm = from(Service.*).cpm();
@ -34,7 +34,7 @@ service_p90 = from(Service.latency).p90(10);
service_p75 = from(Service.latency).p75(10);
service_p50 = from(Service.latency).p50(10);
// Service relation scope metric for topology
// Service relation scope metrics for topology
service_relation_client_cpm = from(ServiceRelation.*).filter(detectPoint == DetectPoint.CLIENT).cpm();
service_relation_server_cpm = from(ServiceRelation.*).filter(detectPoint == DetectPoint.SERVER).cpm();
service_relation_client_call_sla = from(ServiceRelation.*).filter(detectPoint == DetectPoint.CLIENT).percent(status == true);
@ -42,12 +42,12 @@ service_relation_server_call_sla = from(ServiceRelation.*).filter(detectPoint ==
service_relation_client_resp_time = from(ServiceRelation.latency).filter(detectPoint == DetectPoint.CLIENT).longAvg();
service_relation_server_resp_time = from(ServiceRelation.latency).filter(detectPoint == DetectPoint.SERVER).longAvg();
// Service Instance Scope metric
// Service Instance Scope metrics
service_instance_sla = from(ServiceInstance.*).percent(status == true);
service_instance_resp_time= from(ServiceInstance.latency).longAvg();
service_instance_cpm = from(ServiceInstance.*).cpm();
// Endpoint scope metric
// Endpoint scope metrics
endpoint_cpm = from(Endpoint.*).cpm();
endpoint_avg = from(Endpoint.latency).longAvg();
endpoint_sla = from(Endpoint.*).percent(status == true);
@ -57,11 +57,11 @@ endpoint_p90 = from(Endpoint.latency).p90(10);
endpoint_p75 = from(Endpoint.latency).p75(10);
endpoint_p50 = from(Endpoint.latency).p50(10);
// Endpoint relation scope metric
// Endpoint relation scope metrics
endpoint_relation_cpm = from(EndpointRelation.*).filter(detectPoint == DetectPoint.SERVER).cpm();
endpoint_relation_resp_time = from(EndpointRelation.rpcLatency).filter(detectPoint == DetectPoint.SERVER).longAvg();
// JVM instance metric
// JVM instance metrics
instance_jvm_cpu = from(ServiceInstanceJVMCPU.usePercent).doubleAvg();
instance_jvm_memory_heap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == true).longAvg();
instance_jvm_memory_noheap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == false).longAvg();

View File

@ -16,7 +16,7 @@
*
*/
// All scope metric
// All scope metrics
all_p99 = from(All.latency).p99(10);
all_p95 = from(All.latency).p95(10);
all_p90 = from(All.latency).p90(10);
@ -24,7 +24,7 @@ all_p75 = from(All.latency).p75(10);
all_p50 = from(All.latency).p50(10);
all_heatmap = from(All.latency).thermodynamic(100, 20);
// Service scope metric
// Service scope metrics
service_resp_time = from(Service.latency).longAvg();
service_sla = from(Service.*).percent(status == true);
service_cpm = from(Service.*).cpm();
@ -34,7 +34,7 @@ service_p90 = from(Service.latency).p90(10);
service_p75 = from(Service.latency).p75(10);
service_p50 = from(Service.latency).p50(10);
// Service relation scope metric for topology
// Service relation scope metrics for topology
service_relation_client_cpm = from(ServiceRelation.*).filter(detectPoint == DetectPoint.CLIENT).cpm();
service_relation_server_cpm = from(ServiceRelation.*).filter(detectPoint == DetectPoint.SERVER).cpm();
service_relation_client_call_sla = from(ServiceRelation.*).filter(detectPoint == DetectPoint.CLIENT).percent(status == true);
@ -42,12 +42,12 @@ service_relation_server_call_sla = from(ServiceRelation.*).filter(detectPoint ==
service_relation_client_resp_time = from(ServiceRelation.latency).filter(detectPoint == DetectPoint.CLIENT).longAvg();
service_relation_server_resp_time = from(ServiceRelation.latency).filter(detectPoint == DetectPoint.SERVER).longAvg();
// Service Instance Scope metric
// Service Instance Scope metrics
service_instance_sla = from(ServiceInstance.*).percent(status == true);
service_instance_resp_time= from(ServiceInstance.latency).longAvg();
service_instance_cpm = from(ServiceInstance.*).cpm();
// Endpoint scope metric
// Endpoint scope metrics
endpoint_cpm = from(Endpoint.*).cpm();
endpoint_avg = from(Endpoint.latency).longAvg();
endpoint_sla = from(Endpoint.*).percent(status == true);
@ -57,11 +57,11 @@ endpoint_p90 = from(Endpoint.latency).p90(10);
endpoint_p75 = from(Endpoint.latency).p75(10);
endpoint_p50 = from(Endpoint.latency).p50(10);
// Endpoint relation scope metric
// Endpoint relation scope metrics
endpoint_relation_cpm = from(EndpointRelation.*).filter(detectPoint == DetectPoint.SERVER).cpm();
endpoint_relation_resp_time = from(EndpointRelation.rpcLatency).filter(detectPoint == DetectPoint.SERVER).longAvg();
// JVM instance metric
// JVM instance metrics
instance_jvm_cpu = from(ServiceInstanceJVMCPU.usePercent).doubleAvg();
instance_jvm_memory_heap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == true).longAvg();
instance_jvm_memory_noheap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == false).longAvg();
@ -81,7 +81,7 @@ database_access_p90 = from(DatabaseAccess.latency).p90(10);
database_access_p75 = from(DatabaseAccess.latency).p75(10);
database_access_p50 = from(DatabaseAccess.latency).p50(10);
// CLR instance metric
// CLR instance metrics
instance_clr_cpu = from(ServiceInstanceCLRCPU.usePercent).doubleAvg();
instance_clr_gen0_collect_count = from(ServiceInstanceCLRGC.gen0CollectCount).sum();
instance_clr_gen1_collect_count = from(ServiceInstanceCLRGC.gen1CollectCount).sum();
@ -92,7 +92,7 @@ instance_clr_available_worker_threads = from(ServiceInstanceCLRThread.availableW
instance_clr_max_completion_port_threads = from(ServiceInstanceCLRThread.maxCompletionPortThreads).max();
instance_clr_max_worker_threads = from(ServiceInstanceCLRThread.maxWorkerThreads).max();
// Envoy instance metric
// Envoy instance metrics
envoy_heap_memory_max_used = from(EnvoyInstanceMetric.value).filter(metricName == "server.memory_heap_size").maxDouble();
envoy_total_connections_used = from(EnvoyInstanceMetric.value).filter(metricName == "server.total_connections").maxDouble();
envoy_parent_connections_used = from(EnvoyInstanceMetric.value).filter(metricName == "server.parent_connections").maxDouble();

View File

@ -18,22 +18,14 @@
package org.apache.skywalking.oap.server.core.alarm.provider;
import org.apache.skywalking.oap.server.core.alarm.AlarmCallback;
import org.apache.skywalking.oap.server.core.alarm.AlarmMessage;
import org.joda.time.LocalDateTime;
import org.joda.time.Minutes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.*;
import java.util.concurrent.*;
import org.apache.skywalking.oap.server.core.alarm.*;
import org.joda.time.*;
import org.slf4j.*;
/**
* Alarm core includes metric values in certain time windows based on alarm settings. By using its internal timer
* Alarm core includes metrics values in certain time windows based on alarm settings. By using its internal timer
* trigger and the alarm rules to decides whether send the alarm to database and webhook(s)
*
* @author wusheng
@ -49,16 +41,16 @@ public class AlarmCore {
rules.getRules().forEach(rule -> {
RunningRule runningRule = new RunningRule(rule);
String indicatorName = rule.getIndicatorName();
String metricsName = rule.getMetricsName();
List<RunningRule> runningRules = runningContext.computeIfAbsent(indicatorName, key -> new ArrayList<>());
List<RunningRule> runningRules = runningContext.computeIfAbsent(metricsName, key -> new ArrayList<>());
runningRules.add(runningRule);
});
}
public List<RunningRule> findRunningRule(String indicatorName) {
return runningContext.get(indicatorName);
public List<RunningRule> findRunningRule(String metricsName) {
return runningContext.get(metricsName);
}
public void start(List<AlarmCallback> allCallbacks) {
@ -69,7 +61,7 @@ public class AlarmCore {
List<AlarmMessage> alarmMessageList = new ArrayList<>(30);
LocalDateTime checkTime = LocalDateTime.now();
int minutes = Minutes.minutesBetween(lastExecuteTime, checkTime).getMinutes();
boolean[] hasExecute = new boolean[]{false};
boolean[] hasExecute = new boolean[] {false};
runningContext.values().forEach(ruleList -> ruleList.forEach(runningRule -> {
if (minutes > 0) {
runningRule.moveTo(checkTime);

View File

@ -50,7 +50,7 @@ public class AlarmModuleProvider extends ModuleProvider {
Rules rules = reader.readRules();
notifyHandler = new NotifyHandler(rules);
notifyHandler.init(new AlarmStandardPersistence());
this.registerServiceImplementation(IndicatorNotify.class, notifyHandler);
this.registerServiceImplementation(MetricsNotify.class, notifyHandler);
}
@Override public void start() throws ServiceNotProvidedException, ModuleStartException {

View File

@ -31,7 +31,7 @@ import lombok.Setter;
public class AlarmRule {
private String alarmRuleName;
private String indicatorName;
private String metricsName;
private ArrayList includeNames;
private String threshold;
private String op;

View File

@ -18,6 +18,6 @@
package org.apache.skywalking.oap.server.core.alarm.provider;
public enum IndicatorValueType {
public enum MetricsValueType {
LONG, INT, DOUBLE
}

View File

@ -21,13 +21,13 @@ package org.apache.skywalking.oap.server.core.alarm.provider;
import java.util.*;
import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.alarm.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.*;
import org.apache.skywalking.oap.server.core.cache.*;
import org.apache.skywalking.oap.server.core.register.*;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
public class NotifyHandler implements IndicatorNotify {
public class NotifyHandler implements MetricsNotify {
private ServiceInventoryCache serviceInventoryCache;
private ServiceInstanceInventoryCache serviceInstanceInventoryCache;
private EndpointInventoryCache endpointInventoryCache;
@ -40,9 +40,9 @@ public class NotifyHandler implements IndicatorNotify {
core = new AlarmCore(rules);
}
@Override public void notify(Indicator indicator) {
WithMetadata withMetadata = (WithMetadata)indicator;
IndicatorMetaInfo meta = withMetadata.getMeta();
@Override public void notify(Metrics metrics) {
WithMetadata withMetadata = (WithMetadata)metrics;
MetricsMetaInfo meta = withMetadata.getMeta();
int scope = meta.getScope();
if (!DefaultScopeDefine.inServiceCatalog(scope)
@ -56,7 +56,7 @@ public class NotifyHandler implements IndicatorNotify {
int serviceId = Integer.parseInt(meta.getId());
ServiceInventory serviceInventory = serviceInventoryCache.get(serviceId);
ServiceMetaInAlarm serviceMetaInAlarm = new ServiceMetaInAlarm();
serviceMetaInAlarm.setIndicatorName(meta.getIndicatorName());
serviceMetaInAlarm.setMetricsName(meta.getMetricsName());
serviceMetaInAlarm.setId(serviceId);
serviceMetaInAlarm.setName(serviceInventory.getName());
metaInAlarm = serviceMetaInAlarm;
@ -64,7 +64,7 @@ public class NotifyHandler implements IndicatorNotify {
int serviceInstanceId = Integer.parseInt(meta.getId());
ServiceInstanceInventory serviceInstanceInventory = serviceInstanceInventoryCache.get(serviceInstanceId);
ServiceInstanceMetaInAlarm instanceMetaInAlarm = new ServiceInstanceMetaInAlarm();
instanceMetaInAlarm.setIndicatorName(meta.getIndicatorName());
instanceMetaInAlarm.setMetricsName(meta.getMetricsName());
instanceMetaInAlarm.setId(serviceInstanceId);
instanceMetaInAlarm.setName(serviceInstanceInventory.getName());
metaInAlarm = instanceMetaInAlarm;
@ -72,7 +72,7 @@ public class NotifyHandler implements IndicatorNotify {
int endpointId = Integer.parseInt(meta.getId());
EndpointInventory endpointInventory = endpointInventoryCache.get(endpointId);
EndpointMetaInAlarm endpointMetaInAlarm = new EndpointMetaInAlarm();
endpointMetaInAlarm.setIndicatorName(meta.getIndicatorName());
endpointMetaInAlarm.setMetricsName(meta.getMetricsName());
endpointMetaInAlarm.setId(endpointId);
int serviceId = endpointInventory.getServiceId();
@ -86,12 +86,12 @@ public class NotifyHandler implements IndicatorNotify {
return;
}
List<RunningRule> runningRules = core.findRunningRule(meta.getIndicatorName());
List<RunningRule> runningRules = core.findRunningRule(meta.getMetricsName());
if (runningRules == null) {
return;
}
runningRules.forEach(rule -> rule.in(metaInAlarm, indicator));
runningRules.forEach(rule -> rule.in(metaInAlarm, metrics));
}
public void init(AlarmCallback... callbacks) {

View File

@ -52,12 +52,12 @@ public class RulesReader {
AlarmRule alarmRule = new AlarmRule();
alarmRule.setAlarmRuleName((String)k);
Map settings = (Map)v;
Object indicatorName = settings.get("indicator-name");
if (indicatorName == null) {
throw new IllegalArgumentException("indicator-name can't be null");
Object metricsName = settings.get("metrics-name");
if (metricsName == null) {
throw new IllegalArgumentException("metrics-name can't be null");
}
alarmRule.setIndicatorName((String)indicatorName);
alarmRule.setMetricsName((String)metricsName);
alarmRule.setIncludeNames((ArrayList)settings.getOrDefault("include-names", new ArrayList(0)));
alarmRule.setThreshold(settings.get("threshold").toString());
alarmRule.setOp((String)settings.get("op"));

View File

@ -26,10 +26,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.skywalking.oap.server.core.alarm.AlarmMessage;
import org.apache.skywalking.oap.server.core.alarm.MetaInAlarm;
import org.apache.skywalking.oap.server.core.analysis.indicator.DoubleValueHolder;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.IntValueHolder;
import org.apache.skywalking.oap.server.core.analysis.indicator.LongValueHolder;
import org.apache.skywalking.oap.server.core.analysis.metrics.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
import org.joda.time.LocalDateTime;
import org.joda.time.Minutes;
@ -49,19 +47,19 @@ public class RunningRule {
private String ruleName;
private int period;
private String indicatorName;
private String metricsName;
private final Threshold threshold;
private final OP op;
private final int countThreshold;
private final int silencePeriod;
private Map<MetaInAlarm, Window> windows;
private volatile IndicatorValueType valueType;
private volatile MetricsValueType valueType;
private int targetScopeId;
private List<String> includeNames;
private AlarmMessageFormatter formatter;
public RunningRule(AlarmRule alarmRule) {
indicatorName = alarmRule.getIndicatorName();
metricsName = alarmRule.getMetricsName();
this.ruleName = alarmRule.getAlarmRuleName();
// Init the empty window for alarming rule.
@ -80,13 +78,13 @@ public class RunningRule {
}
/**
* Receive indicator result from persistence, after it is saved into storage. In alarm, only minute dimensionality
* indicators are expected to process.
* Receive metrics result from persistence, after it is saved into storage. In alarm, only minute dimensionality
* metrics are expected to process.
*
* @param indicator
* @param metrics
*/
public void in(MetaInAlarm meta, Indicator indicator) {
if (!meta.getIndicatorName().equals(indicatorName)) {
public void in(MetaInAlarm meta, Metrics metrics) {
if (!meta.getMetricsName().equals(metricsName)) {
//Don't match rule, exit.
return;
}
@ -98,15 +96,15 @@ public class RunningRule {
}
if (valueType == null) {
if (indicator instanceof LongValueHolder) {
valueType = IndicatorValueType.LONG;
threshold.setType(IndicatorValueType.LONG);
} else if (indicator instanceof IntValueHolder) {
valueType = IndicatorValueType.INT;
threshold.setType(IndicatorValueType.INT);
} else if (indicator instanceof DoubleValueHolder) {
valueType = IndicatorValueType.DOUBLE;
threshold.setType(IndicatorValueType.DOUBLE);
if (metrics instanceof LongValueHolder) {
valueType = MetricsValueType.LONG;
threshold.setType(MetricsValueType.LONG);
} else if (metrics instanceof IntValueHolder) {
valueType = MetricsValueType.INT;
threshold.setType(MetricsValueType.INT);
} else if (metrics instanceof DoubleValueHolder) {
valueType = MetricsValueType.DOUBLE;
threshold.setType(MetricsValueType.DOUBLE);
} else {
return;
}
@ -117,12 +115,12 @@ public class RunningRule {
Window window = windows.get(meta);
if (window == null) {
window = new Window(period);
LocalDateTime timebucket = TIME_BUCKET_FORMATTER.parseLocalDateTime(indicator.getTimeBucket() + "");
LocalDateTime timebucket = TIME_BUCKET_FORMATTER.parseLocalDateTime(metrics.getTimeBucket() + "");
window.moveTo(timebucket);
windows.put(meta, window);
}
window.add(indicator);
window.add(metrics);
}
}
@ -160,7 +158,7 @@ public class RunningRule {
}
/**
* A indicator window, based on {@link AlarmRule#period}. This window slides with time, just keeps the recent
* A metrics window, based on {@link AlarmRule#period}. This window slides with time, just keeps the recent
* N(period) buckets.
*
* @author wusheng
@ -171,7 +169,7 @@ public class RunningRule {
private int counter;
private int silenceCountdown;
private LinkedList<Indicator> values;
private LinkedList<Metrics> values;
private ReentrantLock lock = new ReentrantLock();
public Window(int period) {
@ -209,8 +207,8 @@ public class RunningRule {
}
}
public void add(Indicator indicator) {
long bucket = indicator.getTimeBucket();
public void add(Metrics metrics) {
long bucket = metrics.getTimeBucket();
LocalDateTime timebucket = TIME_BUCKET_FORMATTER.parseLocalDateTime(bucket + "");
@ -233,7 +231,7 @@ public class RunningRule {
return;
}
values.set(values.size() - minutes - 1, indicator);
values.set(values.size() - minutes - 1, metrics);
} finally {
lock.unlock();
}
@ -243,7 +241,7 @@ public class RunningRule {
if (isMatch()) {
/**
* When
* 1. Metric value threshold triggers alarm by rule
* 1. Metrics value threshold triggers alarm by rule
* 2. Counter reaches the count threshold;
* 3. Isn't in silence stage, judged by SilenceCountdown(!=0).
*/
@ -268,14 +266,14 @@ public class RunningRule {
private boolean isMatch() {
int matchCount = 0;
for (Indicator indicator : values) {
if (indicator == null) {
for (Metrics metrics : values) {
if (metrics == null) {
continue;
}
switch (valueType) {
case LONG:
long lvalue = ((LongValueHolder)indicator).getValue();
long lvalue = ((LongValueHolder)metrics).getValue();
long lexpected = RunningRule.this.threshold.getLongThreshold();
switch (op) {
case GREATER:
@ -293,7 +291,7 @@ public class RunningRule {
}
break;
case INT:
int ivalue = ((IntValueHolder)indicator).getValue();
int ivalue = ((IntValueHolder)metrics).getValue();
int iexpected = RunningRule.this.threshold.getIntThreshold();
switch (op) {
case LESS:
@ -311,7 +309,7 @@ public class RunningRule {
}
break;
case DOUBLE:
double dvalue = ((DoubleValueHolder)indicator).getValue();
double dvalue = ((DoubleValueHolder)metrics).getValue();
double dexpected = RunningRule.this.threshold.getDoubleThreadhold();
switch (op) {
case EQUAL:

View File

@ -50,7 +50,7 @@ public class Threshold {
return longThreshold;
}
public void setType(IndicatorValueType type) {
public void setType(MetricsValueType type) {
try {
switch (type) {
case INT:
@ -64,7 +64,7 @@ public class Threshold {
break;
}
} catch (NumberFormatException e) {
logger.warn("Alarm rule {} threshold doesn't match the indicator type, expected type: {}", alarmRuleName, type);
logger.warn("Alarm rule {} threshold doesn't match the metrics type, expected type: {}", alarmRuleName, type);
}
}
}

View File

@ -35,7 +35,7 @@ public class AlarmMessageFormatterTest {
return null;
}
@Override public String getIndicatorName() {
@Override public String getMetricsName() {
return null;
}
@ -64,7 +64,7 @@ public class AlarmMessageFormatterTest {
return "service";
}
@Override public String getIndicatorName() {
@Override public String getMetricsName() {
return null;
}

View File

@ -21,26 +21,16 @@ package org.apache.skywalking.oap.server.core.alarm.provider;
import com.google.common.collect.Lists;
import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.alarm.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.IndicatorMetaInfo;
import org.apache.skywalking.oap.server.core.analysis.indicator.WithMetadata;
import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache;
import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache;
import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache;
import org.apache.skywalking.oap.server.core.register.EndpointInventory;
import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory;
import org.apache.skywalking.oap.server.core.register.ServiceInventory;
import org.apache.skywalking.oap.server.core.analysis.metrics.*;
import org.apache.skywalking.oap.server.core.cache.*;
import org.apache.skywalking.oap.server.core.register.*;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.module.ModuleProviderHolder;
import org.apache.skywalking.oap.server.library.module.ModuleServiceHolder;
import org.junit.Before;
import org.junit.Test;
import org.apache.skywalking.oap.server.library.module.*;
import org.junit.*;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.*;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
@ -69,21 +59,20 @@ public class NotifyHandlerTest {
private EndpointInventoryCache endpointInventoryCache;
private MockIndicator indicator;
private MockMetrics metrics;
private IndicatorMetaInfo metadata;
private MetricsMetaInfo metadata;
private int mockId = 1;
private RunningRule rule;
@Test
public void testNotifyWithEndpointCatalog() {
prepareNotify();
String indicatorName = "endpoint-indicator";
when(metadata.getIndicatorName()).thenReturn(indicatorName);
String metricsName = "endpoint-metrics";
when(metadata.getMetricsName()).thenReturn(metricsName);
when(DefaultScopeDefine.inEndpointCatalog(0)).thenReturn(true);
@ -101,14 +90,14 @@ public class NotifyHandlerTest {
ArgumentCaptor<MetaInAlarm> metaCaptor = ArgumentCaptor.forClass(MetaInAlarm.class);
notifyHandler.notify(indicator);
notifyHandler.notify(metrics);
verify(rule).in(metaCaptor.capture(), any());
MetaInAlarm metaInAlarm = metaCaptor.getValue();
assertTrue(metaInAlarm instanceof EndpointMetaInAlarm);
assertEquals(mockId, metaInAlarm.getId0());
assertEquals(indicatorName, metaInAlarm.getIndicatorName());
assertEquals(metricsName, metaInAlarm.getMetricsName());
assertEquals(endpointInventoryName + " in " + serviceInventoryName, metaInAlarm.getName());
assertEquals(DefaultScopeDefine.ENDPOINT, metaInAlarm.getScopeId());
@ -119,8 +108,8 @@ public class NotifyHandlerTest {
prepareNotify();
String indicatorName = "service-instance-indicator";
when(metadata.getIndicatorName()).thenReturn(indicatorName);
String metricsName = "service-instance-metrics";
when(metadata.getMetricsName()).thenReturn(metricsName);
when(DefaultScopeDefine.inServiceInstanceCatalog(0)).thenReturn(true);
@ -132,13 +121,13 @@ public class NotifyHandlerTest {
ArgumentCaptor<MetaInAlarm> metaCaptor = ArgumentCaptor.forClass(MetaInAlarm.class);
notifyHandler.notify(indicator);
notifyHandler.notify(metrics);
verify(rule).in(metaCaptor.capture(), any());
MetaInAlarm metaInAlarm = metaCaptor.getValue();
assertTrue(metaInAlarm instanceof ServiceInstanceMetaInAlarm);
assertEquals(indicatorName, metaInAlarm.getIndicatorName());
assertEquals(metricsName, metaInAlarm.getMetricsName());
assertEquals(mockId, metaInAlarm.getId0());
assertEquals(instanceInventoryName, metaInAlarm.getName());
assertEquals(DefaultScopeDefine.SERVICE_INSTANCE, metaInAlarm.getScopeId());
@ -148,8 +137,8 @@ public class NotifyHandlerTest {
public void testNotifyWithServiceCatalog() {
prepareNotify();
String indicatorName = "service-indicator";
when(metadata.getIndicatorName()).thenReturn(indicatorName);
String metricsName = "service-metrics";
when(metadata.getMetricsName()).thenReturn(metricsName);
when(DefaultScopeDefine.inServiceCatalog(0)).thenReturn(true);
ServiceInventory serviceInventory = mock(ServiceInventory.class);
@ -160,13 +149,13 @@ public class NotifyHandlerTest {
ArgumentCaptor<MetaInAlarm> metaCaptor = ArgumentCaptor.forClass(MetaInAlarm.class);
notifyHandler.notify(indicator);
notifyHandler.notify(metrics);
verify(rule).in(metaCaptor.capture(), any());
MetaInAlarm metaInAlarm = metaCaptor.getValue();
assertTrue(metaInAlarm instanceof ServiceMetaInAlarm);
assertEquals(indicatorName, metaInAlarm.getIndicatorName());
assertEquals(metricsName, metaInAlarm.getMetricsName());
assertEquals(mockId, metaInAlarm.getId0());
assertEquals(serviceInventoryName, metaInAlarm.getName());
assertEquals(DefaultScopeDefine.SERVICE, metaInAlarm.getScopeId());
@ -175,12 +164,12 @@ public class NotifyHandlerTest {
private void prepareNotify() {
notifyHandler.initCache(moduleManager);
metadata = mock(IndicatorMetaInfo.class);
metadata = mock(MetricsMetaInfo.class);
when(metadata.getScope()).thenReturn(DefaultScopeDefine.ALL);
when(metadata.getId()).thenReturn(String.valueOf(mockId));
indicator = mock(MockIndicator.class);
when(indicator.getMeta()).thenReturn(metadata);
metrics = mock(MockMetrics.class);
when(metrics.getMeta()).thenReturn(metadata);
PowerMockito.mockStatic(DefaultScopeDefine.class);
}
@ -188,13 +177,13 @@ public class NotifyHandlerTest {
@Test
public void dontNotify() {
IndicatorMetaInfo metadata = mock(IndicatorMetaInfo.class);
MetricsMetaInfo metadata = mock(MetricsMetaInfo.class);
when(metadata.getScope()).thenReturn(DefaultScopeDefine.ALL);
MockIndicator indicator = mock(MockIndicator.class);
when(indicator.getMeta()).thenReturn(metadata);
MockMetrics mockMetrics = mock(MockMetrics.class);
when(mockMetrics.getMeta()).thenReturn(metadata);
notifyHandler.notify(indicator);
notifyHandler.notify(mockMetrics);
}
@Test
@ -203,7 +192,6 @@ public class NotifyHandlerTest {
notifyHandler.initCache(moduleManager);
}
@Before
public void setUp() throws Exception {
@ -217,12 +205,10 @@ public class NotifyHandlerTest {
}
});
moduleManager = mock(ModuleManager.class);
moduleProviderHolder = mock(ModuleProviderHolder.class);
moduleServiceHolder = mock(ModuleServiceHolder.class);
when(moduleManager.find(CoreModule.NAME)).thenReturn(moduleProviderHolder);
@ -240,14 +226,14 @@ public class NotifyHandlerTest {
rule = mock(RunningRule.class);
doNothing().when(rule).in(any(MetaInAlarm.class), any(Indicator.class));
doNothing().when(rule).in(any(MetaInAlarm.class), any(Metrics.class));
when(core.findRunningRule(anyString())).thenReturn(Lists.newArrayList(rule));
Whitebox.setInternalState(notifyHandler, "core", core);
}
private abstract class MockIndicator extends Indicator implements WithMetadata {
private abstract class MockMetrics extends Metrics implements WithMetadata {
}
}

View File

@ -20,7 +20,7 @@ package org.apache.skywalking.oap.server.core.alarm.provider;
import java.util.*;
import org.apache.skywalking.oap.server.core.alarm.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.*;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
import org.joda.time.LocalDateTime;
@ -42,7 +42,7 @@ public class RunningRuleTest {
public void testInitAndStart() {
AlarmRule alarmRule = new AlarmRule();
alarmRule.setAlarmRuleName("endpoint_percent_rule");
alarmRule.setIndicatorName("endpoint_percent");
alarmRule.setMetricsName("endpoint_percent");
alarmRule.setOp("<");
alarmRule.setThreshold("75");
alarmRule.setCount(3);
@ -51,25 +51,25 @@ public class RunningRuleTest {
RunningRule runningRule = new RunningRule(alarmRule);
LocalDateTime startTime = TIME_BUCKET_FORMATTER.parseLocalDateTime("201808301434");
long timeInPeriod1 = 201808301434L;
runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod1, 70));
runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod1, 70));
Map<MetaInAlarm, RunningRule.Window> windows = Whitebox.getInternalState(runningRule, "windows");
RunningRule.Window window = windows.get(getMetaInAlarm(123));
LocalDateTime endTime = Whitebox.getInternalState(window, "endTime");
int period = Whitebox.getInternalState(window, "period");
LinkedList<Indicator> indicatorBuffer = Whitebox.getInternalState(window, "values");
LinkedList<Metrics> metricsBuffer = Whitebox.getInternalState(window, "values");
Assert.assertTrue(startTime.equals(endTime));
Assert.assertEquals(15, period);
Assert.assertEquals(15, indicatorBuffer.size());
Assert.assertEquals(15, metricsBuffer.size());
}
@Test
public void testAlarm() {
AlarmRule alarmRule = new AlarmRule();
alarmRule.setAlarmRuleName("endpoint_percent_rule");
alarmRule.setIndicatorName("endpoint_percent");
alarmRule.setMetricsName("endpoint_percent");
alarmRule.setOp("<");
alarmRule.setThreshold("75");
alarmRule.setCount(3);
@ -83,9 +83,9 @@ public class RunningRuleTest {
long timeInPeriod2 = 201808301436L;
long timeInPeriod3 = 201808301438L;
runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod1, 70));
runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod2, 71));
runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod3, 74));
runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod1, 70));
runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod2, 71));
runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod3, 74));
// check at 201808301440
List<AlarmMessage> alarmMessages = runningRule.check();
@ -105,7 +105,7 @@ public class RunningRuleTest {
public void testNoAlarm() {
AlarmRule alarmRule = new AlarmRule();
alarmRule.setAlarmRuleName("endpoint_percent_rule");
alarmRule.setIndicatorName("endpoint_percent");
alarmRule.setMetricsName("endpoint_percent");
alarmRule.setOp(">");
alarmRule.setThreshold("75");
alarmRule.setCount(3);
@ -129,11 +129,11 @@ public class RunningRuleTest {
long timeInPeriod3 = 201808301438L;
long timeInPeriod4 = 201808301432L;
long timeInPeriod5 = 201808301440L;
runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod1, 70));
runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod2, 71));
runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod3, 74));
runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod4, 90));
runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod5, 95));
runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod1, 70));
runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod2, 71));
runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod3, 74));
runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod4, 90));
runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod5, 95));
// check at 201808301440
Assert.assertEquals(0, runningRule.check().size());
@ -149,7 +149,7 @@ public class RunningRuleTest {
public void testSilence() {
AlarmRule alarmRule = new AlarmRule();
alarmRule.setAlarmRuleName("endpoint_percent_rule");
alarmRule.setIndicatorName("endpoint_percent");
alarmRule.setMetricsName("endpoint_percent");
alarmRule.setOp("<");
alarmRule.setThreshold("75");
alarmRule.setCount(3);
@ -161,9 +161,9 @@ public class RunningRuleTest {
long timeInPeriod1 = 201808301434L;
long timeInPeriod2 = 201808301436L;
long timeInPeriod3 = 201808301438L;
runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod1, 70));
runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod2, 71));
runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod3, 74));
runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod1, 70));
runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod2, 71));
runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod3, 74));
// check at 201808301440
Assert.assertEquals(0, runningRule.check().size()); //check matches, no alarm
@ -191,7 +191,7 @@ public class RunningRuleTest {
return "Service_" + id;
}
@Override public String getIndicatorName() {
@Override public String getMetricsName() {
return "endpoint_percent";
}
@ -214,21 +214,21 @@ public class RunningRuleTest {
};
}
private Indicator getIndicator(long timebucket, int value) {
MockIndicator indicator = new MockIndicator();
indicator.setValue(value);
indicator.setTimeBucket(timebucket);
return indicator;
private Metrics getMetrics(long timeBucket, int value) {
MockMetrics mockMetrics = new MockMetrics();
mockMetrics.setValue(value);
mockMetrics.setTimeBucket(timeBucket);
return mockMetrics;
}
private class MockIndicator extends Indicator implements IntValueHolder {
private class MockMetrics extends Metrics implements IntValueHolder {
private int value;
@Override public String id() {
return null;
}
@Override public void combine(Indicator indicator) {
@Override public void combine(Metrics metrics) {
}
@ -236,15 +236,15 @@ public class RunningRuleTest {
}
@Override public Indicator toHour() {
@Override public Metrics toHour() {
return null;
}
@Override public Indicator toDay() {
@Override public Metrics toDay() {
return null;
}
@Override public Indicator toMonth() {
@Override public Metrics toMonth() {
return null;
}

View File

@ -30,20 +30,20 @@ public class ThresholdTest {
@Test
public void setType() {
Threshold threshold = new Threshold("my-rule", "75");
threshold.setType(IndicatorValueType.DOUBLE);
threshold.setType(MetricsValueType.DOUBLE);
assertEquals(0, Double.compare(75, threshold.getDoubleThreadhold()));
threshold.setType(IndicatorValueType.INT);
threshold.setType(MetricsValueType.INT);
assertEquals(75, threshold.getIntThreshold());
threshold.setType(IndicatorValueType.LONG);
threshold.setType(MetricsValueType.LONG);
assertEquals(75L, threshold.getLongThreshold());
}
@Test
public void setTypeWithWrong() {
Threshold threshold = new Threshold("my-rule", "wrong");
threshold.setType(IndicatorValueType.INT);
threshold.setType(MetricsValueType.INT);
assertEquals(0, threshold.getIntThreshold());
}
}

View File

@ -17,20 +17,20 @@
rules:
# Rule unique name, must be ended with `_rule`.
endpoint_percent_rule:
# Indicator value need to be long, double or int
indicator-name: endpoint_percent
# Metrics value need to be long, double or int
metrics-name: endpoint_percent
threshold: 75
op: <
# The length of time to evaluate the metric
# The length of time to evaluate the metrics
period: 10
# How many times after the metric match the condition, will trigger alarm
# How many times after the metrics match the condition, will trigger alarm
count: 3
# How many times of checks, the alarm keeps silence after alarm triggered, default as same as period.
silence-period: 10
message: Successful rate of endpoint {name} is lower than 75%
service_percent_rule:
indicator-name: service_percent
# [Optional] Default, match all services in this indicator
metrics-name: service_percent
# [Optional] Default, match all services in this metrics
include-names:
- service_a
- service_b

View File

@ -1,166 +0,0 @@
/*
* 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.oap.server.cluster.plugin.kubernetes.dependencies;
import com.squareup.okhttp.Call;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.models.V1ObjectMeta;
import io.kubernetes.client.models.V1Pod;
import io.kubernetes.client.models.V1PodStatus;
import io.kubernetes.client.util.Watch;
import org.apache.skywalking.oap.server.cluster.plugin.kubernetes.Event;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
import java.lang.reflect.Type;
import java.util.Iterator;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
/**
* Created by dengming, 2019.05.02
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({Watch.class, OkHttpClient.class})
@PowerMockIgnore("javax.management.*")
public class NamespacedPodListWatchTest {
private NamespacedPodListWatch namespacedPodListWatch;
private Watch mockWatch = mock(Watch.class);
private static final String NAME_SPACE = "my-namespace";
private static final String LABEL_SELECTOR = "equality-based";
private static final String RESPONSE_TYPE = "my-type";
private static final int WATCH_TIMEOUT_SECONDS = 3;
@Before
public void setUp() throws Exception {
namespacedPodListWatch = new NamespacedPodListWatch(NAME_SPACE, LABEL_SELECTOR, WATCH_TIMEOUT_SECONDS);
PowerMockito.mockStatic(Watch.class);
when(Watch.createWatch(any(), any(), any())).thenReturn(mockWatch);
Call mockCall = mock(Call.class);
PowerMockito.whenNew(Call.class).withArguments(any(OkHttpClient.class), any(Request.class)).thenReturn(mockCall);
namespacedPodListWatch.initOrReset();
ArgumentCaptor<ApiClient> apiClientArgumentCaptor = ArgumentCaptor.forClass(ApiClient.class);
ArgumentCaptor<Call> callArgumentCaptor = ArgumentCaptor.forClass(Call.class);
ArgumentCaptor<Type> typeArgumentCaptor = ArgumentCaptor.forClass(Type.class);
PowerMockito.verifyStatic();
Watch.createWatch(
apiClientArgumentCaptor.capture(),
callArgumentCaptor.capture(),
typeArgumentCaptor.capture());
ApiClient apiClient = apiClientArgumentCaptor.getValue();
Call call = callArgumentCaptor.getValue();
Type type = typeArgumentCaptor.getValue();
assertEquals(mockCall, call);
assertNotNull(apiClient);
assertNotNull(type);
}
@Test
public void iterator() {
when(mockWatch.hasNext()).thenReturn(true, true, false);
Iterator mockIterator = mockIterator();
when(mockWatch.iterator()).thenReturn(mockIterator);
Iterator<Event> iterator = namespacedPodListWatch.iterator();
assertNotNull(iterator);
assertTrue(iterator.hasNext());
Event event0 = iterator.next();
assertNotNull(event0);
validateEvent(event0, 0);
assertTrue(iterator.hasNext());
Event event1 = iterator.next();
assertNotNull(event1);
validateEvent(event1, 1);
assertFalse(iterator.hasNext());
}
@Test
public void iteratorWithEmpty() {
Iterator iterator = mock(Iterator.class);
when(iterator.hasNext()).thenReturn(false);
when(mockWatch.iterator()).thenReturn(iterator);
Iterator<Event> eventIterator = namespacedPodListWatch.iterator();
assertFalse(eventIterator.hasNext());
}
private Iterator<Watch.Response<V1Pod>> mockIterator() {
Iterator<Watch.Response<V1Pod>> iterator = mock(Iterator.class);
when(iterator.hasNext()).thenReturn(true, true, false);
Watch.Response response0 = mockResponse(0);
Watch.Response response1 = mockResponse(1);
when(iterator.next()).thenReturn(response0, response1);
return iterator;
}
private Watch.Response<V1Pod> mockResponse(int i) {
V1Pod v1Pod = new V1Pod();
V1ObjectMeta meta = new V1ObjectMeta();
V1PodStatus status = new V1PodStatus();
status.setPodIP("PodIp" + i);
meta.setUid("uid" + i);
v1Pod.setMetadata(meta);
v1Pod.setStatus(status);
Watch.Response response = mock(Watch.Response.class);
response.object = v1Pod;
response.type = RESPONSE_TYPE;
return response;
}
private void validateEvent(Event event, int i) {
String type = Whitebox.getInternalState(event, "type");
assertEquals(RESPONSE_TYPE, type);
String uid = Whitebox.getInternalState(event, "uid");
assertEquals("uid" + i, uid);
String host = Whitebox.getInternalState(event, "host");
assertEquals("PodIp" + i, host);
}
}

View File

@ -20,7 +20,7 @@ package org.apache.skywalking.oap.server.core;
import java.io.IOException;
import org.apache.skywalking.oap.server.core.analysis.DisableRegister;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorTypeListener;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsTypeListener;
import org.apache.skywalking.oap.server.core.analysis.record.annotation.RecordTypeListener;
import org.apache.skywalking.oap.server.core.analysis.topn.annotation.TopNTypeListener;
import org.apache.skywalking.oap.server.core.annotation.AnnotationScan;
@ -153,7 +153,7 @@ public class CoreModuleProvider extends ModuleProvider {
annotationScan.registerListener(storageAnnotationListener);
annotationScan.registerListener(streamAnnotationListener);
annotationScan.registerListener(new IndicatorTypeListener(getManager()));
annotationScan.registerListener(new MetricsTypeListener(getManager()));
annotationScan.registerListener(new InventoryTypeListener(getManager()));
annotationScan.registerListener(new RecordTypeListener(getManager()));
annotationScan.registerListener(new TopNTypeListener(getManager()));

View File

@ -18,7 +18,7 @@
package org.apache.skywalking.oap.server.core.alarm;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder;
/**
@ -26,25 +26,25 @@ import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder;
*/
public class AlarmEntrance {
private ModuleDefineHolder moduleDefineHolder;
private IndicatorNotify indicatorNotify;
private MetricsNotify metricsNotify;
public AlarmEntrance(ModuleDefineHolder moduleDefineHolder) {
this.moduleDefineHolder = moduleDefineHolder;
}
public void forward(Indicator indicator) {
public void forward(Metrics metrics) {
if (!moduleDefineHolder.has(AlarmModule.NAME)) {
return;
}
init();
indicatorNotify.notify(indicator);
metricsNotify.notify(metrics);
}
private void init() {
if (indicatorNotify == null) {
indicatorNotify = moduleDefineHolder.find(AlarmModule.NAME).provider().getService(IndicatorNotify.class);
if (metricsNotify == null) {
metricsNotify = moduleDefineHolder.find(AlarmModule.NAME).provider().getService(MetricsNotify.class);
}
}
}

View File

@ -35,6 +35,6 @@ public class AlarmModule extends ModuleDefine {
}
@Override public Class[] services() {
return new Class[] {IndicatorNotify.class};
return new Class[] {MetricsNotify.class};
}
}

View File

@ -26,7 +26,7 @@ import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
public class EndpointMetaInAlarm extends MetaInAlarm {
private String indicatorName;
private String metricsName;
private int id;
private String name;

View File

@ -25,7 +25,7 @@ public abstract class MetaInAlarm {
public abstract String getName();
public abstract String getIndicatorName();
public abstract String getMetricsName();
/**
* In most scopes, there is only id0, as primary id. Such as Service, Endpoint. But in relation, the ID includes

View File

@ -18,11 +18,11 @@
package org.apache.skywalking.oap.server.core.alarm;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
import org.apache.skywalking.oap.server.library.module.Service;
/**
* Indicator notify service should be provided by Alarm Module provider, which can receive the indicator value, driven
* Metrics notify service should be provided by Alarm Module provider, which can receive the metrics value, driven
* by storage core.
*
* The alarm module provider could choose whether or how to do the alarm. Meanwhile, the storage core will provide the
@ -31,6 +31,6 @@ import org.apache.skywalking.oap.server.library.module.Service;
*
* @author wusheng
*/
public interface IndicatorNotify extends Service {
void notify(Indicator indicator);
public interface MetricsNotify extends Service {
void notify(Metrics metrics);
}

View File

@ -18,15 +18,13 @@
package org.apache.skywalking.oap.server.core.alarm;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.*;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
public class ServiceInstanceMetaInAlarm extends MetaInAlarm {
private String indicatorName;
private String metricsName;
private int id;
private String name;

View File

@ -18,15 +18,13 @@
package org.apache.skywalking.oap.server.core.alarm;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.*;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
public class ServiceMetaInAlarm extends MetaInAlarm {
private String indicatorName;
private String metricsName;
private int id;
private String name;

View File

@ -18,28 +18,28 @@
package org.apache.skywalking.oap.server.core.analysis.data;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
/**
* @author peng-yongsheng
*/
public class MergeDataCache<INDICATOR extends Indicator> extends Window<INDICATOR> implements DataCache {
public class MergeDataCache<METRICS extends Metrics> extends Window<METRICS> implements DataCache {
private SWCollection<INDICATOR> lockedMergeDataCollection;
private SWCollection<METRICS> lockedMergeDataCollection;
@Override public SWCollection<INDICATOR> collectionInstance() {
@Override public SWCollection<METRICS> collectionInstance() {
return new MergeDataCollection<>();
}
public boolean containsKey(INDICATOR key) {
public boolean containsKey(METRICS key) {
return lockedMergeDataCollection.containsKey(key);
}
public Indicator get(INDICATOR key) {
public Metrics get(METRICS key) {
return lockedMergeDataCollection.get(key);
}
public void put(INDICATOR data) {
public void put(METRICS data) {
lockedMergeDataCollection.put(data);
}

View File

@ -19,7 +19,7 @@
package org.apache.skywalking.oap.server.core.analysis.manual.endpointrelation;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
import org.apache.skywalking.oap.server.core.analysis.worker.MetricsProcess;
import org.apache.skywalking.oap.server.core.source.EndpointRelation;
/**
@ -36,12 +36,12 @@ public class EndpointCallRelationDispatcher implements SourceDispatcher<Endpoint
}
private void serverSide(EndpointRelation source) {
EndpointRelationServerSideIndicator indicator = new EndpointRelationServerSideIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setSourceEndpointId(source.getEndpointId());
indicator.setDestEndpointId(source.getChildEndpointId());
indicator.setComponentId(source.getComponentId());
indicator.setEntityId(source.getEntityId());
IndicatorProcess.INSTANCE.in(indicator);
EndpointRelationServerSideMetrics metrics = new EndpointRelationServerSideMetrics();
metrics.setTimeBucket(source.getTimeBucket());
metrics.setSourceEndpointId(source.getEndpointId());
metrics.setDestEndpointId(source.getChildEndpointId());
metrics.setComponentId(source.getComponentId());
metrics.setEntityId(source.getEntityId());
MetricsProcess.INSTANCE.in(metrics);
}
}

View File

@ -21,18 +21,18 @@ package org.apache.skywalking.oap.server.core.analysis.manual.endpointrelation;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
@IndicatorType
@MetricsType
@StreamData
@StorageEntity(name = EndpointRelationServerSideIndicator.INDEX_NAME, builder = EndpointRelationServerSideIndicator.Builder.class, sourceScopeId = DefaultScopeDefine.ENDPOINT_RELATION)
public class EndpointRelationServerSideIndicator extends Indicator {
@StorageEntity(name = EndpointRelationServerSideMetrics.INDEX_NAME, builder = EndpointRelationServerSideMetrics.Builder.class, sourceScopeId = DefaultScopeDefine.ENDPOINT_RELATION)
public class EndpointRelationServerSideMetrics extends Metrics {
public static final String INDEX_NAME = "endpoint_relation_server_side";
public static final String SOURCE_ENDPOINT_ID = "source_endpoint_id";
@ -52,7 +52,7 @@ public class EndpointRelationServerSideIndicator extends Indicator {
return splitJointId;
}
@Override public void combine(Indicator indicator) {
@Override public void combine(Metrics metrics) {
}
@ -60,34 +60,34 @@ public class EndpointRelationServerSideIndicator extends Indicator {
}
@Override public Indicator toHour() {
EndpointRelationServerSideIndicator indicator = new EndpointRelationServerSideIndicator();
indicator.setTimeBucket(toTimeBucketInHour());
indicator.setSourceEndpointId(getSourceEndpointId());
indicator.setDestEndpointId(getDestEndpointId());
indicator.setComponentId(getComponentId());
indicator.setEntityId(getEntityId());
return indicator;
@Override public Metrics toHour() {
EndpointRelationServerSideMetrics metrics = new EndpointRelationServerSideMetrics();
metrics.setTimeBucket(toTimeBucketInHour());
metrics.setSourceEndpointId(getSourceEndpointId());
metrics.setDestEndpointId(getDestEndpointId());
metrics.setComponentId(getComponentId());
metrics.setEntityId(getEntityId());
return metrics;
}
@Override public Indicator toDay() {
EndpointRelationServerSideIndicator indicator = new EndpointRelationServerSideIndicator();
indicator.setTimeBucket(toTimeBucketInDay());
indicator.setSourceEndpointId(getSourceEndpointId());
indicator.setDestEndpointId(getDestEndpointId());
indicator.setComponentId(getComponentId());
indicator.setEntityId(getEntityId());
return indicator;
@Override public Metrics toDay() {
EndpointRelationServerSideMetrics metrics = new EndpointRelationServerSideMetrics();
metrics.setTimeBucket(toTimeBucketInDay());
metrics.setSourceEndpointId(getSourceEndpointId());
metrics.setDestEndpointId(getDestEndpointId());
metrics.setComponentId(getComponentId());
metrics.setEntityId(getEntityId());
return metrics;
}
@Override public Indicator toMonth() {
EndpointRelationServerSideIndicator indicator = new EndpointRelationServerSideIndicator();
indicator.setTimeBucket(toTimeBucketInMonth());
indicator.setSourceEndpointId(getSourceEndpointId());
indicator.setDestEndpointId(getDestEndpointId());
indicator.setComponentId(getComponentId());
indicator.setEntityId(getEntityId());
return indicator;
@Override public Metrics toMonth() {
EndpointRelationServerSideMetrics metrics = new EndpointRelationServerSideMetrics();
metrics.setTimeBucket(toTimeBucketInMonth());
metrics.setSourceEndpointId(getSourceEndpointId());
metrics.setDestEndpointId(getDestEndpointId());
metrics.setComponentId(getComponentId());
metrics.setEntityId(getEntityId());
return metrics;
}
@Override public int remoteHashCode() {
@ -138,33 +138,33 @@ public class EndpointRelationServerSideIndicator extends Indicator {
if (getClass() != obj.getClass())
return false;
EndpointRelationServerSideIndicator indicator = (EndpointRelationServerSideIndicator)obj;
if (sourceEndpointId != indicator.sourceEndpointId)
EndpointRelationServerSideMetrics metrics = (EndpointRelationServerSideMetrics)obj;
if (sourceEndpointId != metrics.sourceEndpointId)
return false;
if (destEndpointId != indicator.destEndpointId)
if (destEndpointId != metrics.destEndpointId)
return false;
if (componentId != indicator.componentId)
if (componentId != metrics.componentId)
return false;
if (getTimeBucket() != indicator.getTimeBucket())
if (getTimeBucket() != metrics.getTimeBucket())
return false;
return true;
}
public static class Builder implements StorageBuilder<EndpointRelationServerSideIndicator> {
public static class Builder implements StorageBuilder<EndpointRelationServerSideMetrics> {
@Override public EndpointRelationServerSideIndicator map2Data(Map<String, Object> dbMap) {
EndpointRelationServerSideIndicator indicator = new EndpointRelationServerSideIndicator();
indicator.setSourceEndpointId(((Number)dbMap.get(SOURCE_ENDPOINT_ID)).intValue());
indicator.setDestEndpointId(((Number)dbMap.get(DEST_ENDPOINT_ID)).intValue());
indicator.setComponentId(((Number)dbMap.get(COMPONENT_ID)).intValue());
indicator.setTimeBucket(((Number)dbMap.get(TIME_BUCKET)).longValue());
indicator.setEntityId((String)dbMap.get(ENTITY_ID));
return indicator;
@Override public EndpointRelationServerSideMetrics map2Data(Map<String, Object> dbMap) {
EndpointRelationServerSideMetrics metrics = new EndpointRelationServerSideMetrics();
metrics.setSourceEndpointId(((Number)dbMap.get(SOURCE_ENDPOINT_ID)).intValue());
metrics.setDestEndpointId(((Number)dbMap.get(DEST_ENDPOINT_ID)).intValue());
metrics.setComponentId(((Number)dbMap.get(COMPONENT_ID)).intValue());
metrics.setTimeBucket(((Number)dbMap.get(TIME_BUCKET)).longValue());
metrics.setEntityId((String)dbMap.get(ENTITY_ID));
return metrics;
}
@Override public Map<String, Object> data2Map(EndpointRelationServerSideIndicator storageData) {
@Override public Map<String, Object> data2Map(EndpointRelationServerSideMetrics storageData) {
Map<String, Object> map = new HashMap<>();
map.put(SOURCE_ENDPOINT_ID, storageData.getSourceEndpointId());
map.put(DEST_ENDPOINT_ID, storageData.getDestEndpointId());

View File

@ -19,7 +19,7 @@
package org.apache.skywalking.oap.server.core.analysis.manual.servicerelation;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
import org.apache.skywalking.oap.server.core.analysis.worker.MetricsProcess;
import org.apache.skywalking.oap.server.core.source.ServiceRelation;
/**
@ -39,22 +39,22 @@ public class ServiceCallRelationDispatcher implements SourceDispatcher<ServiceRe
}
private void serverSide(ServiceRelation source) {
ServiceRelationServerSideIndicator indicator = new ServiceRelationServerSideIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setSourceServiceId(source.getSourceServiceId());
indicator.setDestServiceId(source.getDestServiceId());
indicator.setComponentId(source.getComponentId());
indicator.setEntityId(source.getEntityId());
IndicatorProcess.INSTANCE.in(indicator);
ServiceRelationServerSideMetrics metrics = new ServiceRelationServerSideMetrics();
metrics.setTimeBucket(source.getTimeBucket());
metrics.setSourceServiceId(source.getSourceServiceId());
metrics.setDestServiceId(source.getDestServiceId());
metrics.setComponentId(source.getComponentId());
metrics.setEntityId(source.getEntityId());
MetricsProcess.INSTANCE.in(metrics);
}
private void clientSide(ServiceRelation source) {
ServiceRelationClientSideIndicator indicator = new ServiceRelationClientSideIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setSourceServiceId(source.getSourceServiceId());
indicator.setDestServiceId(source.getDestServiceId());
indicator.setComponentId(source.getComponentId());
indicator.setEntityId(source.getEntityId());
IndicatorProcess.INSTANCE.in(indicator);
ServiceRelationClientSideMetrics metrics = new ServiceRelationClientSideMetrics();
metrics.setTimeBucket(source.getTimeBucket());
metrics.setSourceServiceId(source.getSourceServiceId());
metrics.setDestServiceId(source.getDestServiceId());
metrics.setComponentId(source.getComponentId());
metrics.setEntityId(source.getEntityId());
MetricsProcess.INSTANCE.in(metrics);
}
}

View File

@ -21,18 +21,18 @@ package org.apache.skywalking.oap.server.core.analysis.manual.servicerelation;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
@IndicatorType
@MetricsType
@StreamData
@StorageEntity(name = ServiceRelationClientSideIndicator.INDEX_NAME, builder = ServiceRelationClientSideIndicator.Builder.class, sourceScopeId = DefaultScopeDefine.SERVICE_RELATION)
public class ServiceRelationClientSideIndicator extends Indicator {
@StorageEntity(name = ServiceRelationClientSideMetrics.INDEX_NAME, builder = ServiceRelationClientSideMetrics.Builder.class, sourceScopeId = DefaultScopeDefine.SERVICE_RELATION)
public class ServiceRelationClientSideMetrics extends Metrics {
public static final String INDEX_NAME = "service_relation_client_side";
public static final String SOURCE_SERVICE_ID = "source_service_id";
@ -52,7 +52,7 @@ public class ServiceRelationClientSideIndicator extends Indicator {
return splitJointId;
}
@Override public void combine(Indicator indicator) {
@Override public void combine(Metrics metrics) {
}
@ -60,34 +60,34 @@ public class ServiceRelationClientSideIndicator extends Indicator {
}
@Override public Indicator toHour() {
ServiceRelationClientSideIndicator indicator = new ServiceRelationClientSideIndicator();
indicator.setEntityId(getEntityId());
indicator.setTimeBucket(toTimeBucketInHour());
indicator.setSourceServiceId(getSourceServiceId());
indicator.setDestServiceId(getDestServiceId());
indicator.setComponentId(getComponentId());
return indicator;
@Override public Metrics toHour() {
ServiceRelationClientSideMetrics metrics = new ServiceRelationClientSideMetrics();
metrics.setEntityId(getEntityId());
metrics.setTimeBucket(toTimeBucketInHour());
metrics.setSourceServiceId(getSourceServiceId());
metrics.setDestServiceId(getDestServiceId());
metrics.setComponentId(getComponentId());
return metrics;
}
@Override public Indicator toDay() {
ServiceRelationClientSideIndicator indicator = new ServiceRelationClientSideIndicator();
indicator.setEntityId(getEntityId());
indicator.setTimeBucket(toTimeBucketInDay());
indicator.setSourceServiceId(getSourceServiceId());
indicator.setDestServiceId(getDestServiceId());
indicator.setComponentId(getComponentId());
return indicator;
@Override public Metrics toDay() {
ServiceRelationClientSideMetrics metrics = new ServiceRelationClientSideMetrics();
metrics.setEntityId(getEntityId());
metrics.setTimeBucket(toTimeBucketInDay());
metrics.setSourceServiceId(getSourceServiceId());
metrics.setDestServiceId(getDestServiceId());
metrics.setComponentId(getComponentId());
return metrics;
}
@Override public Indicator toMonth() {
ServiceRelationClientSideIndicator indicator = new ServiceRelationClientSideIndicator();
indicator.setEntityId(getEntityId());
indicator.setTimeBucket(toTimeBucketInMonth());
indicator.setSourceServiceId(getSourceServiceId());
indicator.setDestServiceId(getDestServiceId());
indicator.setComponentId(getComponentId());
return indicator;
@Override public Metrics toMonth() {
ServiceRelationClientSideMetrics metrics = new ServiceRelationClientSideMetrics();
metrics.setEntityId(getEntityId());
metrics.setTimeBucket(toTimeBucketInMonth());
metrics.setSourceServiceId(getSourceServiceId());
metrics.setDestServiceId(getDestServiceId());
metrics.setComponentId(getComponentId());
return metrics;
}
@Override public int remoteHashCode() {
@ -138,33 +138,33 @@ public class ServiceRelationClientSideIndicator extends Indicator {
if (getClass() != obj.getClass())
return false;
ServiceRelationClientSideIndicator indicator = (ServiceRelationClientSideIndicator)obj;
if (sourceServiceId != indicator.sourceServiceId)
ServiceRelationClientSideMetrics metrics = (ServiceRelationClientSideMetrics)obj;
if (sourceServiceId != metrics.sourceServiceId)
return false;
if (destServiceId != indicator.destServiceId)
if (destServiceId != metrics.destServiceId)
return false;
if (componentId != indicator.componentId)
if (componentId != metrics.componentId)
return false;
if (getTimeBucket() != indicator.getTimeBucket())
if (getTimeBucket() != metrics.getTimeBucket())
return false;
return true;
}
public static class Builder implements StorageBuilder<ServiceRelationClientSideIndicator> {
public static class Builder implements StorageBuilder<ServiceRelationClientSideMetrics> {
@Override public ServiceRelationClientSideIndicator map2Data(Map<String, Object> dbMap) {
ServiceRelationClientSideIndicator indicator = new ServiceRelationClientSideIndicator();
indicator.setSourceServiceId(((Number)dbMap.get(SOURCE_SERVICE_ID)).intValue());
indicator.setDestServiceId(((Number)dbMap.get(DEST_SERVICE_ID)).intValue());
indicator.setComponentId(((Number)dbMap.get(COMPONENT_ID)).intValue());
indicator.setTimeBucket(((Number)dbMap.get(TIME_BUCKET)).longValue());
indicator.setEntityId((String)dbMap.get(ENTITY_ID));
return indicator;
@Override public ServiceRelationClientSideMetrics map2Data(Map<String, Object> dbMap) {
ServiceRelationClientSideMetrics metrics = new ServiceRelationClientSideMetrics();
metrics.setSourceServiceId(((Number)dbMap.get(SOURCE_SERVICE_ID)).intValue());
metrics.setDestServiceId(((Number)dbMap.get(DEST_SERVICE_ID)).intValue());
metrics.setComponentId(((Number)dbMap.get(COMPONENT_ID)).intValue());
metrics.setTimeBucket(((Number)dbMap.get(TIME_BUCKET)).longValue());
metrics.setEntityId((String)dbMap.get(ENTITY_ID));
return metrics;
}
@Override public Map<String, Object> data2Map(ServiceRelationClientSideIndicator storageData) {
@Override public Map<String, Object> data2Map(ServiceRelationClientSideMetrics storageData) {
Map<String, Object> map = new HashMap<>();
map.put(TIME_BUCKET, storageData.getTimeBucket());
map.put(SOURCE_SERVICE_ID, storageData.getSourceServiceId());

View File

@ -21,19 +21,19 @@ package org.apache.skywalking.oap.server.core.analysis.manual.servicerelation;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
@IndicatorType
@MetricsType
@StreamData
@StorageEntity(name = ServiceRelationServerSideIndicator.INDEX_NAME, builder = ServiceRelationServerSideIndicator.Builder.class,
@StorageEntity(name = ServiceRelationServerSideMetrics.INDEX_NAME, builder = ServiceRelationServerSideMetrics.Builder.class,
sourceScopeId = DefaultScopeDefine.SERVICE_RELATION)
public class ServiceRelationServerSideIndicator extends Indicator {
public class ServiceRelationServerSideMetrics extends Metrics {
public static final String INDEX_NAME = "service_relation_server_side";
public static final String SOURCE_SERVICE_ID = "source_service_id";
@ -53,7 +53,7 @@ public class ServiceRelationServerSideIndicator extends Indicator {
return splitJointId;
}
@Override public void combine(Indicator indicator) {
@Override public void combine(Metrics metrics) {
}
@ -61,34 +61,34 @@ public class ServiceRelationServerSideIndicator extends Indicator {
}
@Override public Indicator toHour() {
ServiceRelationServerSideIndicator indicator = new ServiceRelationServerSideIndicator();
indicator.setTimeBucket(toTimeBucketInHour());
indicator.setSourceServiceId(getSourceServiceId());
indicator.setDestServiceId(getDestServiceId());
indicator.setComponentId(getComponentId());
indicator.setEntityId(getEntityId());
return indicator;
@Override public Metrics toHour() {
ServiceRelationServerSideMetrics metrics = new ServiceRelationServerSideMetrics();
metrics.setTimeBucket(toTimeBucketInHour());
metrics.setSourceServiceId(getSourceServiceId());
metrics.setDestServiceId(getDestServiceId());
metrics.setComponentId(getComponentId());
metrics.setEntityId(getEntityId());
return metrics;
}
@Override public Indicator toDay() {
ServiceRelationServerSideIndicator indicator = new ServiceRelationServerSideIndicator();
indicator.setTimeBucket(toTimeBucketInDay());
indicator.setSourceServiceId(getSourceServiceId());
indicator.setDestServiceId(getDestServiceId());
indicator.setComponentId(getComponentId());
indicator.setEntityId(getEntityId());
return indicator;
@Override public Metrics toDay() {
ServiceRelationServerSideMetrics metrics = new ServiceRelationServerSideMetrics();
metrics.setTimeBucket(toTimeBucketInDay());
metrics.setSourceServiceId(getSourceServiceId());
metrics.setDestServiceId(getDestServiceId());
metrics.setComponentId(getComponentId());
metrics.setEntityId(getEntityId());
return metrics;
}
@Override public Indicator toMonth() {
ServiceRelationServerSideIndicator indicator = new ServiceRelationServerSideIndicator();
indicator.setTimeBucket(toTimeBucketInMonth());
indicator.setSourceServiceId(getSourceServiceId());
indicator.setDestServiceId(getDestServiceId());
indicator.setComponentId(getComponentId());
indicator.setEntityId(getEntityId());
return indicator;
@Override public Metrics toMonth() {
ServiceRelationServerSideMetrics metrics = new ServiceRelationServerSideMetrics();
metrics.setTimeBucket(toTimeBucketInMonth());
metrics.setSourceServiceId(getSourceServiceId());
metrics.setDestServiceId(getDestServiceId());
metrics.setComponentId(getComponentId());
metrics.setEntityId(getEntityId());
return metrics;
}
@Override public int remoteHashCode() {
@ -139,33 +139,33 @@ public class ServiceRelationServerSideIndicator extends Indicator {
if (getClass() != obj.getClass())
return false;
ServiceRelationServerSideIndicator indicator = (ServiceRelationServerSideIndicator)obj;
if (sourceServiceId != indicator.sourceServiceId)
ServiceRelationServerSideMetrics metrics = (ServiceRelationServerSideMetrics)obj;
if (sourceServiceId != metrics.sourceServiceId)
return false;
if (destServiceId != indicator.destServiceId)
if (destServiceId != metrics.destServiceId)
return false;
if (componentId != indicator.componentId)
if (componentId != metrics.componentId)
return false;
if (getTimeBucket() != indicator.getTimeBucket())
if (getTimeBucket() != metrics.getTimeBucket())
return false;
return true;
}
public static class Builder implements StorageBuilder<ServiceRelationServerSideIndicator> {
public static class Builder implements StorageBuilder<ServiceRelationServerSideMetrics> {
@Override public ServiceRelationServerSideIndicator map2Data(Map<String, Object> dbMap) {
ServiceRelationServerSideIndicator indicator = new ServiceRelationServerSideIndicator();
indicator.setEntityId((String)dbMap.get(ENTITY_ID));
indicator.setSourceServiceId(((Number)dbMap.get(SOURCE_SERVICE_ID)).intValue());
indicator.setDestServiceId(((Number)dbMap.get(DEST_SERVICE_ID)).intValue());
indicator.setComponentId(((Number)dbMap.get(COMPONENT_ID)).intValue());
indicator.setTimeBucket(((Number)dbMap.get(TIME_BUCKET)).longValue());
return indicator;
@Override public ServiceRelationServerSideMetrics map2Data(Map<String, Object> dbMap) {
ServiceRelationServerSideMetrics metrics = new ServiceRelationServerSideMetrics();
metrics.setEntityId((String)dbMap.get(ENTITY_ID));
metrics.setSourceServiceId(((Number)dbMap.get(SOURCE_SERVICE_ID)).intValue());
metrics.setDestServiceId(((Number)dbMap.get(DEST_SERVICE_ID)).intValue());
metrics.setComponentId(((Number)dbMap.get(COMPONENT_ID)).intValue());
metrics.setTimeBucket(((Number)dbMap.get(TIME_BUCKET)).longValue());
return metrics;
}
@Override public Map<String, Object> data2Map(ServiceRelationServerSideIndicator storageData) {
@Override public Map<String, Object> data2Map(ServiceRelationServerSideMetrics storageData) {
Map<String, Object> map = new HashMap<>();
map.put(ENTITY_ID, storageData.getEntityId());
map.put(SOURCE_SERVICE_ID, storageData.getSourceServiceId());

View File

@ -16,18 +16,18 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.indicator;
package org.apache.skywalking.oap.server.core.analysis.metrics;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*;
import org.apache.skywalking.oap.server.core.query.sql.Function;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
/**
* @author wusheng
*/
@IndicatorFunction(functionName = "cpm")
public abstract class CPMIndicator extends Indicator implements LongValueHolder {
@MetricsFunction(functionName = "cpm")
public abstract class CPMMetrics extends Metrics implements LongValueHolder {
protected static final String VALUE = "value";
protected static final String TOTAL = "total";
@ -40,9 +40,9 @@ public abstract class CPMIndicator extends Indicator implements LongValueHolder
this.total += count;
}
@Override public final void combine(Indicator indicator) {
CPMIndicator countIndicator = (CPMIndicator)indicator;
combine(countIndicator.total);
@Override public final void combine(Metrics metrics) {
CPMMetrics cpmMetrics = (CPMMetrics)metrics;
combine(cpmMetrics.total);
}
@Override public void calculate() {

View File

@ -16,18 +16,18 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.indicator;
package org.apache.skywalking.oap.server.core.analysis.metrics;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*;
import org.apache.skywalking.oap.server.core.query.sql.Function;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
/**
* @author peng-yongsheng
*/
@IndicatorFunction(functionName = "count")
public abstract class CountIndicator extends Indicator implements LongValueHolder {
@MetricsFunction(functionName = "count")
public abstract class CountMetrics extends Metrics implements LongValueHolder {
protected static final String VALUE = "value";
@ -38,9 +38,9 @@ public abstract class CountIndicator extends Indicator implements LongValueHolde
this.value += count;
}
@Override public final void combine(Indicator indicator) {
CountIndicator countIndicator = (CountIndicator)indicator;
combine(countIndicator.value);
@Override public final void combine(Metrics metrics) {
CountMetrics countMetrics = (CountMetrics)metrics;
combine(countMetrics.value);
}
@Override public void calculate() {

View File

@ -16,18 +16,18 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.indicator;
package org.apache.skywalking.oap.server.core.analysis.metrics;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*;
import org.apache.skywalking.oap.server.core.query.sql.Function;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
/**
* @author peng-yongsheng
*/
@IndicatorFunction(functionName = "doubleAvg")
public abstract class DoubleAvgIndicator extends Indicator implements DoubleValueHolder {
@MetricsFunction(functionName = "doubleAvg")
public abstract class DoubleAvgMetrics extends Metrics implements DoubleValueHolder {
protected static final String SUMMATION = "summation";
protected static final String COUNT = "count";
@ -43,9 +43,9 @@ public abstract class DoubleAvgIndicator extends Indicator implements DoubleValu
this.count += count;
}
@Override public final void combine(Indicator indicator) {
DoubleAvgIndicator avgIndicator = (DoubleAvgIndicator)indicator;
combine(avgIndicator.summation, avgIndicator.count);
@Override public final void combine(Metrics metrics) {
DoubleAvgMetrics doubleAvgMetrics = (DoubleAvgMetrics)metrics;
combine(doubleAvgMetrics.summation, doubleAvgMetrics.count);
}
@Override public final void calculate() {

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.indicator;
package org.apache.skywalking.oap.server.core.analysis.metrics;
/**
* DoubleValueHolder always holds a value of double.

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.indicator;
package org.apache.skywalking.oap.server.core.analysis.metrics;
import java.util.Objects;
import lombok.*;

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.indicator;
package org.apache.skywalking.oap.server.core.analysis.metrics;
import java.util.ArrayList;
import org.apache.skywalking.oap.server.core.Const;

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.indicator;
package org.apache.skywalking.oap.server.core.analysis.metrics;
/**
* IntValueHolder always holds a value of int.

View File

@ -16,18 +16,18 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.indicator;
package org.apache.skywalking.oap.server.core.analysis.metrics;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*;
import org.apache.skywalking.oap.server.core.query.sql.Function;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
/**
* @author peng-yongsheng
*/
@IndicatorFunction(functionName = "longAvg")
public abstract class LongAvgIndicator extends Indicator implements LongValueHolder {
@MetricsFunction(functionName = "longAvg")
public abstract class LongAvgMetrics extends Metrics implements LongValueHolder {
protected static final String SUMMATION = "summation";
protected static final String COUNT = "count";
@ -43,9 +43,9 @@ public abstract class LongAvgIndicator extends Indicator implements LongValueHol
this.count += count;
}
@Override public final void combine(Indicator indicator) {
LongAvgIndicator avgIndicator = (LongAvgIndicator)indicator;
combine(avgIndicator.summation, avgIndicator.count);
@Override public final void combine(Metrics metrics) {
LongAvgMetrics longAvgMetrics = (LongAvgMetrics)metrics;
combine(longAvgMetrics.summation, longAvgMetrics.count);
}
@Override public final void calculate() {

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.indicator;
package org.apache.skywalking.oap.server.core.analysis.metrics;
/**
* LongValueHolder always holds a value of long.

View File

@ -16,17 +16,17 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.indicator;
package org.apache.skywalking.oap.server.core.analysis.metrics;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
/**
* @author wusheng
*/
@IndicatorFunction(functionName = "maxDouble")
public abstract class MaxDoubleIndicator extends Indicator implements DoubleValueHolder {
@MetricsFunction(functionName = "maxDouble")
public abstract class MaxDoubleMetrics extends Metrics implements DoubleValueHolder {
protected static final String VALUE = "value";
@ -39,9 +39,9 @@ public abstract class MaxDoubleIndicator extends Indicator implements DoubleValu
}
}
@Override public final void combine(Indicator indicator) {
MaxDoubleIndicator countIndicator = (MaxDoubleIndicator)indicator;
combine(countIndicator.value);
@Override public final void combine(Metrics metrics) {
MaxDoubleMetrics maxDoubleMetrics = (MaxDoubleMetrics)metrics;
combine(maxDoubleMetrics.value);
}
@Override public void calculate() {

View File

@ -16,17 +16,17 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.indicator;
package org.apache.skywalking.oap.server.core.analysis.metrics;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*;
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
/**
* @author liuhaoyang
**/
@IndicatorFunction(functionName = "max")
public abstract class MaxLongIndicator extends Indicator implements LongValueHolder {
@MetricsFunction(functionName = "max")
public abstract class MaxLongMetrics extends Metrics implements LongValueHolder {
protected static final String VALUE = "value";
@ -39,9 +39,9 @@ public abstract class MaxLongIndicator extends Indicator implements LongValueHol
}
}
@Override public final void combine(Indicator indicator) {
MaxLongIndicator countIndicator = (MaxLongIndicator)indicator;
combine(countIndicator.value);
@Override public final void combine(Metrics metrics) {
MaxLongMetrics maxLongMetrics = (MaxLongMetrics)metrics;
combine(maxLongMetrics.value);
}
@Override public void calculate() {

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.indicator;
package org.apache.skywalking.oap.server.core.analysis.metrics;
import lombok.*;
import org.apache.skywalking.oap.server.core.remote.data.StreamData;
@ -27,7 +27,7 @@ import org.joda.time.format.*;
/**
* @author peng-yongsheng
*/
public abstract class Indicator extends StreamData implements StorageData {
public abstract class Metrics extends StreamData implements StorageData {
private static DateTimeFormatter TIME_BUCKET_MONTH_FORMATTER = DateTimeFormat.forPattern("yyyyMM");
@ -38,15 +38,15 @@ public abstract class Indicator extends StreamData implements StorageData {
public abstract String id();
public abstract void combine(Indicator indicator);
public abstract void combine(Metrics metrics);
public abstract void calculate();
public abstract Indicator toHour();
public abstract Metrics toHour();
public abstract Indicator toDay();
public abstract Metrics toDay();
public abstract Indicator toMonth();
public abstract Metrics toMonth();
public long toTimeBucketInHour() {
if (isMinuteBucket()) {

Some files were not shown because too many files have changed in this diff Show More