Skip to content

Commit 13efa83

Browse files
committed
adding tests
1 parent 08d6741 commit 13efa83

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

google/cloud/opentelemetry/internal/monitoring_exporter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ otel_internal::ResourceFilterDataFn MakeFilter(Options const& options) {
3636
return nullptr;
3737
}
3838

39-
// Get the excluded labels list.
39+
// Get the metric labels set to be excluded.
4040
auto const& excluded = options.get<otel::ResourceFilterDataFnOption>();
4141
if (excluded.empty()) return nullptr;
4242

google/cloud/opentelemetry/internal/monitoring_exporter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ class MonitoringExporter final
5151
MonitoringExporter(
5252
std::shared_ptr<monitoring_v3::MetricServiceConnection> conn,
5353
otel_internal::MonitoredResourceFromDataFn dynamic_resource_fn,
54-
otel_internal::ResourceFilterDataFn resource_filter_fn, Options const& options);
54+
otel_internal::ResourceFilterDataFn resource_filter_fn,
55+
Options const& options);
5556

5657
MonitoringExporter(
5758
Project project,

google/cloud/opentelemetry/internal/monitoring_exporter_test.cc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,39 @@ TEST(MonitoringExporter, ExportSuccess) {
159159
EXPECT_EQ(result, opentelemetry::sdk::common::ExportResult::kSuccess);
160160
}
161161

162+
TEST(MonitoringExporterTest, MakeFilterNoOption) {
163+
auto mock =
164+
std::make_shared<monitoring_v3_mocks::MockMetricServiceConnection>();
165+
Options options;
166+
167+
auto exporter = std::make_unique<MonitoringExporter>(Project("test-project"),
168+
mock, options);
169+
EXPECT_NE(exporter, nullptr);
170+
}
171+
172+
TEST(MonitoringExporterTest, MakeFilterEmptySet) {
173+
auto mock =
174+
std::make_shared<monitoring_v3_mocks::MockMetricServiceConnection>();
175+
Options options;
176+
options.set<otel::ResourceFilterDataFnOption>(std::set<std::string>{});
177+
178+
auto exporter = std::make_unique<MonitoringExporter>(Project("test-project"),
179+
mock, options);
180+
EXPECT_NE(exporter, nullptr);
181+
}
182+
183+
TEST(MonitoringExporterTest, MakeFilterWithExcludedKeys) {
184+
auto mock =
185+
std::make_shared<monitoring_v3_mocks::MockMetricServiceConnection>();
186+
Options options;
187+
std::set<std::string> excluded{"service_name", "service_version"};
188+
options.set<otel::ResourceFilterDataFnOption>(excluded);
189+
190+
auto exporter = std::make_unique<MonitoringExporter>(Project("test-project"),
191+
mock, options);
192+
EXPECT_NE(exporter, nullptr);
193+
}
194+
162195
} // namespace
163196
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
164197
} // namespace otel_internal

google/cloud/storage/grpc_plugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct GrpcMetricsExportTimeoutOption {
136136
*
137137
* A set of OpenTelemetry resource attribute keys to exclude from metric labels
138138
* when exporting gRPC telemetry. For example, to exclude the `service.name`
139-
* label, configure the option with `{"service.name"}`.
139+
* label, configure the option with `{"service_name"}`.
140140
*
141141
* @par Example: Exclude specific labels from telemetry
142142
* @code

0 commit comments

Comments
 (0)