Skip to content

Commit b0a0e36

Browse files
Charlie Cookfacebook-github-bot
authored andcommitted
Plug in a function to publish metrics to scuba
Summary: Plugs in the log_metrics_tag pluggable function with an implementation to export metrics to scuba. There is a complexity that the standard loggers have a build dependency on the thrift compiler, meaning the thrift compiler cannot depend on the logger and create a circular dependency. Instead we use the `scribe_cat` cli tool to export the metrics Reviewed By: iahs Differential Revision: D76854422 fbshipit-source-id: e2547240c977b43c1787e8ea3b27bc8e6c2ba87c
1 parent a0c1de1 commit b0a0e36

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

third-party/thrift/src/thrift/compiler/compiler.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ void printUsageTo(FILE* stream) {
8181
-v[erbose] Verbose mode
8282
-r[ecurse] Also generate included files
8383
-debug Parse debug trace to stdout
84+
-no-log-metircs
85+
Do not log metrics.
8486
--allow-neg-keys
8587
Allow negative field keys (IGNORED: always true).
8688
--allow-neg-enum-vals
@@ -682,6 +684,8 @@ std::string parse_args(
682684
}
683685
} else if (flag == "v" || flag == "verbose") {
684686
dparams.info = true;
687+
} else if (flag == "no-log-metrics") {
688+
dparams.log_metrics = false;
685689
} else if (flag == "r" || flag == "recurse") {
686690
gparams.gen_recurse = true;
687691
} else if (flag == "allow-neg-keys") {
@@ -954,8 +958,10 @@ compile_result compile_with_options(
954958
.count();
955959
ctx.metrics().get(detail::metrics::IntValue::RUNTIME).set(duration);
956960

957-
detail::pluggable_functions().call<log_metrics_tag>(
958-
ctx.metrics(), ctx.params());
961+
if (dparams.log_metrics) {
962+
detail::pluggable_functions().call<log_metrics_tag>(
963+
ctx.metrics(), ctx.params());
964+
}
959965
return result;
960966
}
961967

third-party/thrift/src/thrift/compiler/diagnostic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ struct diagnostic_params {
219219
bool debug = false;
220220
bool info = false;
221221
int warn_level = 1;
222+
bool log_metrics = true;
222223

223224
bool should_report(diagnostic_level level) const {
224225
switch (level) {

0 commit comments

Comments
 (0)