Skip to content

Commit

Permalink
Export TimeseriesExporter Type String
Browse files Browse the repository at this point in the history
Summary: This change exports the mapping between the `ExportType` to its string representation. For example `fb303::SUM` to `"sum"`.

Reviewed By: jalopezsilva

Differential Revision: D51224204

fbshipit-source-id: e3be46b3db3fa139275c24c724f23428a7593666
  • Loading branch information
naclander authored and facebook-github-bot committed Nov 28, 2023
1 parent 1d333ab commit 5a580a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fb303/TimeseriesExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ std::array<const char* const, 5> kTypeString = {{
"pct",
}};

/* static */
std::array<const char* const, 5> TimeseriesExporter::getTypeString() {
return kTypeString;
}

/* static */
CounterType TimeseriesExporter::getStatValue(
ExportedStat& stat,
Expand Down Expand Up @@ -97,7 +102,7 @@ void TimeseriesExporter::getCounterName(
"%.*s.%s",
static_cast<int>(statName.size()),
statName.data(),
kTypeString[type]);
TimeseriesExporter::getTypeString()[type]);
} else {
// typical name: 'ad_request.rate.600' or 'ad_request_elapsed_time.avg.3600'
auto durationSecs =
Expand All @@ -108,7 +113,7 @@ void TimeseriesExporter::getCounterName(
"%.*s.%s.%ld",
static_cast<int>(statName.size()),
statName.data(),
kTypeString[type],
TimeseriesExporter::getTypeString()[type],
static_cast<long>(durationSecs.count()));
}
}
Expand Down
2 changes: 2 additions & 0 deletions fb303/TimeseriesExporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class TimeseriesExporter {
ExportType type,
const int level);

static std::array<const char* const, 5> getTypeString();

private:
/*
* Get the specified export value from the specified timeseries level.
Expand Down

0 comments on commit 5a580a6

Please sign in to comment.