Skip to content

[#12195] Add new agent list using uid #12249

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

Merged
merged 1 commit into from
May 20, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
try {
// agent info
final AgentInfoBo agentInfoBo = this.agentInfoBoMapper.map(agentInfo, header);
this.agentInfoService.insert(agentInfoBo);
this.agentInfoService.insert(header.getServiceUid(), header.getApplicationUid(), agentInfoBo);

Check warning on line 94 in collector/src/main/java/com/navercorp/pinpoint/collector/handler/grpc/GrpcAgentInfoHandler.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/handler/grpc/GrpcAgentInfoHandler.java#L94

Added line #L94 was not covered by tests
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling insert with ServiceUid and ApplicationUid directly does not match the updated method signature expecting Suppliers. Wrap these calls in Supplier lambdas or update the service method signature.

Suggested change
this.agentInfoService.insert(header.getServiceUid(), header.getApplicationUid(), agentInfoBo);
this.agentInfoService.insert(() -> header.getServiceUid(), () -> header.getApplicationUid(), agentInfoBo);

Copilot uses AI. Check for mistakes.

return PResult.newBuilder().setSuccess(true).build();
} catch (Exception e) {
logger.warn("Failed to handle. agentInfo={}", MessageFormatUtils.debugLog(agentInfo), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,24 @@

import com.navercorp.pinpoint.collector.dao.AgentInfoDao;
import com.navercorp.pinpoint.collector.dao.ApplicationIndexDao;
import com.navercorp.pinpoint.collector.uid.dao.AgentNameDao;
import com.navercorp.pinpoint.collector.uid.service.ApplicationUidService;
import com.navercorp.pinpoint.common.server.bo.AgentInfoBo;
import com.navercorp.pinpoint.common.server.uid.ApplicationUid;
import com.navercorp.pinpoint.common.server.uid.ServiceUid;
import com.navercorp.pinpoint.io.request.UidException;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.PositiveOrZero;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.Objects;
import java.util.Optional;
import java.util.function.Supplier;

/**
* @author emeroad
Expand All @@ -35,19 +45,59 @@
@Service
@Validated
public class AgentInfoService {
private final Logger logger = LogManager.getLogger(this.getClass());

Check warning on line 48 in collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java#L48

Added line #L48 was not covered by tests

private final AgentInfoDao agentInfoDao;

private final ApplicationIndexDao applicationIndexDao;

public AgentInfoService(AgentInfoDao agentInfoDao, ApplicationIndexDao applicationIndexDao) {
private final ApplicationUidService applicationUidService;
private final AgentNameDao agentNameDao;

private final boolean uidAgentListEnable;

public AgentInfoService(AgentInfoDao agentInfoDao, ApplicationIndexDao applicationIndexDao,
ApplicationUidService applicationUidService, Optional<AgentNameDao> agentNameDao,
@Value("${pinpoint.collector.application.uid.agent.list.enable:false}") boolean uidAgentListEnable) {

Check warning on line 60 in collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java#L60

Added line #L60 was not covered by tests
this.agentInfoDao = Objects.requireNonNull(agentInfoDao, "agentInfoDao");
this.applicationIndexDao = Objects.requireNonNull(applicationIndexDao, "applicationIndexDao");
this.applicationUidService = Objects.requireNonNull(applicationUidService, "applicationUidService");
this.agentNameDao = agentNameDao.orElse(null);
this.uidAgentListEnable = uidAgentListEnable;

Check warning on line 65 in collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java#L63-L65

Added lines #L63 - L65 were not covered by tests
}

public void insert(@Valid final AgentInfoBo agentInfoBo) {
public void insert(Supplier<ServiceUid> serviceUidSupplier, Supplier<ApplicationUid> applicationUidSupplier, @Valid final AgentInfoBo agentInfoBo) {
agentInfoDao.insert(agentInfoBo);
applicationIndexDao.insert(agentInfoBo);
uidAgentListInsert(serviceUidSupplier, applicationUidSupplier, agentInfoBo);
}

Check warning on line 72 in collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java#L71-L72

Added lines #L71 - L72 were not covered by tests

private void uidAgentListInsert(Supplier<ServiceUid> serviceUidSupplier, Supplier<ApplicationUid> applicationUidSupplier, AgentInfoBo agentInfoBo) {
if (!uidAgentListEnable || agentNameDao == null) {
return;

Check warning on line 76 in collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java#L76

Added line #L76 was not covered by tests
}
ServiceUid serviceUid = serviceUidSupplier.get();
ApplicationUid applicationUid = getApplicationUid(applicationUidSupplier, agentInfoBo, serviceUid);
insertApplicationName(agentInfoBo, serviceUid, applicationUid);
}

Check warning on line 81 in collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java#L78-L81

Added lines #L78 - L81 were not covered by tests

private ApplicationUid getApplicationUid(Supplier<ApplicationUid> applicationUidSupplier, AgentInfoBo agentInfoBo, ServiceUid serviceUid) {
try {
return applicationUidSupplier.get();
} catch (UidException exception) {
return applicationUidService.getOrCreateApplicationUid(serviceUid, agentInfoBo.getApplicationName());

Check warning on line 87 in collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java#L85-L87

Added lines #L85 - L87 were not covered by tests
}
Comment on lines +68 to +88
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The insert method signature now expects Supplier and Supplier, but the GRPC handler passes ServiceUid and ApplicationUid directly, causing a type mismatch. Consider changing the signature to accept ServiceUid and ApplicationUid directly or wrapping the parameters in Suppliers at the caller site.

Suggested change
public void insert(Supplier<ServiceUid> serviceUidSupplier, Supplier<ApplicationUid> applicationUidSupplier, @Valid final AgentInfoBo agentInfoBo) {
agentInfoDao.insert(agentInfoBo);
applicationIndexDao.insert(agentInfoBo);
uidAgentListInsert(serviceUidSupplier, applicationUidSupplier, agentInfoBo);
}
private void uidAgentListInsert(Supplier<ServiceUid> serviceUidSupplier, Supplier<ApplicationUid> applicationUidSupplier, AgentInfoBo agentInfoBo) {
if (!uidAgentListEnable || agentNameDao == null) {
return;
}
ServiceUid serviceUid = serviceUidSupplier.get();
ApplicationUid applicationUid = getApplicationUid(applicationUidSupplier, agentInfoBo, serviceUid);
insertApplicationName(agentInfoBo, serviceUid, applicationUid);
}
private ApplicationUid getApplicationUid(Supplier<ApplicationUid> applicationUidSupplier, AgentInfoBo agentInfoBo, ServiceUid serviceUid) {
try {
return applicationUidSupplier.get();
} catch (UidException exception) {
return applicationUidService.getOrCreateApplicationUid(serviceUid, agentInfoBo.getApplicationName());
}
public void insert(ServiceUid serviceUid, ApplicationUid applicationUid, @Valid final AgentInfoBo agentInfoBo) {
agentInfoDao.insert(agentInfoBo);
applicationIndexDao.insert(agentInfoBo);
uidAgentListInsert(serviceUid, applicationUid, agentInfoBo);
}
private void uidAgentListInsert(ServiceUid serviceUid, ApplicationUid applicationUid, AgentInfoBo agentInfoBo) {
if (!uidAgentListEnable || agentNameDao == null) {
return;
}
insertApplicationName(agentInfoBo, serviceUid, applicationUid);
}
private ApplicationUid getApplicationUid(ApplicationUid applicationUid, AgentInfoBo agentInfoBo, ServiceUid serviceUid) {
if (applicationUid != null) {
return applicationUid;
}
return applicationUidService.getOrCreateApplicationUid(serviceUid, agentInfoBo.getApplicationName());

Copilot uses AI. Check for mistakes.

}

private void insertApplicationName(AgentInfoBo agentInfoBo, ServiceUid serviceUid, ApplicationUid applicationUid) {
if (applicationUid == null) {
logger.warn("null applicationUid. {}, applicationName: {}, id: {}, name: {}", serviceUid, agentInfoBo.getApplicationName(), agentInfoBo.getAgentId(), agentInfoBo.getAgentName());
return;

Check warning on line 94 in collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java#L93-L94

Added lines #L93 - L94 were not covered by tests
}
try {
agentNameDao.insert(serviceUid, applicationUid, agentInfoBo.getAgentId(), agentInfoBo.getStartTime(), agentInfoBo.getAgentName());
} catch (Exception e) {
logger.warn("Failed to insert uid agent list. {}, applicationName: {}, id: {}, name: {}", serviceUid, agentInfoBo.getApplicationName(), agentInfoBo.getAgentId(), agentInfoBo.getAgentName(), e);
}

Check warning on line 100 in collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/service/AgentInfoService.java#L97-L100

Added lines #L97 - L100 were not covered by tests
}

public AgentInfoBo getSimpleAgentInfo(@NotBlank final String agentId, @PositiveOrZero final long timestamp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@
import com.navercorp.pinpoint.collector.uid.config.ApplicationUidConfig;
import com.navercorp.pinpoint.collector.uid.config.ServiceUidCacheConfig;
import com.navercorp.pinpoint.collector.uid.config.UidHbaseTemplateConfiguration;
import com.navercorp.pinpoint.collector.uid.service.ApplicationUidService;
import com.navercorp.pinpoint.collector.uid.service.EmptyApplicationUidService;
import com.navercorp.pinpoint.collector.uid.service.ServiceGroupService;
import com.navercorp.pinpoint.collector.uid.service.StaticServiceGroupService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
Expand All @@ -35,15 +28,4 @@ public UidModule() {
logger.info("Install UidModule");
}

@Bean
@ConditionalOnMissingBean(ApplicationUidService.class)
public ApplicationUidService emptyApplicationUidService() {
return new EmptyApplicationUidService();
}

@Bean
@ConditionalOnMissingBean(ServiceGroupService.class)
public ServiceGroupService defaultServiceGroupService(@Value("${collector.service.uid.default.value:0}") int staticServiceUid) {
return new StaticServiceGroupService(staticServiceUid);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.navercorp.pinpoint.collector.uid.config;


import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.navercorp.pinpoint.common.server.uid.ApplicationUid;
import com.navercorp.pinpoint.common.server.uid.cache.CaffeineCacheSpec;
import com.navercorp.pinpoint.common.server.uid.cache.CaffeineCacheProperties;
import com.navercorp.pinpoint.common.server.util.IdGenerator;
import com.navercorp.pinpoint.common.server.util.RandomApplicationUidGenerator;
import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.cache.CaffeineCacheMetrics;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Qualifier;
Expand All @@ -32,23 +35,58 @@

@Bean
@ConfigurationProperties(prefix = "collector.application.uid.cache")
public CaffeineCacheSpec applicationUidCacheSpec() {
return new CaffeineCacheSpec();
public CaffeineCacheProperties applicationUidCacheProperties() {
return new CaffeineCacheProperties();

Check warning on line 39 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java#L39

Added line #L39 was not covered by tests
}

@Bean
public CacheManager applicationUidCache(@Qualifier("applicationUidCacheSpec") CaffeineCacheSpec caffeineCacheSpec) {
public CacheManager applicationUidCache(@Qualifier("applicationUidCacheProperties") CaffeineCacheProperties caffeineCacheProperties) {
CaffeineCacheManager cacheManager = new CaffeineCacheManager(APPLICATION_UID_CACHE_NAME);
cacheManager.setCaffeine(Caffeine.from(caffeineCacheSpec.getSpecification()));
cacheManager.setCaffeine(buildCaffeine(caffeineCacheProperties));

Check warning on line 45 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java#L45

Added line #L45 was not covered by tests
cacheManager.setAsyncCacheMode(true);
cacheManager.setAllowNullValues(false);

return cacheManager;
}

private Caffeine<Object, Object> buildCaffeine(CaffeineCacheProperties properties) {
Caffeine<Object, Object> builder = Caffeine.newBuilder();

Check warning on line 52 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java#L52

Added line #L52 was not covered by tests
if (properties.getInitialCapacity() != -1) {
builder.initialCapacity(properties.getInitialCapacity());

Check warning on line 54 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java#L54

Added line #L54 was not covered by tests
}
if (properties.getMaximumSize() != -1) {
builder.maximumSize(properties.getMaximumSize());

Check warning on line 57 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java#L57

Added line #L57 was not covered by tests
}
if (properties.isRecordStats()) {
builder.recordStats();

Check warning on line 60 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java#L60

Added line #L60 was not covered by tests
}

if (properties.getExpireAfterWrite() != null) {
builder.expireAfterWrite(properties.getExpireAfterWrite());

Check warning on line 64 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java#L64

Added line #L64 was not covered by tests
}
return builder;

Check warning on line 66 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java#L66

Added line #L66 was not covered by tests
}

@Bean
public IdGenerator<ApplicationUid> applicationUidGenerator() {
return new RandomApplicationUidGenerator();
}


//micrometer caffeine cache metrics
@Bean
public MeterBinder caffeineCacheMeterBinder(@Qualifier("applicationUidCache") CacheManager cacheManager,
@Qualifier("applicationUidCacheProperties") CaffeineCacheProperties properties) {
if (!properties.isRecordStats()) {
logger.info("Skipping CaffeineCacheMetrics. recordStats is false");
return meterRegistry -> {};

Check warning on line 81 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java#L80-L81

Added lines #L80 - L81 were not covered by tests
}
org.springframework.cache.Cache springCache = cacheManager.getCache(APPLICATION_UID_CACHE_NAME);

Check warning on line 83 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java#L83

Added line #L83 was not covered by tests
if (springCache == null) {
logger.warn("Skipping CaffeineCacheMetrics. cache '{}' not found", APPLICATION_UID_CACHE_NAME);
return meterRegistry -> {};

Check warning on line 86 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java#L85-L86

Added lines #L85 - L86 were not covered by tests
}

Cache<?, ?> nativeCache = (Cache<?, ?>) springCache.getNativeCache();
return meterRegistry -> CaffeineCacheMetrics.monitor(meterRegistry, nativeCache, APPLICATION_UID_CACHE_NAME);

Check warning on line 90 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ApplicationUidConfig.java#L89-L90

Added lines #L89 - L90 were not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


import com.github.benmanes.caffeine.cache.Caffeine;
import com.navercorp.pinpoint.common.server.uid.cache.CaffeineCacheSpec;
import com.navercorp.pinpoint.common.server.uid.cache.CaffeineCacheProperties;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Qualifier;
Expand All @@ -29,17 +29,32 @@

@Bean
@ConfigurationProperties(prefix = "collector.service.uid.cache")
public CaffeineCacheSpec serviceUidCacheSpec() {
return new CaffeineCacheSpec();
public CaffeineCacheProperties serviceUidCacheProperties() {
return new CaffeineCacheProperties();

Check warning on line 33 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java#L33

Added line #L33 was not covered by tests
}

@Bean
public CacheManager collectorServiceUidCache(@Qualifier("serviceUidCacheSpec") CaffeineCacheSpec caffeineCacheSpec) {
public CacheManager collectorServiceUidCache(@Qualifier("serviceUidCacheProperties") CaffeineCacheProperties caffeineCacheProperties) {
CaffeineCacheManager caffeineCacheManager = new CaffeineCacheManager(SERVICE_UID_CACHE_NAME);
caffeineCacheManager.setCaffeine(
Caffeine.from(caffeineCacheSpec.getSpecification())
);

caffeineCacheManager.setCaffeine(buildCaffeine(caffeineCacheProperties));

Check warning on line 39 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java#L39

Added line #L39 was not covered by tests
return caffeineCacheManager;
}

private Caffeine<Object, Object> buildCaffeine(CaffeineCacheProperties properties) {
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The buildCaffeine method is duplicated in both ServiceUidCacheConfig and ApplicationUidConfig; consider extracting it into a shared utility to reduce code duplication.

Copilot uses AI. Check for mistakes.

Caffeine<Object, Object> builder = Caffeine.newBuilder();

Check warning on line 44 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java#L44

Added line #L44 was not covered by tests
if (properties.getInitialCapacity() != -1) {
builder.initialCapacity(properties.getInitialCapacity());

Check warning on line 46 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java#L46

Added line #L46 was not covered by tests
}
if (properties.getMaximumSize() != -1) {
builder.maximumSize(properties.getMaximumSize());

Check warning on line 49 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java#L49

Added line #L49 was not covered by tests
}
if (properties.isRecordStats()) {
builder.recordStats();

Check warning on line 52 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java#L52

Added line #L52 was not covered by tests
}

if (properties.getExpireAfterWrite() != null) {
builder.expireAfterWrite(properties.getExpireAfterWrite());

Check warning on line 56 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java#L56

Added line #L56 was not covered by tests
}
return builder;

Check warning on line 58 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/config/ServiceUidCacheConfig.java#L58

Added line #L58 was not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.navercorp.pinpoint.collector.uid.dao;

import com.navercorp.pinpoint.common.server.uid.ApplicationUid;
import com.navercorp.pinpoint.common.server.uid.ServiceUid;

public interface AgentNameDao {
void insert(ServiceUid serviceUid, ApplicationUid applicationUid, String agentId, long agentStartTime, String agentName);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.navercorp.pinpoint.collector.uid.dao.hbase;

import com.navercorp.pinpoint.collector.uid.dao.AgentNameDao;
import com.navercorp.pinpoint.common.hbase.HbaseColumnFamily;
import com.navercorp.pinpoint.common.hbase.HbaseOperations;
import com.navercorp.pinpoint.common.hbase.HbaseTables;
import com.navercorp.pinpoint.common.hbase.TableNameProvider;
import com.navercorp.pinpoint.common.server.uid.ApplicationUid;
import com.navercorp.pinpoint.common.server.uid.ServiceUid;
import com.navercorp.pinpoint.common.server.util.AgentListRowKeyUtils;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Repository;

import java.util.Objects;

@Repository
@ConditionalOnProperty(name = "pinpoint.collector.application.uid.enable", havingValue = "true")
public class HbaseAgentNameDao implements AgentNameDao {

private static final HbaseColumnFamily DESCRIPTOR = HbaseTables.AGENT_NAME;

Check warning on line 23 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/dao/hbase/HbaseAgentNameDao.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/dao/hbase/HbaseAgentNameDao.java#L23

Added line #L23 was not covered by tests

private final HbaseOperations hbaseOperations;
private final TableNameProvider tableNameProvider;

public HbaseAgentNameDao(HbaseOperations hbaseOperations, TableNameProvider tableNameProvider) {
this.hbaseOperations = Objects.requireNonNull(hbaseOperations, "hbaseOperations");
this.tableNameProvider = Objects.requireNonNull(tableNameProvider, "tableNameProvider");
}

Check warning on line 31 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/dao/hbase/HbaseAgentNameDao.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/dao/hbase/HbaseAgentNameDao.java#L28-L31

Added lines #L28 - L31 were not covered by tests

@Override
public void insert(ServiceUid serviceUid, ApplicationUid applicationUid, String agentId, long agentStartTime, String agentName) {
byte[] rowKey = AgentListRowKeyUtils.makeRowKey(serviceUid, applicationUid, agentId, agentStartTime);
byte[] value = Bytes.toBytes(agentName);

Check warning on line 36 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/dao/hbase/HbaseAgentNameDao.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/dao/hbase/HbaseAgentNameDao.java#L35-L36

Added lines #L35 - L36 were not covered by tests

Put put = new Put(rowKey, true);
put.addColumn(DESCRIPTOR.getName(), DESCRIPTOR.getName(), value);

Check warning on line 39 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/dao/hbase/HbaseAgentNameDao.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/dao/hbase/HbaseAgentNameDao.java#L38-L39

Added lines #L38 - L39 were not covered by tests

final TableName agentListTableName = tableNameProvider.getTableName(DESCRIPTOR.getTable());
hbaseOperations.put(agentListTableName, put);
}

Check warning on line 43 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/dao/hbase/HbaseAgentNameDao.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/dao/hbase/HbaseAgentNameDao.java#L41-L43

Added lines #L41 - L43 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@

import com.navercorp.pinpoint.common.server.uid.ApplicationUid;
import com.navercorp.pinpoint.common.server.uid.ServiceUid;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

@Service
@ConditionalOnProperty(value = "pinpoint.collector.application.uid.enable", havingValue = "false", matchIfMissing = true)
public class EmptyApplicationUidService implements ApplicationUidService {
private final Logger logger = LogManager.getLogger(this.getClass());

Check warning on line 13 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/service/EmptyApplicationUidService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/service/EmptyApplicationUidService.java#L13

Added line #L13 was not covered by tests

public EmptyApplicationUidService() {
logger.info("EmptyApplicationUidService initialized");
}

Check warning on line 17 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/service/EmptyApplicationUidService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/service/EmptyApplicationUidService.java#L15-L17

Added lines #L15 - L17 were not covered by tests

@Override
public ApplicationUid getApplicationUid(ServiceUid serviceUid, String applicationName) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package com.navercorp.pinpoint.collector.uid.service;

import com.navercorp.pinpoint.common.server.uid.ServiceUid;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

@Service
@ConditionalOnProperty(name = "pinpoint.collector.v4.enable", havingValue = "false", matchIfMissing = true)
public class StaticServiceGroupService implements ServiceGroupService {
private final Logger logger = LogManager.getLogger(this.getClass());

Check warning on line 13 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/service/StaticServiceGroupService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/service/StaticServiceGroupService.java#L13

Added line #L13 was not covered by tests

private final ServiceUid staticServiceUid;

public StaticServiceGroupService(int uid) {
public StaticServiceGroupService(@Value("${collector.service.uid.default.value:0}") int uid) {

Check warning on line 17 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/service/StaticServiceGroupService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/service/StaticServiceGroupService.java#L17

Added line #L17 was not covered by tests
this.staticServiceUid = ServiceUid.of(uid);
logger.info("StaticServiceGroupService initialized. {}", this.staticServiceUid);

Check warning on line 19 in collector/src/main/java/com/navercorp/pinpoint/collector/uid/service/StaticServiceGroupService.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/uid/service/StaticServiceGroupService.java#L19

Added line #L19 was not covered by tests
}

@Override
Expand Down
14 changes: 8 additions & 6 deletions collector/src/main/resources/pinpoint-collector-root.properties
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ pinpoint.collector.realtime.atc.enable-count-metric=false
# Pinpoint Uid (Do not change, under development)
pinpoint.collector.v4.enable=false
collector.service.uid.default.value=0
collector.service.uid.cache.spec.initialCapacity=10
collector.service.uid.cache.spec.maximumSize=200
collector.service.uid.cache.spec.expireAfterWrite=300s
collector.service.uid.cache.initialCapacity=16
collector.service.uid.cache.maximumSize=200
collector.service.uid.cache.expireAfterWrite=3600s

pinpoint.collector.application.uid.enable=false
collector.application.uid.cache.spec.initialCapacity=10
collector.application.uid.cache.spec.maximumSize=200
collector.application.uid.cache.spec.expireAfterWrite=300s
pinpoint.collector.application.uid.agent.list.enable=false
collector.application.uid.cache.initialCapacity=16
collector.application.uid.cache.maximumSize=2000
collector.application.uid.cache.expireAfterWrite=600s
collector.application.uid.cache.recordStats=false

###########################################################
# BANNER #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public enum HbaseTable {
APPLICATION_INDEX("ApplicationIndex"),
APPLICATION_UID("ApplicationUid"),
APPLICATION_NAME("ApplicationName"),
AGENT_NAME("AgentName"),
APPLICATION_TRACE_INDEX("ApplicationTraceIndex"),
HOST_APPLICATION_MAP_VER2("HostApplicationMap_Ver2"),
MAP_STATISTICS_CALLEE_VER2("ApplicationMapStatisticsCallee_Ver2"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private ApiMetadata(HbaseTable hBaseTable, byte[] columnFamilyName) {

public static final HbaseColumnFamily APPLICATION_NAME = new HbaseColumnFamily(HbaseTable.APPLICATION_NAME, Bytes.toBytes("N"));

public static final HbaseColumnFamily AGENT_NAME = new HbaseColumnFamily(HbaseTable.AGENT_NAME, Bytes.toBytes("A"));

public static final HbaseColumnFamily APPLICATION_INDEX_AGENTS = new HbaseColumnFamily(HbaseTable.APPLICATION_INDEX, Bytes.toBytes("Agents"));

Expand Down
Loading