Skip to content
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

[#10693] change retry with grpc retry #10766

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 5 additions & 2 deletions agent-module/agent/src/main/resources/pinpoint-root.config
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ profiler.transport.grpc.metadata.ssl.enable=false
profiler.transport.grpc.metadata.sender.executor.queue.size=1000
profiler.transport.grpc.metadata.sender.channel.executor.queue.size=1000
profiler.transport.grpc.metadata.sender.request.timeout.millis=6000
profiler.transport.grpc.metadata.sender.retry.max.count=3
profiler.transport.grpc.metadata.sender.retry.delay.millis=1000
profiler.transport.grpc.metadata.sender.retry.enable=true
profiler.transport.grpc.metadata.sender.retry.buffer.size=16M
profiler.transport.grpc.metadata.sender.retry.per.rpc.buffer.limit=1M
profiler.transport.grpc.metadata.sender.max.attempts=3
profiler.transport.grpc.metadata.sender.hedging.delay.millis=1000
profiler.transport.grpc.metadata.sender.keepalive.time.millis=30000
profiler.transport.grpc.metadata.sender.keepalive.timeout.millis=60000
profiler.transport.grpc.metadata.sender.loadbalancer=pick_first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.navercorp.pinpoint.profiler.test;

import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor;
import com.navercorp.pinpoint.common.profiler.message.EnhancedDataSender;
import com.navercorp.pinpoint.common.profiler.message.DataSender;
import com.navercorp.pinpoint.io.ResponseMessage;
import com.navercorp.pinpoint.profiler.cache.IdAllocator;
import com.navercorp.pinpoint.profiler.cache.Result;
Expand All @@ -35,10 +35,10 @@ public class MockApiMetaDataService implements ApiMetaDataService {

private final SimpleCache<String> apiCache = new SimpleCache<>(new IdAllocator.ZigZagAllocator());

private final EnhancedDataSender<MetaDataType, ResponseMessage> enhancedDataSender;
private final DataSender<MetaDataType> dataSender;

public MockApiMetaDataService(EnhancedDataSender<MetaDataType, ResponseMessage> enhancedDataSender) {
this.enhancedDataSender = Objects.requireNonNull(enhancedDataSender, "enhancedDataSender");
public MockApiMetaDataService(DataSender<MetaDataType> dataSender) {
this.dataSender = Objects.requireNonNull(dataSender, "dataSender");
}

@Override
Expand All @@ -51,7 +51,7 @@ public int cacheApi(final MethodDescriptor methodDescriptor) {
final ApiMetaData apiMetadata = new ApiMetaData(result.getId(), methodDescriptor.getApiDescriptor(),
methodDescriptor.getLineNumber(), methodDescriptor.getType());

this.enhancedDataSender.request(apiMetadata);
this.dataSender.send(apiMetadata);

return result.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.navercorp.pinpoint.common.profiler.message.EnhancedDataSender;
import com.navercorp.pinpoint.io.ResponseMessage;
import com.navercorp.pinpoint.common.profiler.message.DataSender;
import com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService;
import com.navercorp.pinpoint.profiler.metadata.MetaDataType;

Expand All @@ -30,17 +29,17 @@
*/
public class MockApiMetaDataServiceProvider implements Provider<ApiMetaDataService> {

private final Provider<EnhancedDataSender<MetaDataType, ResponseMessage>> enhancedDataSenderProvider;
private final Provider<DataSender<MetaDataType>> dataSenderProvider;

@Inject
public MockApiMetaDataServiceProvider(Provider<EnhancedDataSender<MetaDataType, ResponseMessage>> enhancedDataSenderProvider) {
this.enhancedDataSenderProvider = Objects.requireNonNull(enhancedDataSenderProvider, "enhancedDataSenderProvider");
public MockApiMetaDataServiceProvider(Provider<DataSender<MetaDataType>> dataSenderProvider) {
this.dataSenderProvider = Objects.requireNonNull(dataSenderProvider, "dataSenderProvider");
}

@Override
public ApiMetaDataService get() {
final EnhancedDataSender<MetaDataType, ResponseMessage> enhancedDataSender = this.enhancedDataSenderProvider.get();
return new MockApiMetaDataService(enhancedDataSender);
final DataSender<MetaDataType> dataSender = this.dataSenderProvider.get();
return new MockApiMetaDataService(dataSender);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.navercorp.pinpoint.profiler.context.DefaultServerMetaDataRegistryService;
import com.navercorp.pinpoint.profiler.context.ServerMetaDataRegistryService;
import com.navercorp.pinpoint.profiler.context.SpanType;
import com.navercorp.pinpoint.profiler.context.module.MetadataDataSender;
import com.navercorp.pinpoint.profiler.context.module.SpanDataSender;
import com.navercorp.pinpoint.profiler.context.module.StatDataSender;
import com.navercorp.pinpoint.profiler.context.storage.StorageFactory;
Expand Down Expand Up @@ -64,6 +65,12 @@ protected void configure() {
Key<DataSender<MetricType>> statDataSenderKey = Key.get(statDataSenderType, StatDataSender.class);
bind(statDataSenderKey).toInstance(statDataSender);

final DataSender<MetaDataType> metadataDataSender = newUdpMetadataDataSender();
logger.debug("metadataDataSender:{}", metadataDataSender);
TypeLiteral<DataSender<MetaDataType>> metadataDataSenderType = new TypeLiteral<DataSender<MetaDataType>>() {};
Key<DataSender<MetaDataType>> metadataDataSenderKey = Key.get(metadataDataSenderType, MetadataDataSender.class);
bind(metadataDataSenderKey).toInstance(metadataDataSender);

bind(StorageFactory.class).to(TestSpanStorageFactory.class);

EnhancedDataSender<MetaDataType, ResponseMessage> enhancedDataSender = newTcpDataSender();
Expand All @@ -76,6 +83,9 @@ protected void configure() {
bind(ApiMetaDataService.class).toProvider(MockApiMetaDataServiceProvider.class).in(Scopes.SINGLETON);
}

private DataSender<MetaDataType> newUdpMetadataDataSender() {
return new ListenableDataSender<>("MetadataDataSender");
}

private DataSender<MetricType> newUdpStatDataSender() {
return new ListenableDataSender<>("StatDataSender");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ protected void configure() {
bind(statDataSenderKey).toInstance(statDataSender);
expose(statDataSenderKey);

TypeLiteral<DataSender<MetaDataType>> metadataDataSenderTypeLiteral = new TypeLiteral<DataSender<MetaDataType>>() {};
Key<DataSender<MetaDataType>> metadataDataSenderKey = Key.get(metadataDataSenderTypeLiteral, MetadataDataSender.class);
final DataSender<MetaDataType> metadataDataSender = new ListenableDataSender<>("MetadataDataSender");
logger.debug("metadataDataSender:{}", metadataDataSender);
bind(metadataDataSenderKey).toInstance(metadataDataSender);
expose(metadataDataSenderKey);

EnhancedDataSender<MetaDataType, ResponseMessage> enhancedDataSender = new TestTcpDataSender();
logger.debug("enhancedDataSender:{}", enhancedDataSender);
TypeLiteral<EnhancedDataSender<MetaDataType, ResponseMessage>> dataSenderTypeLiteral = new TypeLiteral<EnhancedDataSender<MetaDataType, ResponseMessage>>() {
Expand All @@ -83,10 +90,6 @@ protected void configure() {
bind(agentDataSender).to(dataSenderTypeLiteral).in(Scopes.SINGLETON);
expose(agentDataSender);

Key<EnhancedDataSender<MetaDataType, ResponseMessage>> metadataDataSender = Key.get(dataSenderTypeLiteral, MetadataDataSender.class);
bind(metadataDataSender).to(dataSenderTypeLiteral).in(Scopes.SINGLETON);
expose(metadataDataSender);


TypeLiteral<MessageConverter<Object, ResultResponse>> resultMessageConverter = new TypeLiteral<MessageConverter<Object, ResultResponse>>() {};
Key<MessageConverter<Object, ResultResponse>> resultMessageConverterKey = Key.get(resultMessageConverter, ResultConverter.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
*/
package com.navercorp.pinpoint.profiler.context.exception.storage;

import com.navercorp.pinpoint.common.profiler.message.EnhancedDataSender;
import com.navercorp.pinpoint.common.profiler.message.DataSender;
import com.navercorp.pinpoint.common.util.CollectionUtils;
import com.navercorp.pinpoint.io.ResponseMessage;
import com.navercorp.pinpoint.profiler.context.exception.model.ExceptionMetaData;
import com.navercorp.pinpoint.profiler.context.exception.model.ExceptionMetaDataFactory;
import com.navercorp.pinpoint.profiler.context.exception.model.ExceptionWrapper;
Expand All @@ -38,12 +37,12 @@ public class BufferedExceptionStorage implements ExceptionStorage {
private static final boolean isDebug = logger.isDebugEnabled();

private final ArrayBuffer<ExceptionWrapper> buffer;
private final EnhancedDataSender<MetaDataType, ResponseMessage> dataSender;
private final DataSender<MetaDataType> dataSender;
private final ExceptionMetaDataFactory factory;

public BufferedExceptionStorage(
int bufferSize,
EnhancedDataSender<MetaDataType, ResponseMessage> dataSender,
DataSender<MetaDataType> dataSender,
ExceptionMetaDataFactory exceptionMetaDataFactory
) {
this.dataSender = Objects.requireNonNull(dataSender, "dataSender");
Expand Down Expand Up @@ -79,7 +78,7 @@ private void sendExceptionMetaData(List<ExceptionWrapper> exceptionWrappers) {
if (isDebug) {
logger.debug("Flush {}", exceptionMetaData);
}
final boolean success = this.dataSender.request(exceptionMetaData);
final boolean success = this.dataSender.send(exceptionMetaData);
if (!success) {
// Do not call exceptionMetaData.toString()
logger.debug("send fail");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
*/
package com.navercorp.pinpoint.profiler.context.exception.storage;

import com.navercorp.pinpoint.common.profiler.message.EnhancedDataSender;
import com.navercorp.pinpoint.io.ResponseMessage;
import com.navercorp.pinpoint.common.profiler.message.DataSender;
import com.navercorp.pinpoint.profiler.context.exception.model.ExceptionMetaDataFactory;
import com.navercorp.pinpoint.profiler.metadata.MetaDataType;

Expand All @@ -27,10 +26,10 @@
*/
public class ExceptionStorageFactory {

private final EnhancedDataSender<MetaDataType, ResponseMessage> dataSender;
private final DataSender<MetaDataType> dataSender;
private final int bufferSize;

public ExceptionStorageFactory(EnhancedDataSender<MetaDataType, ResponseMessage> dataSender, int bufferSize) {
public ExceptionStorageFactory(DataSender<MetaDataType> dataSender, int bufferSize) {
this.dataSender = Objects.requireNonNull(dataSender, "dataSender");
this.bufferSize = bufferSize;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.navercorp.pinpoint.common.config.Value;
import com.navercorp.pinpoint.common.config.util.ValueAnnotationProcessor;
import com.navercorp.pinpoint.common.config.util.spring.PropertyPlaceholderHelper;
import com.navercorp.pinpoint.common.util.ByteSizeUnit;
import com.navercorp.pinpoint.grpc.client.config.ClientOption;
import com.navercorp.pinpoint.grpc.client.config.SslOption;

Expand Down Expand Up @@ -65,14 +66,15 @@ public class GrpcTransportConfig {
public final static long DEFAULT_RENEW_TRANSPORT_PERIOD_MILLIS_DISABLE = 3153600000000L;
private static final long DEFAULT_RENEW_TRANSPORT_PERIOD_MILLIS = DEFAULT_RENEW_TRANSPORT_PERIOD_MILLIS_DISABLE; // Disabled

private static final int DEFAULT_METADATA_RETRY_MAX_COUNT = 3;
private static final int DEFAULT_METADATA_RETRY_DELAY_MILLIS = 1000;

private static final boolean DEFAULT_METADATA_RETRY_ENABLE = false;
private static final long DEFAULT_METADATA_RETRY_BUFFER_SIZE = 1L << 24; // 16M
private static final long DEFAULT_METADATA_PER_RPC_BUFFER_LIMIT = 1L << 20; // 1M
private static final int DEFAULT_METADATA_MAX_ATTEMPTS = 3;
private static final long DEFAULT_METADATA_HEDGING_DELAY_MILLIS = 1000;
@Deprecated
private static final int DEFAULT_METADATA_RETRY_MAX_COUNT = -1;
@Deprecated
private static final int DEFAULT_METADATA_RETRY_DELAY_MILLIS = -1;

public static final boolean DEFAULT_NETTY_SYSTEM_PROPERTY_TRY_REFLECTIVE_SET_ACCESSIBLE = true;

Expand Down Expand Up @@ -112,21 +114,21 @@ public class GrpcTransportConfig {
private int metadataSenderExecutorQueueSize = DEFAULT_METADATA_SENDER_EXECUTOR_QUEUE_SIZE;
@Value("${profiler.transport.grpc.metadata.sender.channel.executor.queue.size}")
private int metadataChannelExecutorQueueSize = DEFAULT_METADATA_CHANNEL_EXECUTOR_QUEUE_SIZE;
@Value("${profiler.transport.grpc.metadata.sender.retry.max.count}")
private int metadataRetryMaxCount = DEFAULT_METADATA_RETRY_MAX_COUNT;
@Value("${profiler.transport.grpc.metadata.sender.retry.delay.millis}")
private int metadataRetryDelayMillis = DEFAULT_METADATA_RETRY_DELAY_MILLIS;
//grpc client retry
@Value("${profiler.transport.grpc.metadata.sender.retry.enable}")
private boolean metadataRetryEnable = DEFAULT_METADATA_RETRY_ENABLE;
@Value("${profiler.transport.grpc.metadata.sender.retry.buffer.size}")
private long metadataRetryBufferSize = DEFAULT_METADATA_RETRY_BUFFER_SIZE;
@Value("${profiler.transport.grpc.metadata.sender.retry.per.rpc.buffer.limit}")
private long metadataPerRpcBufferLimit = DEFAULT_METADATA_PER_RPC_BUFFER_LIMIT;
@Value("${profiler.transport.grpc.metadata.sender.max.attempts}")
private int metadataMaxAttempts = DEFAULT_METADATA_MAX_ATTEMPTS;
@Value("${profiler.transport.grpc.metadata.sender.hedging.delay.millis}")
private long metadataHedgingDelayMillis = DEFAULT_METADATA_HEDGING_DELAY_MILLIS;
@Deprecated
@Value("${profiler.transport.grpc.metadata.sender.retry.max.count}")
private int metadataRetryMaxCount = DEFAULT_METADATA_RETRY_MAX_COUNT;
@Deprecated
@Value("${profiler.transport.grpc.metadata.sender.retry.delay.millis}")
private int metadataRetryDelayMillis = DEFAULT_METADATA_RETRY_DELAY_MILLIS;

@Value("${profiler.transport.grpc.stat.collector.ip}")
private String statCollectorIp = DEFAULT_IP;
Expand Down Expand Up @@ -418,6 +420,16 @@ public boolean isNettySystemPropertyTryReflectiveSetAccessible() {
return nettySystemPropertyTryReflectiveSetAccessible;
}


@Value("${profiler.transport.grpc.metadata.sender.retry.buffer.size}")
void setMetadataRetryBufferSize(String metadataRetryBufferSize) {
this.metadataRetryBufferSize = ByteSizeUnit.getByteSize(metadataRetryBufferSize, DEFAULT_METADATA_RETRY_BUFFER_SIZE);
}
@Value("${profiler.transport.grpc.metadata.sender.retry.per.rpc.buffer.limit}")
void setMetadataPerRpcBufferLimit(String metadataPerRpcBufferLimit) {
this.metadataPerRpcBufferLimit = ByteSizeUnit.getByteSize(metadataPerRpcBufferLimit, DEFAULT_METADATA_PER_RPC_BUFFER_LIMIT);
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("GrpcTransportConfig{");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ private void bindAgentDataSender() {
bind(agentDataSender).toProvider(AgentGrpcDataSenderProvider.class).in(Scopes.SINGLETON);
expose(agentDataSender);

Key<EnhancedDataSender<MetaDataType, ResponseMessage>> metadataDataSender = Key.get(dataSenderTypeLiteral, MetadataDataSender.class);
TypeLiteral<DataSender<MetaDataType>> metadataDataSenderTypeLiteral = new TypeLiteral<DataSender<MetaDataType>>() {
};
Key<DataSender<MetaDataType>> metadataDataSender = Key.get(metadataDataSenderTypeLiteral, MetadataDataSender.class);
bind(metadataDataSender).toProvider(MetadataGrpcDataSenderProvider.class).in(Scopes.SINGLETON);
expose(metadataDataSender);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ public class GrpcModuleLifeCycle implements ModuleLifeCycle {
private final PluginLogger logger = PluginLogManager.getLogger(this.getClass());

private final Provider<EnhancedDataSender<MetaDataType, ResponseMessage>> agentDataSenderProvider;
private final Provider<EnhancedDataSender<MetaDataType, ResponseMessage>> metadataDataSenderProvider;
private final Provider<DataSender<MetaDataType>> metadataDataSenderProvider;
private final Provider<DataSender<SpanType>> spanDataSenderProvider;
private final Provider<DataSender<MetricType>> statDataSenderProvider;

private final Provider<ExecutorService> dnsExecutorServiceProvider;
private final Provider<ScheduledExecutorService> reconnectScheduledExecutorProvider;

private EnhancedDataSender<MetaDataType, ResponseMessage> agentDataSender;
private EnhancedDataSender<MetaDataType, ResponseMessage> metadataDataSender;
private DataSender<MetaDataType> metadataDataSender;

private DataSender<SpanType> spanDataSender;
private DataSender<MetricType> statDataSender;
Expand All @@ -62,7 +62,7 @@ public class GrpcModuleLifeCycle implements ModuleLifeCycle {
@Inject
public GrpcModuleLifeCycle(
@AgentDataSender Provider<EnhancedDataSender<MetaDataType, ResponseMessage>> agentDataSenderProvider,
@MetadataDataSender Provider<EnhancedDataSender<MetaDataType, ResponseMessage>> metadataDataSenderProvider,
@MetadataDataSender Provider<DataSender<MetaDataType>> metadataDataSenderProvider,
@SpanDataSender Provider<DataSender<SpanType>> spanDataSenderProvider,
@StatDataSender Provider<DataSender<MetricType>> statDataSenderProvider,
Provider<ExecutorService> dnsExecutorServiceProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.navercorp.pinpoint.common.profiler.message.EnhancedDataSender;
import com.navercorp.pinpoint.io.ResponseMessage;
import com.navercorp.pinpoint.common.profiler.message.DataSender;
import com.navercorp.pinpoint.profiler.context.exception.storage.ExceptionStorageFactory;
import com.navercorp.pinpoint.profiler.context.module.MetadataDataSender;
import com.navercorp.pinpoint.profiler.context.monitor.config.ExceptionTraceConfig;
Expand All @@ -32,12 +31,12 @@
public class ExceptionStorageFactoryProvider implements Provider<ExceptionStorageFactory> {

private final ExceptionTraceConfig exceptionTraceConfig;
private final EnhancedDataSender<MetaDataType, ResponseMessage> spanTypeDataSender;
private final DataSender<MetaDataType> spanTypeDataSender;

@Inject
public ExceptionStorageFactoryProvider(
ExceptionTraceConfig exceptionTraceConfig,
@MetadataDataSender EnhancedDataSender<MetaDataType, ResponseMessage> metadataDataSender
@MetadataDataSender DataSender<MetaDataType> metadataDataSender
) {
this.exceptionTraceConfig = Objects.requireNonNull(exceptionTraceConfig, "exceptionTraceConfig");
this.spanTypeDataSender = metadataDataSender;
Expand Down
Loading
Loading