Search in sources :

Example 1 with Id

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);
    }
}
Also used : ConsumerConfig(com.alipay.sofa.rpc.config.ConsumerConfig) Id(com.alipay.lookout.api.Id)

Example 2 with Id

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);
    }
}
Also used : MixinMetric(com.alipay.lookout.api.composite.MixinMetric) Id(com.alipay.lookout.api.Id)

Example 3 with Id

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;
}
Also used : Id(com.alipay.lookout.api.Id)

Example 4 with Id

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;
}
Also used : Id(com.alipay.lookout.api.Id)

Example 5 with Id

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);
        }
    }
}
Also used : DefaultRegistry(com.alipay.lookout.core.DefaultRegistry) Metric(com.alipay.lookout.api.Metric) DefaultRegistry(com.alipay.lookout.core.DefaultRegistry) NoopRegistry(com.alipay.lookout.api.NoopRegistry) Registry(com.alipay.lookout.api.Registry) Id(com.alipay.lookout.api.Id) BeforeClass(org.junit.BeforeClass)

Aggregations

Id (com.alipay.lookout.api.Id)12 Metric (com.alipay.lookout.api.Metric)5 NoopRegistry (com.alipay.lookout.api.NoopRegistry)5 Registry (com.alipay.lookout.api.Registry)5 DefaultRegistry (com.alipay.lookout.core.DefaultRegistry)5 MixinMetric (com.alipay.lookout.api.composite.MixinMetric)2 After (org.junit.After)2 BeforeClass (org.junit.BeforeClass)2 ApplicationConfig (com.alipay.sofa.rpc.config.ApplicationConfig)1 ConsumerConfig (com.alipay.sofa.rpc.config.ConsumerConfig)1 MethodConfig (com.alipay.sofa.rpc.config.MethodConfig)1 ProviderConfig (com.alipay.sofa.rpc.config.ProviderConfig)1 ServerConfig (com.alipay.sofa.rpc.config.ServerConfig)1 SofaRpcException (com.alipay.sofa.rpc.core.exception.SofaRpcException)1 ArrayList (java.util.ArrayList)1 AfterClass (org.junit.AfterClass)1 Before (org.junit.Before)1