Fix typo and add comments. (#5495)
* Fix typo and add comments. * Fix comment.
This commit is contained in:
parent
f397c1bb49
commit
54ee2e61ad
|
|
@ -42,12 +42,14 @@ import org.apache.skywalking.apm.network.language.agent.v3.MeterReportServiceGrp
|
|||
|
||||
import static org.apache.skywalking.apm.agent.core.conf.Config.Collector.GRPC_UPSTREAM_TIMEOUT;
|
||||
|
||||
/**
|
||||
* Collect the values from given registered metrics, and send to the backend.
|
||||
*/
|
||||
@DefaultImplementor
|
||||
public class MeterSender implements BootService, GRPCChannelListener {
|
||||
private static final ILog LOGGER = LogManager.getLogger(MeterSender.class);
|
||||
|
||||
private volatile GRPCChannelStatus status = GRPCChannelStatus.DISCONNECT;
|
||||
|
||||
private volatile MeterReportServiceGrpc.MeterReportServiceStub meterReportServiceStub;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
|
|||
import org.apache.skywalking.apm.agent.core.meter.transform.MeterTransformer;
|
||||
import org.apache.skywalking.apm.util.RunnableWithExceptionProtection;
|
||||
|
||||
/**
|
||||
* Agent core level service. It provides the register map for all available metrics and send them through meter sender.
|
||||
*/
|
||||
@DefaultImplementor
|
||||
public class MeterService implements BootService, Runnable {
|
||||
private static final ILog LOGGER = LogManager.getLogger(MeterService.class);
|
||||
|
|
|
|||
|
|
@ -24,5 +24,8 @@ import org.apache.skywalking.apm.agent.core.meter.MeterId;
|
|||
* Working on adapt the tool-kit side with agent core
|
||||
*/
|
||||
public interface MeterAdapter {
|
||||
/**
|
||||
* @return {@link MeterId}
|
||||
*/
|
||||
MeterId getId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.apache.skywalking.apm.agent.core.meter.MeterService;
|
|||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
|
||||
import org.apache.skywalking.apm.toolkit.meter.impl.CounterImpl;
|
||||
import org.apache.skywalking.apm.toolkit.activation.meter.adapter.TookitCounterAdapter;
|
||||
import org.apache.skywalking.apm.toolkit.activation.meter.adapter.ToolkitCounterAdapter;
|
||||
|
||||
public class CounterInterceptor implements InstanceConstructorInterceptor {
|
||||
private static MeterService METER_SERVICE;
|
||||
|
|
@ -33,7 +33,7 @@ public class CounterInterceptor implements InstanceConstructorInterceptor {
|
|||
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
|
||||
final CounterImpl toolkitCounter = (CounterImpl) objInst;
|
||||
|
||||
final TookitCounterAdapter counterAdapter = new TookitCounterAdapter(toolkitCounter);
|
||||
final ToolkitCounterAdapter counterAdapter = new ToolkitCounterAdapter(toolkitCounter);
|
||||
final CounterTransformer counterTransformer = new CounterTransformer(counterAdapter);
|
||||
|
||||
if (METER_SERVICE == null) {
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ import org.apache.skywalking.apm.agent.core.meter.adapter.CounterAdapter;
|
|||
import org.apache.skywalking.apm.toolkit.activation.meter.util.MeterIdConverter;
|
||||
import org.apache.skywalking.apm.toolkit.meter.impl.CounterImpl;
|
||||
|
||||
public class TookitCounterAdapter implements CounterAdapter {
|
||||
public class ToolkitCounterAdapter implements CounterAdapter {
|
||||
|
||||
private final CounterImpl counter;
|
||||
private final MeterId id;
|
||||
|
||||
public TookitCounterAdapter(CounterImpl counter) {
|
||||
public ToolkitCounterAdapter(CounterImpl counter) {
|
||||
this.counter = counter;
|
||||
this.id = MeterIdConverter.convert(counter.getMeterId());
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ package org.apache.skywalking.apm.toolkit.meter;
|
|||
import org.apache.skywalking.apm.agent.core.meter.MeterId;
|
||||
import org.apache.skywalking.apm.agent.core.meter.MeterTag;
|
||||
import org.apache.skywalking.apm.agent.core.meter.MeterType;
|
||||
import org.apache.skywalking.apm.toolkit.activation.meter.adapter.TookitCounterAdapter;
|
||||
import org.apache.skywalking.apm.toolkit.activation.meter.adapter.ToolkitCounterAdapter;
|
||||
import org.apache.skywalking.apm.toolkit.meter.impl.CounterImpl;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
@ -31,7 +31,7 @@ public class ToolkitCounterAdapterTest {
|
|||
@Test
|
||||
public void testGetCount() {
|
||||
final Counter counter = MeterFactory.counter("test").build();
|
||||
final TookitCounterAdapter adapter = new TookitCounterAdapter((CounterImpl) counter);
|
||||
final ToolkitCounterAdapter adapter = new ToolkitCounterAdapter((CounterImpl) counter);
|
||||
|
||||
counter.increment(1d);
|
||||
counter.increment(2d);
|
||||
|
|
@ -45,7 +45,7 @@ public class ToolkitCounterAdapterTest {
|
|||
@Test
|
||||
public void testGetCountWithRate() {
|
||||
final Counter counter = MeterFactory.counter("test_with_rate").mode(Counter.Mode.RATE).build();
|
||||
final TookitCounterAdapter adapter = new TookitCounterAdapter((CounterImpl) counter);
|
||||
final ToolkitCounterAdapter adapter = new ToolkitCounterAdapter((CounterImpl) counter);
|
||||
|
||||
counter.increment(1d);
|
||||
counter.increment(2d);
|
||||
|
|
@ -60,7 +60,7 @@ public class ToolkitCounterAdapterTest {
|
|||
@Test
|
||||
public void testGetId() {
|
||||
final Counter counter = MeterFactory.counter("test").tag("k1", "v1").build();
|
||||
final TookitCounterAdapter adapter = new TookitCounterAdapter((CounterImpl) counter);
|
||||
final ToolkitCounterAdapter adapter = new ToolkitCounterAdapter((CounterImpl) counter);
|
||||
|
||||
final MeterId id = adapter.getId();
|
||||
Assert.assertEquals("test", id.getName());
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import org.apache.skywalking.apm.agent.core.meter.transform.MeterTransformer;
|
|||
import org.apache.skywalking.apm.network.language.agent.v3.MeterDataCollection;
|
||||
|
||||
/**
|
||||
* A report to send JVM Metrics data to Kafka Broker.
|
||||
* A report to send Metrics data of meter system to Kafka Broker.
|
||||
*/
|
||||
@OverrideImplementor(MeterSender.class)
|
||||
public class KafkaMeterSender extends MeterSender {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import org.apache.skywalking.oap.server.telemetry.api.MetricsTag;
|
|||
import org.apache.skywalking.oap.server.telemetry.api.TelemetryRelatedContext;
|
||||
|
||||
/**
|
||||
* BaseMetrics parent class represents the me
|
||||
* BaseMetrics parent class represents the metrics
|
||||
*/
|
||||
public abstract class BaseMetrics<T extends SimpleCollector, C> {
|
||||
private static Map<String, Object> ALL_METRICS = new HashMap<>();
|
||||
|
|
@ -49,6 +49,12 @@ public abstract class BaseMetrics<T extends SimpleCollector, C> {
|
|||
return TelemetryRelatedContext.INSTANCE.getId() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create real prometheus metrics with SkyWalking native labels, and provide to all metrics implementation. Metrics
|
||||
* name should be unique.
|
||||
*
|
||||
* @return metric reference if the service instance id has been initialized. Or NULL.
|
||||
*/
|
||||
protected C getMetric() {
|
||||
if (metricsInstance == null) {
|
||||
if (isIDReady()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue