in prod/native/libphpbridge/code/OtlpExporter/MetricConverter.h [217:246]
opentelemetry::proto::metrics::v1::AggregationTemporality convertTemporality(AutoZval const &val) {
using opentelemetry::proto::metrics::v1::AggregationTemporality;
if (val.isLong()) {
switch (val.getLong()) {
case 1:
return AggregationTemporality::AGGREGATION_TEMPORALITY_DELTA;
case 2:
return AggregationTemporality::AGGREGATION_TEMPORALITY_CUMULATIVE;
case 0:
default:
return AggregationTemporality::AGGREGATION_TEMPORALITY_UNSPECIFIED;
}
}
using namespace elasticapm::utils::string_view_literals;
if (val.isString()) {
auto iStr = elasticapm::utils::traits_cast<elasticapm::utils::CiCharTraits>(val.getStringView());
if (iStr == "Delta"_cisv) {
return AggregationTemporality::AGGREGATION_TEMPORALITY_DELTA;
} else if (iStr == "Cumulative"_cisv) {
return AggregationTemporality::AGGREGATION_TEMPORALITY_CUMULATIVE;
} else {
return AggregationTemporality::AGGREGATION_TEMPORALITY_UNSPECIFIED;
}
}
throw std::runtime_error("Invalid temporality value: expected int or string (DELTA, CUMULATIVE, UNSPECIFIED)");
}