Skip to content
This repository was archived by the owner on Dec 16, 2020. It is now read-only.

Use StatNameManagedStorage for creating StatName(s).#452

Merged
jplevyak merged 4 commits intoenvoyproxy:masterfrom
jplevyak:remember_stats
Mar 12, 2020
Merged

Use StatNameManagedStorage for creating StatName(s).#452
jplevyak merged 4 commits intoenvoyproxy:masterfrom
jplevyak:remember_stats

Conversation

@jplevyak
Copy link
Contributor

Signed-off-by: John Plevyak jplevyak@gmail.com

Signed-off-by: John Plevyak <jplevyak@gmail.com>
@jplevyak jplevyak requested review from jmarantz and removed request for lizan March 10, 2020 19:36
@jplevyak
Copy link
Contributor Author

@mandarjog

@jplevyak
Copy link
Contributor Author

#451

Signed-off-by: John Plevyak <jplevyak@gmail.com>
@jplevyak jplevyak changed the title Use an intern table for stat names. Use StatNameManagedStorage for creating StatName(s). Mar 10, 2020
Signed-off-by: John Plevyak <jplevyak@gmail.com>
Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm modulo type nit and leaving a TODO for the scope.

WasmResult Context::defineMetric(MetricType type, absl::string_view name, uint32_t* metric_id_ptr) {
auto stat_name = wasm_->stat_name_set_->add(name);
Stats::StatNameManagedStorage storage(name, wasm()->scope_->symbolTable());
auto stat_name = storage.statName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/auto/Stats::StatName/

https://google.github.io/styleguide/cppguide.html#Type_deduction

the type of this is obvious to me personally but will not necessarily be to readers of this code, as it is not derived from context. The type is not onerous either so I think the guideline clearly states that explicit type is preferred here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: nit and added a TODO.

Signed-off-by: John Plevyak <jplevyak@gmail.com>
@jplevyak jplevyak requested a review from jmarantz March 11, 2020 23:32
Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks; looks great. One question, which doesn't block submission in my opinion.

ALL_WASM_STATS(POOL_COUNTER_PREFIX(*scope_, absl::StrCat("wasm.", runtime, ".")),
POOL_GAUGE_PREFIX(*scope_, absl::StrCat("wasm.", runtime, ".")))}),
stat_name_set_(scope_->symbolTable().makeSet("Wasm").release()) {
POOL_GAUGE_PREFIX(*scope_, absl::StrCat("wasm.", runtime, ".")))}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it's OK to take a bunch of locks here, as this does not happen in the request path; is that right?

You can easily code around this if you need to, and I've been mulling over creating a new family of stats-macros for instantiating stats without taking locks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically this is done in the configure path which is coming out of the dispatcher, so same thread, but not (typically) in the request path.

@jplevyak jplevyak merged commit d7fff53 into envoyproxy:master Mar 12, 2020
yxue added a commit to yxue/envoy-wasm that referenced this pull request Mar 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments