33import static datadog .trace .bootstrap .instrumentation .decorator .http .HttpResourceDecorator .HTTP_RESOURCE_DECORATOR ;
44
55import datadog .context .Context ;
6+ import datadog .trace .bootstrap .config .provider .ConfigProvider ;
67import datadog .trace .bootstrap .instrumentation .api .AgentPropagation ;
78import datadog .trace .bootstrap .instrumentation .api .AgentSpan ;
89import datadog .trace .bootstrap .instrumentation .api .URIDataAdapter ;
@@ -27,6 +28,8 @@ public class SpringWebHttpServerDecorator
2728 // source for limits: https://docs.datadoghq.com/tracing/troubleshooting
2829 static final int VIEW_NAME_RESOURCE_LIMIT = 5_000 ;
2930 static final int VIEW_NAME_TAG_LIMIT = 25_000 ;
31+ private static final boolean VIEW_NAME_ENABLED =
32+ ConfigProvider .getInstance ().getBoolean ("trace.spring-web.view-name.enabled" , true );
3033
3134 private static final CharSequence SPRING_HANDLER = UTF8BytesString .create ("spring.handler" );
3235 public static final CharSequence RESPONSE_RENDER = UTF8BytesString .create ("response.render" );
@@ -151,10 +154,12 @@ private String getMethodName(final Object handler) {
151154 }
152155
153156 public AgentSpan onRender (final AgentSpan span , final ModelAndView mv ) {
154- final String viewName = mv .getViewName ();
155- if (viewName != null ) {
156- span .setTag ("view.name" , Strings .truncate (viewName , VIEW_NAME_TAG_LIMIT ));
157- span .setResourceName (Strings .truncate (viewName , VIEW_NAME_RESOURCE_LIMIT ));
157+ if (VIEW_NAME_ENABLED ) {
158+ final String viewName = mv .getViewName ();
159+ if (viewName != null ) {
160+ span .setTag ("view.name" , Strings .truncate (viewName , VIEW_NAME_TAG_LIMIT ));
161+ span .setResourceName (Strings .truncate (viewName , VIEW_NAME_RESOURCE_LIMIT ));
162+ }
158163 }
159164 if (mv .getView () != null ) {
160165 span .setTag ("view.type" , className (mv .getView ().getClass ()));
0 commit comments