Include the customer and project IDs in the generated registry code.
Users will need these to call the new CreateLogger methods that take an
ID instead of a name.
Bug: 36823
Change-Id: Ic2499f144fef2e731f17b1754c3b9fc0325afc5a
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.dart b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.dart
index 1ea361a..b9e8cc2 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.dart
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.dart
@@ -1,7 +1,11 @@
// This file was generated by Cobalt's Config parser based on the configuration
// YAML in the cobalt_config repository. Edit the YAML there to make changes.
const String customerName = 'customer';
+// ignore: constant_identifier_names
+const int customerId = 10;
const String projectName = 'project';
+// ignore: constant_identifier_names
+const int projectId = 5;
// Linear bucket constants for linear buckets
// ignore: constant_identifier_names
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.go b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.go
index f31cc47..acc3cd2 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.go
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.go
@@ -2,7 +2,9 @@
// YAML in the cobalt_config repository. Edit the YAML there to make changes.
package package
const CustomerName string = "customer";
+const CustomerId uint32 = 10;
const ProjectName string = "project";
+const ProjectId uint32 = 5;
// Linear bucket constants for linear buckets
const LinearBucketsIntBucketsFloor int64 = 0;
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.h b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.h
index 42c2591..6072623 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.h
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.h
@@ -6,7 +6,9 @@
#include <cstdint>
const char kCustomerName[] = "customer";
+const uint32_t kCustomerId = 10;
const char kProjectName[] = "project";
+const uint32_t kProjectId = 5;
// Linear bucket constants for linear buckets
const int64_t kLinearBucketsIntBucketsFloor = 0;
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.rs b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.rs
index 9240704..07e7e34 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.rs
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.rs
@@ -1,7 +1,9 @@
// This file was generated by Cobalt's Config parser based on the configuration
// YAML in the cobalt_config repository. Edit the YAML there to make changes.
pub const CUSTOMER_NAME: &str = "customer";
+pub const CUSTOMER_ID: u32 = 10;
pub const PROJECT_NAME: &str = "project";
+pub const PROJECT_ID: u32 = 5;
// Linear bucket constants for linear buckets
pub const LINEAR_BUCKETS_INT_BUCKETS_FLOOR: i64 = 0;
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.dart b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.dart
index 411d930..66eadb5 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.dart
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.dart
@@ -1,7 +1,11 @@
// This file was generated by Cobalt's Config parser based on the configuration
// YAML in the cobalt_config repository. Edit the YAML there to make changes.
const String customerName = 'customer';
+// ignore: constant_identifier_names
+const int customerId = 10;
const String projectName = 'project';
+// ignore: constant_identifier_names
+const int projectId = 5;
// Linear bucket constants for linear buckets
// ignore: constant_identifier_names
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.go b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.go
index dc2c855..44d0ff4 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.go
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.go
@@ -2,7 +2,9 @@
// YAML in the cobalt_config repository. Edit the YAML there to make changes.
package package
const CustomerName string = "customer";
+const CustomerId uint32 = 10;
const ProjectName string = "project";
+const ProjectId uint32 = 5;
// Linear bucket constants for linear buckets
const LinearBucketsIntBucketsFloor int64 = 0;
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.h b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.h
index d7fe05b..2ccc671 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.h
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.h
@@ -6,7 +6,9 @@
#include <cstdint>
const char kCustomerName[] = "customer";
+const uint32_t kCustomerId = 10;
const char kProjectName[] = "project";
+const uint32_t kProjectId = 5;
// Linear bucket constants for linear buckets
const int64_t kLinearBucketsIntBucketsFloor = 0;
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.rs b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.rs
index 88561fe..4fb0e3e 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.rs
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_filtered.cb.rs
@@ -1,7 +1,9 @@
// This file was generated by Cobalt's Config parser based on the configuration
// YAML in the cobalt_config repository. Edit the YAML there to make changes.
pub const CUSTOMER_NAME: &str = "customer";
+pub const CUSTOMER_ID: u32 = 10;
pub const PROJECT_NAME: &str = "project";
+pub const PROJECT_ID: u32 = 5;
// Linear bucket constants for linear buckets
pub const LINEAR_BUCKETS_INT_BUCKETS_FLOOR: i64 = 0;
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.dart b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.dart
index 28c8cc1..8939127 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.dart
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.dart
@@ -1,7 +1,11 @@
// This file was generated by Cobalt's Config parser based on the configuration
// YAML in the cobalt_config repository. Edit the YAML there to make changes.
const String customerName = 'customer';
+// ignore: constant_identifier_names
+const int customerId = 10;
const String projectName = 'project';
+// ignore: constant_identifier_names
+const int projectId = 5;
// Linear bucket constants for linear buckets
// ignore: constant_identifier_names
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.go b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.go
index c0add41..51ee7a0 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.go
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.go
@@ -2,7 +2,9 @@
// YAML in the cobalt_config repository. Edit the YAML there to make changes.
package package
const CustomerName string = "customer";
+const CustomerId uint32 = 10;
const ProjectName string = "project";
+const ProjectId uint32 = 5;
// Linear bucket constants for linear buckets
const LinearBucketsIntBucketsFloor int64 = 0;
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.h b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.h
index 0d3426d..87a361c 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.h
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.h
@@ -6,7 +6,9 @@
#include <cstdint>
const char kCustomerName[] = "customer";
+const uint32_t kCustomerId = 10;
const char kProjectName[] = "project";
+const uint32_t kProjectId = 5;
// Linear bucket constants for linear buckets
const int64_t kLinearBucketsIntBucketsFloor = 0;
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.rs b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.rs
index 782cfc2..98befb6 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.rs
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_for_testing.cb.rs
@@ -1,7 +1,9 @@
// This file was generated by Cobalt's Config parser based on the configuration
// YAML in the cobalt_config repository. Edit the YAML there to make changes.
pub const CUSTOMER_NAME: &str = "customer";
+pub const CUSTOMER_ID: u32 = 10;
pub const PROJECT_NAME: &str = "project";
+pub const PROJECT_ID: u32 = 5;
// Linear bucket constants for linear buckets
pub const LINEAR_BUCKETS_INT_BUCKETS_FLOOR: i64 = 0;
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_with_ns.cb.h b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_with_ns.cb.h
index 1c5da53..07e610d 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_with_ns.cb.h
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_with_ns.cb.h
@@ -7,7 +7,9 @@
namespace ns1::ns2 {
const char kCustomerName[] = "customer";
+const uint32_t kCustomerId = 10;
const char kProjectName[] = "project";
+const uint32_t kProjectId = 5;
// Linear bucket constants for linear buckets
const int64_t kLinearBucketsIntBucketsFloor = 0;
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_with_ns.cb.rs b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_with_ns.cb.rs
index 2e77d18..ee935ea 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_with_ns.cb.rs
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden_with_ns.cb.rs
@@ -2,7 +2,9 @@
// YAML in the cobalt_config repository. Edit the YAML there to make changes.
pub mod ns1::ns2 {
pub const CUSTOMER_NAME: &str = "customer";
+pub const CUSTOMER_ID: u32 = 10;
pub const PROJECT_NAME: &str = "project";
+pub const PROJECT_ID: u32 = 5;
// Linear bucket constants for linear buckets
pub const LINEAR_BUCKETS_INT_BUCKETS_FLOOR: i64 = 0;
diff --git a/src/bin/config_parser/src/source_generator/source_outputter.go b/src/bin/config_parser/src/source_generator/source_outputter.go
index b435fc0..4a62693 100644
--- a/src/bin/config_parser/src/source_generator/source_outputter.go
+++ b/src/bin/config_parser/src/source_generator/source_outputter.go
@@ -277,7 +277,9 @@
func (so *sourceOutputter) writeNames(c *config.CobaltRegistry) {
so.language.writeStringConstant(so, c.Customers[0].CustomerName, "Customer Name")
+ so.language.writeConstUint32(so, c.Customers[0].CustomerId, "Customer Id")
so.language.writeStringConstant(so, c.Customers[0].Projects[0].ProjectName, "Project Name")
+ so.language.writeConstUint32(so, c.Customers[0].Projects[0].ProjectId, "Project Id")
}
func (so *sourceOutputter) writeFile(c, filtered *config.CobaltRegistry) error {
diff --git a/src/logger/internal_metrics_test.cc b/src/logger/internal_metrics_test.cc
index 85bb549..fde7599 100644
--- a/src/logger/internal_metrics_test.cc
+++ b/src/logger/internal_metrics_test.cc
@@ -12,17 +12,17 @@
namespace cobalt::logger {
constexpr int64_t kNumBytes = 123;
-constexpr uint32_t kCustomerId = 1;
-constexpr uint32_t kProjectId = 2;
+constexpr uint32_t kTestCustomerId = 1;
+constexpr uint32_t kTestProjectId = 2;
constexpr uint32_t kMany = 100;
class InternalMetricsImplTest : public ::testing::Test {
public:
Project GetTestProject() {
Project project;
- project.set_customer_id(kCustomerId);
+ project.set_customer_id(kTestCustomerId);
project.set_customer_name("test");
- project.set_project_id(kProjectId);
+ project.set_project_id(kTestProjectId);
project.set_project_name("project");
return project;
}
@@ -84,7 +84,7 @@
ASSERT_EQ(logger.call_count(), 0);
metrics.BytesUploaded(PerProjectBytesUploadedMetricDimensionStatus::Attempted, kNumBytes,
- kCustomerId, kProjectId);
+ kTestCustomerId, kTestProjectId);
ASSERT_EQ(logger.call_count(), 1);
ASSERT_TRUE(logger.last_event_logged().has_count_event());
@@ -98,7 +98,7 @@
metrics.PauseLogging();
for (int i = 0; i < kMany; i++) {
metrics.BytesUploaded(PerProjectBytesUploadedMetricDimensionStatus::Attempted, kNumBytes,
- kCustomerId, kProjectId);
+ kTestCustomerId, kTestProjectId);
}
metrics.ResumeLogging();
ASSERT_EQ(logger.call_count(), 0);
@@ -109,8 +109,8 @@
InternalMetricsImpl metrics(&logger);
ASSERT_EQ(logger.call_count(), 0);
- metrics.BytesStored(PerProjectBytesStoredMetricDimensionStatus::Attempted, kNumBytes, kCustomerId,
- kProjectId);
+ metrics.BytesStored(PerProjectBytesStoredMetricDimensionStatus::Attempted, kNumBytes,
+ kTestCustomerId, kTestProjectId);
ASSERT_EQ(logger.call_count(), 1);
ASSERT_TRUE(logger.last_event_logged().has_memory_usage_event());
@@ -124,7 +124,7 @@
metrics.PauseLogging();
for (int i = 0; i < kMany; i++) {
metrics.BytesStored(PerProjectBytesStoredMetricDimensionStatus::Attempted, kNumBytes,
- kCustomerId, kProjectId);
+ kTestCustomerId, kTestProjectId);
}
metrics.ResumeLogging();
ASSERT_EQ(logger.call_count(), 0);