Merge pull request #92 from palazzem/resource-rewriting-cast

[decorators] fixed URLAsResourceName when the cast fails
This commit is contained in:
Emanuele Palazzetti 2017-08-04 13:16:09 +02:00 committed by GitHub
commit abaf24451f
1 changed files with 20 additions and 22 deletions

View File

@ -44,10 +44,12 @@ public class URLAsResourceName extends AbstractDecorator {
@Override
public boolean afterSetTag(final DDSpanContext context, final String tag, final Object value) {
try {
final String statusCode = (String) context.getTags().get(Tags.HTTP_STATUS.getKey());
final String statusCode = String.valueOf(context.getTags().get(Tags.HTTP_STATUS.getKey()));
// do nothing if the status code is already set and equals to 404.
// TODO: it assumes that Status404Decorator is active. If it's not, it will lead to unexpected behaviors
if (statusCode != null && statusCode.equals("404")) {
return true;
}
// Get the path without host:port
String path = String.valueOf(value);
@ -66,12 +68,8 @@ public class URLAsResourceName extends AbstractDecorator {
path = verb + " " + path;
}
//Assign resource name
context.setResourceName(path);
}
} catch (final Throwable e) {
return false;
}
return true;