envoyproxy/envoy

stats: inconsistent handling of multiple consecutive dots in stat-names produced via join vs direct encoding

Open

#10.008 geöffnet am 11. Feb. 2020

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (1 zugewiesene Person)C++ (5.373 Forks)batch import
area/statshelp wanted

Repository-Metriken

Stars
 (27.997 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 8T) (378 gemergte PRs in 30 T)

Beschreibung

You can create a multi-segment stat-name by directly encoding it into the table, or by joining multiple existing stat names.

When you encode directly, you can wind up with multiple consecutive dots. When you construct by joining, you can't. The testcase in this commit illustrates the problem:

https://github.com/jmarantz/envoy/commit/6e7367c522c2fb5e77bb1d59cb54817e039bd9c3

TEST_P(StatNameTest, TestIgnoreTrailingDots) {
  EXPECT_EQ("foo.bar", encodeDecode("foo.bar."));
  EXPECT_EQ("foo.bar", encodeDecode("foo.bar..."));
  EXPECT_EQ("foo..bar", encodeDecode("foo..bar"));
  EXPECT_EQ("foo...bar", encodeDecode("foo...bar"));

  StatNamePool pool(*table_);
  SymbolTable::StoragePtr joined = table_->join({makeStat("a"), makeStat(""), makeStat("b")});
  EXPECT_EQ("a..b", table_->toString(StatName(joined.get())));   // FAILS, will be "a.b".

  EXPECT_EQ("", encodeDecode("."));
  EXPECT_EQ("", encodeDecode(".."));
}

Contributor Guide