ADD: add operationName length threshold (#3357)
* ADD: add operationName length threshold * MOD:move operationName threshold to Config, simplified code * MOD:update agent set-up document, clean code * MOD:add agent.operation_name_threshold conf prefix
This commit is contained in:
parent
ed5a1fc2d2
commit
3d00d83fc6
|
|
@ -62,4 +62,11 @@ public final class StringUtil {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String cut(String str, int threshold) {
|
||||
if (isEmpty(str) || str.length() <= threshold) {
|
||||
return str;
|
||||
}
|
||||
return str.substring(0, threshold);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,4 +53,12 @@ public class StringUtilTest {
|
|||
Assert.assertFalse(StringUtil.substringMatch("", 4770, ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCut() {
|
||||
String str = "aaaaaaabswbswbbsbwbsbbwbsbwbsbwbbsbbebewewewewewewewewewewew";
|
||||
String shortStr = "ab";
|
||||
Assert.assertEquals(10, StringUtil.cut(str, 10).length());
|
||||
Assert.assertEquals(2, StringUtil.cut(shortStr, 10).length());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -105,6 +105,11 @@ public class Config {
|
|||
* status more than this number. The channel check will call channel.getState(true) to requestConnection.
|
||||
*/
|
||||
public static long FORCE_RECONNECTION_PERIOD = 1;
|
||||
|
||||
/**
|
||||
* Limit the length of the operationName to prevent errors when inserting elasticsearch
|
||||
**/
|
||||
public static int OPERATION_NAME_THRESHOLD = 500;
|
||||
}
|
||||
|
||||
public static class Collector {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ import org.apache.skywalking.apm.agent.core.logging.api.*;
|
|||
import org.apache.skywalking.apm.agent.core.sampling.SamplingService;
|
||||
import org.apache.skywalking.apm.util.StringUtil;
|
||||
|
||||
import static org.apache.skywalking.apm.agent.core.conf.Config.Agent.OPERATION_NAME_THRESHOLD;
|
||||
|
||||
/**
|
||||
* {@link ContextManager} controls the whole context of {@link TraceSegment}. Any {@link TraceSegment} relates to
|
||||
* single-thread, so this context use {@link ThreadLocal} to maintain the context, and make sure, since a {@link
|
||||
|
|
@ -89,6 +91,7 @@ public class ContextManager implements BootService {
|
|||
public static AbstractSpan createEntrySpan(String operationName, ContextCarrier carrier) {
|
||||
AbstractSpan span;
|
||||
AbstractTracerContext context;
|
||||
operationName = StringUtil.cut(operationName, OPERATION_NAME_THRESHOLD);
|
||||
if (carrier != null && carrier.isValid()) {
|
||||
SamplingService samplingService = ServiceManager.INSTANCE.findService(SamplingService.class);
|
||||
samplingService.forceSampled();
|
||||
|
|
@ -103,6 +106,7 @@ public class ContextManager implements BootService {
|
|||
}
|
||||
|
||||
public static AbstractSpan createLocalSpan(String operationName) {
|
||||
operationName = StringUtil.cut(operationName, OPERATION_NAME_THRESHOLD);
|
||||
AbstractTracerContext context = getOrCreate(operationName, false);
|
||||
return context.createLocalSpan(operationName);
|
||||
}
|
||||
|
|
@ -111,6 +115,7 @@ public class ContextManager implements BootService {
|
|||
if (carrier == null) {
|
||||
throw new IllegalArgumentException("ContextCarrier can't be null.");
|
||||
}
|
||||
operationName = StringUtil.cut(operationName, OPERATION_NAME_THRESHOLD);
|
||||
AbstractTracerContext context = getOrCreate(operationName, false);
|
||||
AbstractSpan span = context.createExitSpan(operationName, remotePeer);
|
||||
context.inject(carrier);
|
||||
|
|
@ -118,6 +123,7 @@ public class ContextManager implements BootService {
|
|||
}
|
||||
|
||||
public static AbstractSpan createExitSpan(String operationName, String remotePeer) {
|
||||
operationName = StringUtil.cut(operationName, OPERATION_NAME_THRESHOLD);
|
||||
AbstractTracerContext context = getOrCreate(operationName, false);
|
||||
AbstractSpan span = context.createExitSpan(operationName, remotePeer);
|
||||
return span;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ agent.service_name=${SW_AGENT_NAME:Your_ApplicationName}
|
|||
# Skywalking team may ask for these files in order to resolve compatible problem.
|
||||
# agent.is_open_debugging_class = ${SW_AGENT_OPEN_DEBUG:true}
|
||||
|
||||
# The operationName max length
|
||||
# agent.operation_name_threshold=${SW_AGENT_OPERATION_NAME_THRESHOLD:500}
|
||||
|
||||
# Backend service addresses.
|
||||
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:127.0.0.1:11800}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ property key | Description | Default |
|
|||
`agent.active_v1_header `|Deactivate V1 header in default.|`false`|
|
||||
`agent.cool_down_threshold `|How long should the agent wait (in minute) before re-registering to the OAP server after receiving reset command.|`10`|
|
||||
`agent.force_reconnection_period `|Force reconnection period of grpc, based on grpc_channel_check_interval.|`1`|
|
||||
`agent.operation_name_threshold `|The operationName max length, setting this value > 500 is not recommended.|`500`|
|
||||
`collector.grpc_channel_check_interval`|grpc channel status check interval.|`30`|
|
||||
`collector.app_and_service_register_check_interval`|application and service registry check interval.|`3`|
|
||||
`collector.backend_service`|Collector SkyWalking trace receiver service addresses.|`127.0.0.1:11800`|
|
||||
|
|
|
|||
Loading…
Reference in New Issue