Skip to content

Commit

Permalink
working on it
Browse files Browse the repository at this point in the history
  • Loading branch information
jpihl committed Feb 2, 2025
1 parent 3152d6e commit 59c38c9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/abacus/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ metrics::metrics(const std::map<name, abacus::info>& infos)
assert(false && "Unknown type");
},
m->value);
m_initialized[name.value] = true;
}

m_metadata.mutable_metrics()->insert({name.value, metric});
Expand Down
45 changes: 22 additions & 23 deletions test/src/test_metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ TEST(test_metrics, api)

EXPECT_EQ(metrics.metadata().metrics().at(name4).constant().value_case(),
abacus::protobuf::Constant::ValueCase::kBoolean);
EXPECT_EQ(metrics.metadata().metrics().at(name4).boolean().description(),
EXPECT_EQ(metrics.metadata().metrics().at(name4).constant().description(),
"A constant boolean metric");
EXPECT_EQ(metrics.metadata().metrics().at(name4).boolean().unit(),
EXPECT_EQ(metrics.metadata().metrics().at(name4).constant().unit(),
""); // empty unit

EXPECT_EQ(metrics.metadata().metrics().at(name5).constant().value_case(),
abacus::protobuf::Constant::ValueCase::kFloat64);

EXPECT_EQ(metrics.metadata().metrics().at(name5).float64().description(),
EXPECT_EQ(metrics.metadata().metrics().at(name5).constant().description(),
"A constant floating point metric");
EXPECT_EQ(metrics.metadata().metrics().at(name5).float64().unit(), "ms");
EXPECT_EQ(metrics.metadata().metrics().at(name5).constant().unit(), "ms");

EXPECT_EQ(metrics.metadata().metrics().at(name6).enum8().description(),
"An enum metric");
Expand Down Expand Up @@ -218,7 +218,7 @@ TEST(test_metrics, value_and_metadata_bytes)
(void)m0;
(void)m1;

EXPECT_EQ(metrics.metadata().ByteSizeLong(), 114U);
EXPECT_EQ(metrics.metadata().ByteSizeLong(), 112);
EXPECT_EQ(metrics.value_bytes(),
sizeof(uint32_t) + // hash
1 + sizeof(uint64_t) + // metric0 has_value + value
Expand Down Expand Up @@ -272,23 +272,22 @@ TEST(test_metrics, reset_counters)
}

static const std::vector<uint8_t> expected_metadata = {
0x08, 0x02, 0x1d, 0x8d, 0x25, 0xed, 0x54, 0x22, 0x2e, 0x0a, 0x07, 0x6d,
0x65, 0x74, 0x72, 0x69, 0x63, 0x32, 0x12, 0x23, 0x3a, 0x21, 0x08, 0x16,
0x12, 0x17, 0x41, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x69, 0x6e, 0x67,
0x20, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x20, 0x6d, 0x65, 0x74, 0x72, 0x69,
0x63, 0x1a, 0x00, 0x32, 0x02, 0x6d, 0x73, 0x22, 0x34, 0x0a, 0x07, 0x6d,
0x65, 0x74, 0x72, 0x69, 0x63, 0x30, 0x12, 0x29, 0x1a, 0x27, 0x08, 0x04,
0x12, 0x1a, 0x41, 0x6e, 0x20, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65,
0x64, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x20, 0x6d, 0x65,
0x74, 0x72, 0x69, 0x63, 0x22, 0x00, 0x32, 0x05, 0x62, 0x79, 0x74, 0x65,
0x73, 0x22, 0x23, 0x0a, 0x07, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x33,
0x12, 0x18, 0x4a, 0x16, 0x08, 0x1f, 0x12, 0x10, 0x41, 0x20, 0x62, 0x6f,
0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x20, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63,
0x1a, 0x00, 0x22, 0x2f, 0x0a, 0x07, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63,
0x31, 0x12, 0x24, 0x22, 0x22, 0x08, 0x0d, 0x12, 0x17, 0x41, 0x20, 0x73,
0x69, 0x67, 0x6e, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65,
0x72, 0x20, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x1a, 0x00, 0x32, 0x03,
0x55, 0x53, 0x44,
0x08, 0x02, 0x1d, 0xa6, 0xbc, 0x77, 0x0c, 0x22, 0x2d, 0x0a, 0x07, 0x6d,
0x65, 0x74, 0x72, 0x69, 0x63, 0x31, 0x12, 0x22, 0x1a, 0x20, 0x08, 0x0d,
0x12, 0x17, 0x41, 0x20, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x20, 0x69,
0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x20, 0x6d, 0x65, 0x74, 0x72, 0x69,
0x63, 0x2a, 0x03, 0x55, 0x53, 0x44, 0x22, 0x34, 0x0a, 0x07, 0x6d, 0x65,
0x74, 0x72, 0x69, 0x63, 0x30, 0x12, 0x29, 0x12, 0x27, 0x08, 0x04, 0x12,
0x1a, 0x41, 0x6e, 0x20, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64,
0x20, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x20, 0x6d, 0x65, 0x74,
0x72, 0x69, 0x63, 0x20, 0x01, 0x2a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73,
0x22, 0x21, 0x0a, 0x07, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x33, 0x12,
0x16, 0x42, 0x14, 0x08, 0x1f, 0x12, 0x10, 0x41, 0x20, 0x62, 0x6f, 0x6f,
0x6c, 0x65, 0x61, 0x6e, 0x20, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x22,
0x2c, 0x0a, 0x07, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x32, 0x12, 0x21,
0x32, 0x1f, 0x08, 0x16, 0x12, 0x17, 0x41, 0x20, 0x66, 0x6c, 0x6f, 0x61,
0x74, 0x69, 0x6e, 0x67, 0x20, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x20, 0x6d,
0x65, 0x74, 0x72, 0x69, 0x63, 0x2a, 0x02, 0x6d, 0x73,
};

static const std::vector<uint8_t> expected_value_data = {
Expand Down

0 comments on commit 59c38c9

Please sign in to comment.