use of com.alipay.lookout.api.Id in project sofa-rpc by sofastack.
the class RpcLookout method collectConsumerSubInfo.
/**
* Collect the RPC client information.
*
* @param consumerConfig client information model
*/
public void collectConsumerSubInfo(final ConsumerConfig consumerConfig) {
try {
Id consumerConfigId = rpcLookoutId.fetchConsumerSubId();
Lookout.registry().info(consumerConfigId, new Info<ConsumerConfig>() {
@Override
public ConsumerConfig value() {
return consumerConfig;
}
});
} catch (Throwable t) {
LOGGER.error(LogCodes.getLog(LogCodes.ERROR_METRIC_REPORT_ERROR), t);
}
}
use of com.alipay.lookout.api.Id in project sofa-rpc by sofastack.
the class RpcLookout method collectServer.
/**
* Collect the RPC server information.
*
* @param rpcServerMetricsModel server information model
*/
public void collectServer(RpcServerLookoutModel rpcServerMetricsModel) {
try {
Id methodProviderId = createMethodProviderId(rpcServerMetricsModel);
MixinMetric methodProviderMetric = Lookout.registry().mixinMetric(methodProviderId);
recordCounterAndTimer(methodProviderMetric, rpcServerMetricsModel);
} catch (Throwable t) {
LOGGER.error(LogCodes.getLog(LogCodes.ERROR_METRIC_REPORT_ERROR), t);
}
}
use of com.alipay.lookout.api.Id in project sofa-rpc by sofastack.
the class RpcLookoutId method fetchProviderStatId.
/**
* Create ProviderId
*
* @return ProviderId
*/
public Id fetchProviderStatId(Map<String, String> tags) {
String key = tags.toString();
Id lookoutId = providerIds.get(key);
if (lookoutId == null) {
synchronized (RpcLookoutId.class) {
lookoutId = providerIds.get(key);
if (lookoutId == null) {
lookoutId = Lookout.registry().createId("rpc.provider.service.stats", tags);
providerIds.put(key, lookoutId);
}
}
}
return lookoutId;
}
use of com.alipay.lookout.api.Id in project sofa-rpc by sofastack.
the class RpcLookoutId method fetchConsumerStatId.
/**
* create consumerId
*
* @return consumerId
*/
public Id fetchConsumerStatId(Map<String, String> tags) {
String key = tags.toString();
Id lookoutId = consumerIds.get(key);
if (lookoutId == null) {
synchronized (RpcLookoutId.class) {
lookoutId = consumerIds.get(key);
if (lookoutId == null) {
lookoutId = Lookout.registry().createId("rpc.consumer.service.stats", tags);
consumerIds.put(key, lookoutId);
}
}
}
return lookoutId;
}
use of com.alipay.lookout.api.Id in project sofa-rpc by sofastack.
the class RestLookoutTest method beforeCurrentClass.
@BeforeClass
public static void beforeCurrentClass() {
RpcRunningState.setUnitTestMode(false);
JAXRSProviderManager.registerInternalProviderClass(LookoutRequestFilter.class);
RpcRuntimeContext.putIfAbsent(RpcRuntimeContext.KEY_APPNAME, "TestLookOutServer");
Registry registry = new DefaultRegistry();
final Registry currentRegistry = Lookout.registry();
if (currentRegistry == NoopRegistry.INSTANCE) {
Lookout.setRegistry(registry);
} else {
// clear all metrics now
Iterator<Metric> itar = currentRegistry.iterator();
while (itar.hasNext()) {
Metric metric = itar.next();
Id id = metric.id();
currentRegistry.removeMetric(id);
}
}
}
Aggregations