code: private Optional<MetricValue> rewrite_(MetricValue v) {
          return v.asString()
                  .map(pattern_::matcher)
                  .filter(matcher -> matcher.find())
                  .map(this::resolve_template_args_)
                  .map(template_::apply)
                  .map(MetricValue::fromStrValue);
      }
docs: Rewrite a string metric, according to matcher and template.
  Strings that don't match the regexp are omitted.