Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]feat(home): measure api #222

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions server/apm/apm-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>io.holoinsight.server</groupId>
<artifactId>common-service</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
*/
package io.holoinsight.server.apm.common.model.query;

import io.holoinsight.server.common.service.Measurable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.ArrayList;
Expand All @@ -18,7 +20,7 @@
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BasicTrace implements Serializable {
public class BasicTrace implements Serializable, Measurable {

private static final long serialVersionUID = -4060937279918402711L;
private String segmentId;
Expand All @@ -29,4 +31,12 @@ public class BasicTrace implements Serializable {
private long start;
private boolean isError;
private List<String> traceIds = new ArrayList<>();

@Override
public long measure() {
if (CollectionUtils.isEmpty(traceIds)) {
return 0;
}
return this.traceIds.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,28 @@
*/
package io.holoinsight.server.apm.common.model.query;

import io.holoinsight.server.common.service.Measurable;
import lombok.Getter;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Getter
public class Topology {
public class Topology implements Measurable {
private final List<Node> nodes;
private final List<Call> calls;

public Topology() {
this.nodes = new ArrayList<>();
this.calls = new ArrayList<>();
}

@Override
public long measure() {
if (CollectionUtils.isEmpty(calls)) {
return 0;
}
return this.calls.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
*/
package io.holoinsight.server.apm.common.model.query;

import io.holoinsight.server.common.service.Measurable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.ArrayList;
Expand All @@ -18,8 +20,20 @@
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TraceBrief implements Serializable {
public class TraceBrief implements Serializable, Measurable {

private static final long serialVersionUID = -5452437207833607799L;
private List<BasicTrace> traces = new ArrayList<>();

@Override
public long measure() {
if (CollectionUtils.isEmpty(traces)) {
return 0;
}
long result = 0;
for (BasicTrace basicTrace : traces) {
result += basicTrace.measure();
}
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
*/
package io.holoinsight.server.apm.common.model.specification.sw;

import io.holoinsight.server.common.service.Measurable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.ArrayList;
Expand All @@ -18,12 +20,20 @@
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Trace implements Serializable {
public class Trace implements Serializable, Measurable {

private static final long serialVersionUID = 3436393920339302223L;

/**
* span 列表
*/
private List<Span> spans = new ArrayList<>();

@Override
public long measure() {
if (CollectionUtils.isEmpty(spans)) {
return 0;
}
return this.spans.size();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0.
*/
package io.holoinsight.server.common.service;

/**
* Measure the data
*
* @author masaimu
* @version 2023-03-10 16:38:00
*/
public interface Measurable {

/**
* @return data size
*/
long measure();
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public class AlertTaskScheduler {

public void start() {
try {
StdSchedulerFactory stdSchedulerFactory = new StdSchedulerFactory(getScheduleProperties());
StdSchedulerFactory stdSchedulerFactory =
new StdSchedulerFactory(getScheduleProperties("AlertTaskScheduler"));
Scheduler scheduler = stdSchedulerFactory.getScheduler();

// 创建需要执行的任务
Expand All @@ -73,9 +74,9 @@ public void start() {
}
}

private Properties getScheduleProperties() {
public static Properties getScheduleProperties(String instanceName) {
Properties properties = new Properties();
properties.setProperty("org.quartz.scheduler.instanceName", "AlertTaskScheduler");
properties.setProperty("org.quartz.scheduler.instanceName", instanceName);
properties.setProperty("org.quartz.threadPool.threadCount", "1");
properties.setProperty("org.quartz.jobStore.class", "org.quartz.simpl.RAMJobStore");
properties.setProperty("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
*/
package io.holoinsight.server.home.common.service.query;

import io.holoinsight.server.common.service.Measurable;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.List;

Expand All @@ -12,8 +14,16 @@
* @date 2022/4/29 11:23 上午
*/
@Data
public class KeyResult {
public class KeyResult implements Measurable {

private String metric;
private List<String> tags;

@Override
public long measure() {
if (CollectionUtils.isEmpty(tags)) {
return 0;
}
return tags.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,28 @@
*/
package io.holoinsight.server.home.common.service.query;

import io.holoinsight.server.common.service.Measurable;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Data
public class QueryResponse {
public class QueryResponse implements Measurable {

private List<Result> results;

@Override
public long measure() {
if (CollectionUtils.isEmpty(results)) {
return 0;
}
long size = 0;
if (!CollectionUtils.isEmpty(results)) {
for (Result result : results) {
size += result.measure();
}
}
return size;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,25 @@
*/
package io.holoinsight.server.home.common.service.query;

import io.holoinsight.server.common.service.Measurable;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Map;

@Data
public class Result {
public class Result implements Measurable {

private String metric;
private Map<String, String> tags;
private List<Object[]> values;

@Override
public long measure() {
if (CollectionUtils.isEmpty(values)) {
return 0;
}
return values.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
*/
package io.holoinsight.server.home.common.service.query;

import io.holoinsight.server.common.service.Measurable;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.List;

Expand All @@ -12,7 +14,15 @@
* @date 2022/8/16 5:33 下午
*/
@Data
public class ValueResult {
public class ValueResult implements Measurable {
private String tag;
private List<String> values;

@Override
public long measure() {
if (CollectionUtils.isEmpty(values)) {
return 0;
}
return values.size();
}
}
5 changes: 5 additions & 0 deletions server/home/home-facade/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<artifactId>home-proto</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>common-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.devh</groupId>
<artifactId>grpc-client-spring-boot-starter</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
*/
package io.holoinsight.server.home.facade.page;

import io.holoinsight.server.common.service.Measurable;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.List;
Expand All @@ -14,7 +16,7 @@
* @version 1.0: PageRequest.java, v 0.1 2022年03月21日 3:11 下午 jinsong.yjs Exp $
*/
@Data
public class MonitorPageResult<T> implements Serializable {
public class MonitorPageResult<T> implements Serializable, Measurable {
private static final long serialVersionUID = -8352196951709213541L;

private int pageNum = 1;
Expand All @@ -26,4 +28,19 @@ public class MonitorPageResult<T> implements Serializable {

private List<T> items;

@Override
public long measure() {
if (CollectionUtils.isEmpty(items)) {
return 0;
}
long size = 0;
for (T item : items) {
if (item instanceof Measurable) {
size += ((Measurable) item).measure();
} else {
size += 1;
}
}
return size;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
*
* @author jsy1001de
* @version 1.0: MonitorAccessConfig.java, v 0.1 2022年06月10日 3:56 下午 jinsong.yjs Exp $
* @version 1.0: MonitorAccessConfig.java, v 0.1 2022-06-10 15:56 jinsong.yjs Exp $
*/
@Data
public class MonitorAccessConfig {
Expand All @@ -30,30 +30,35 @@ public class MonitorAccessConfig {
private Boolean online;

/**
* 是否允许访问所有指标
* allow all metric access permission
*/
private boolean accessAll = false;
/**
* 允许访问的指标列表
* allow metric list
*/
private Set<String> accessRange = new HashSet<>();
/**
* 单机QPS, -1代表不限,0代表黑名单, 其他代表正常限流
* server QPS, -1: no limit,0: in black list, other: normal flow limie policy
*/
private long metricQps = -1L;
private long metaQps = -1L;
/**
* 用户限流信息
* flow limit configuration
*/
private Map<String, Long> userRate = new HashMap<>();

/**
* 一次查询指标中最多数据点
* metric query upper limit
*/
private long dpsLimit = GatewayConstants.WEB_QUERY_DEFAULT_DPS_LIMIT;
/**
* 一次查询维度中最多的Tags
* tags query upper limit
*/
private long tagsLimit = GatewayConstants.QUERY_DEFAULT_TAGS_LIMIT;

/**
* market plugin id
*/
private Long marketPluginId;;

}
Loading