Skip to content

Commit

Permalink
[pinpoint-apm#9254] Collects and retrieves URL statistics using Pinot
Browse files Browse the repository at this point in the history
  • Loading branch information
ga-ram committed Oct 11, 2022
1 parent 6454e6e commit bff5f34
Show file tree
Hide file tree
Showing 59 changed files with 1,454 additions and 1,014 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ public AgentUriStatBo map(final PAgentUriStat agentUriStat) {

final String agentId = agentInfo.getAgentId();
final long startTimestamp = agentInfo.getAgentStartTime();
final String applicationName = agentInfo.getApplicationName();

long timestamp = agentUriStat.getTimestamp();
int bucketVersion = agentUriStat.getBucketVersion();

AgentUriStatBo agentUriStatBo = new AgentUriStatBo();
agentUriStatBo.setServiceName(""); // TODO: add serviceName when available
agentUriStatBo.setApplicationName(applicationName);
agentUriStatBo.setAgentId(agentId);
agentUriStatBo.setStartTimestamp(startTimestamp);
agentUriStatBo.setTimestamp(timestamp);
Expand Down Expand Up @@ -82,7 +85,7 @@ private UriStatHistogram convertUriStatHistogram(PUriHistogram pUriHistogram) {
return null;
}

double avg = pUriHistogram.getAvg();
long total = pUriHistogram.getTotal();
long max = pUriHistogram.getMax();

int histogramCount = pUriHistogram.getHistogramCount();
Expand All @@ -95,7 +98,7 @@ private UriStatHistogram convertUriStatHistogram(PUriHistogram pUriHistogram) {

UriStatHistogram uriStatHistogram = new UriStatHistogram();
uriStatHistogram.setCount(count);
uriStatHistogram.setAvg(avg);
uriStatHistogram.setTotal(total);
uriStatHistogram.setMax(max);
uriStatHistogram.setTimestampHistogram(histogram);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,17 @@

package com.navercorp.pinpoint.collector.service;

import com.navercorp.pinpoint.collector.dao.hbase.HbaseAgentUriStatDao;
import com.navercorp.pinpoint.common.server.bo.stat.AgentUriStatBo;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
* @author Taejin Koo
*/
@Service("hBaseAgentUriStatService")
public class HBaseAgentUriStatService implements AgentUriStatService {

private final HbaseAgentUriStatDao hbaseAgentUriStatDao;

public HBaseAgentUriStatService(HbaseAgentUriStatDao hbaseAgentUriStatDao) {
this.hbaseAgentUriStatDao = Objects.requireNonNull(hbaseAgentUriStatDao, "hbaseAgentUriStatDao");
}

@ConditionalOnMissingBean(value = AgentUriStatService.class, ignored = EmptyAgentUriStatService.class)
@Service
public class EmptyAgentUriStatService implements AgentUriStatService {
@Override
public void save(AgentUriStatBo agentUriStatBo) {
hbaseAgentUriStatDao.insert(agentUriStatBo);
}

public void save(AgentUriStatBo agentUriStatBo) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public void encodeValues(Buffer valueBuffer, List<AgentUriStatBo> agentUriStatBo
public List<AgentUriStatBo> decodeValues(Buffer valueBuffer, AgentStatDecodingContext decodingContext) {
AgentUriStatBo agentUriStatBo = new AgentUriStatBo();

final String serviceName = decodingContext.getServiceName();
agentUriStatBo.setServiceName(serviceName);

final String applicationName = decodingContext.getApplicationName();
agentUriStatBo.setApplicationName(applicationName);

final String agentId = decodingContext.getAgentId();
agentUriStatBo.setAgentId(agentId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.UnsignedLongEncodingStrategy;
import com.navercorp.pinpoint.common.server.bo.codec.strategy.EncodingStrategy;
import com.navercorp.pinpoint.common.server.bo.serializer.stat.AgentStatDecodingContext;
import com.navercorp.pinpoint.common.server.bo.serializer.stat.AgentStatUtils;
import com.navercorp.pinpoint.common.server.bo.stat.EachUriStatBo;
import com.navercorp.pinpoint.common.server.bo.stat.UriStatHistogram;

Expand Down Expand Up @@ -94,7 +93,7 @@ private static class EachUriStatBoCodecEncoder implements AgentStatCodec.CodecEn
private final UnsignedIntegerEncodingStrategy.Analyzer.Builder histogramCountAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();

private final UnsignedIntegerEncodingStrategy.Analyzer.Builder countAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
private final UnsignedLongEncodingStrategy.Analyzer.Builder avgAnalyzerBuilder = new UnsignedLongEncodingStrategy.Analyzer.Builder();
private final UnsignedLongEncodingStrategy.Analyzer.Builder totalAnalyzerBuilder = new UnsignedLongEncodingStrategy.Analyzer.Builder();
private final UnsignedLongEncodingStrategy.Analyzer.Builder maxAnalyzerBuilder = new UnsignedLongEncodingStrategy.Analyzer.Builder();

private final UnsignedIntegerEncodingStrategy.Analyzer.Builder under100BucketCountAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
Expand Down Expand Up @@ -128,7 +127,7 @@ private void addValue(UriStatHistogram uriStatHistogram) {
return;
}
countAnalyzerBuilder.addValue(uriStatHistogram.getCount());
avgAnalyzerBuilder.addValue(AgentStatUtils.convertDoubleToLong(uriStatHistogram.getAvg()));
totalAnalyzerBuilder.addValue(uriStatHistogram.getTotal());
maxAnalyzerBuilder.addValue(uriStatHistogram.getMax());

int[] timestampHistogram = uriStatHistogram.getTimestampHistogram();
Expand Down Expand Up @@ -172,7 +171,7 @@ private List<StrategyAnalyzer> getAnalyzerList() {
strategyAnalyzerList.add(histogramCountAnalyzerBuilder.build());

strategyAnalyzerList.add(countAnalyzerBuilder.build());
strategyAnalyzerList.add(avgAnalyzerBuilder.build());
strategyAnalyzerList.add(totalAnalyzerBuilder.build());
strategyAnalyzerList.add(maxAnalyzerBuilder.build());

strategyAnalyzerList.add(under100BucketCountAnalyzerBuilder.build());
Expand Down Expand Up @@ -218,7 +217,7 @@ public void decode(Buffer valueBuffer, AgentStatHeaderDecoder headerDecoder, int

private Queue<UriStatHistogram> decodeUriStatHistogramList(Buffer valueBuffer, AgentStatHeaderDecoder headerDecoder, int valueSize) {
EncodingStrategy<Integer> countAnalyzerEncodingStrategy = UnsignedIntegerEncodingStrategy.getFromCode(headerDecoder.getCode());
EncodingStrategy<Long> avgAnalyzerEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
EncodingStrategy<Long> totalAnalyzerEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
EncodingStrategy<Long> maxAnalyzerEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());

EncodingStrategy<Integer> under100BucketCountAnalyzerEncodingStrategy = UnsignedIntegerEncodingStrategy.getFromCode(headerDecoder.getCode());
Expand All @@ -231,7 +230,7 @@ private Queue<UriStatHistogram> decodeUriStatHistogramList(Buffer valueBuffer, A
EncodingStrategy<Integer> over8000BucketCountAnalyzerEncodingStrategy = UnsignedIntegerEncodingStrategy.getFromCode(headerDecoder.getCode());

List<Integer> countList = this.codec.decodeValues(valueBuffer, countAnalyzerEncodingStrategy, valueSize);
List<Long> avgList = this.codec.decodeValues(valueBuffer, avgAnalyzerEncodingStrategy, valueSize);
List<Long> totalList = this.codec.decodeValues(valueBuffer, totalAnalyzerEncodingStrategy, valueSize);
List<Long> maxList = this.codec.decodeValues(valueBuffer, maxAnalyzerEncodingStrategy, valueSize);

List<Integer> under100BucketCountList = this.codec.decodeValues(valueBuffer, under100BucketCountAnalyzerEncodingStrategy, valueSize);
Expand All @@ -249,8 +248,8 @@ private Queue<UriStatHistogram> decodeUriStatHistogramList(Buffer valueBuffer, A
final Integer count = countList.get(i);
uriStatHistogram.setCount(count);

final Long avg = avgList.get(i);
uriStatHistogram.setAvg(AgentStatUtils.convertLongToDouble(avg));
final Long total = totalList.get(i);
uriStatHistogram.setTotal(total);

final Long max = maxList.get(i);
uriStatHistogram.setMax(max);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,24 @@
*/
public class AgentStatDecodingContext {

private String serviceName;

private String applicationName;

private String agentId;

private long baseTimestamp;

private long timestampDelta;

public String getServiceName() { return serviceName; }

public void setServiceName(String serviceName) { this.serviceName = serviceName; }

public String getApplicationName() { return applicationName; }

public void setApplicationName(String applicationName) { this.applicationName = applicationName; }

public String getAgentId() {
return agentId;
}
Expand All @@ -50,4 +62,5 @@ public long getTimestampDelta() {
public void setTimestampDelta(long timestampDelta) {
this.timestampDelta = timestampDelta;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,22 @@
* @author Taejin Koo
*/
public class AgentUriStatBo implements AgentStatDataPoint {

private String serviceName;
private String applicationName;
private String agentId;
private long startTimestamp;

private long timestamp;
private byte bucketVersion;

private List<EachUriStatBo> eachUriStatBoList = new ArrayList<>();

public String getServiceName() { return serviceName; }

public void setServiceName(String serviceName) { this.serviceName = serviceName; }

public String getApplicationName() { return applicationName; }

public void setApplicationName(String applicationName) { this.applicationName = applicationName; }

@Override
public String getAgentId() {
return agentId;
Expand Down Expand Up @@ -103,6 +110,8 @@ public boolean equals(Object o) {

AgentUriStatBo that = (AgentUriStatBo) o;

if (serviceName != null? !serviceName.equals(that.serviceName) : that.serviceName != null) return false;
if (applicationName != null? !applicationName.equals(that.applicationName) : that.applicationName != null) return false;
if (startTimestamp != that.startTimestamp) return false;
if (timestamp != that.timestamp) return false;
if (bucketVersion != that.bucketVersion) return false;
Expand All @@ -112,7 +121,9 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
int result = agentId != null ? agentId.hashCode() : 0;
int result = serviceName != null ? serviceName.hashCode() : 0;
result = 31 * result + (applicationName != null ? applicationName.hashCode() : 0);
result = 31 * result + (agentId != null ? agentId.hashCode() : 0);
result = 31 * result + (int) (startTimestamp ^ (startTimestamp >>> 32));
result = 31 * result + (int) (timestamp ^ (timestamp >>> 32));
result = 31 * result + (int) bucketVersion;
Expand All @@ -123,7 +134,9 @@ public int hashCode() {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("AgentUriStatBo{");
sb.append("agentId='").append(agentId).append('\'');
sb.append("serviceName='").append(serviceName).append('\'');
sb.append(", applicationName=").append(applicationName);
sb.append(", agentId='").append(agentId).append('\'');
sb.append(", startTimestamp=").append(startTimestamp);
sb.append(", timestamp=").append(timestamp);
sb.append(", bucketVersion=").append(bucketVersion);
Expand Down
Loading

0 comments on commit bff5f34

Please sign in to comment.