Skip to content

Commit

Permalink
run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglas Barker committed Dec 5, 2024
1 parent 7308922 commit d6317b5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion exporters/otlp/src/otlp_metric_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void OtlpMetricUtils::PopulateResourceMetrics(
proto::common::v1::InstrumentationScope *scope = scope_lib_metrics->mutable_scope();
scope->set_name(scope_metrics.scope_->GetName());
scope->set_version(scope_metrics.scope_->GetVersion());
scope_lib_metrics->set_schema_url(scope_metrics.scope_->GetSchemaURL());
scope_lib_metrics->set_schema_url(scope_metrics.scope_->GetSchemaURL());

OtlpPopulateAttributeUtils::PopulateAttribute(scope, *scope_metrics.scope_);

Expand Down
32 changes: 16 additions & 16 deletions exporters/otlp/test/otlp_file_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ static nostd::span<T, N> MakeSpan(T (&array)[N])
class OtlpFileExporterTestPeer : public ::testing::Test
{
public:

void ExportJsonIntegrationTest()
{
static ProtobufGlobalSymbolGuard global_symbol_guard;
Expand Down Expand Up @@ -109,12 +108,13 @@ class OtlpFileExporterTestPeer : public ::testing::Test
new sdk::trace::TracerProvider(std::move(processor), resource));

std::string report_trace_id;

#if OPENTELEMETRY_ABI_VERSION_NO >= 2
auto tracer = provider->GetTracer("scope_name", "scope_version", "scope_url", {{"scope_key", "scope_value"}});

#if OPENTELEMETRY_ABI_VERSION_NO >= 2
auto tracer = provider->GetTracer("scope_name", "scope_version", "scope_url",
{{ "scope_key",
"scope_value" }});
#else
auto tracer =
provider->GetTracer("scope_name", "scope_version", "scope_url");
auto tracer = provider->GetTracer("scope_name", "scope_version", "scope_url");
#endif

auto parent_span = tracer->StartSpan("Test parent span");
Expand Down Expand Up @@ -146,19 +146,19 @@ class OtlpFileExporterTestPeer : public ::testing::Test
{
auto resource_span = *check_json["resourceSpans"].begin();
auto scope_span = *resource_span["scopeSpans"].begin();
auto scope = scope_span["scope"];
auto scope = scope_span["scope"];
auto span = *scope_span["spans"].begin();

#if OPENTELEMETRY_ABI_VERSION_NO >= 2
ASSERT_EQ(1, scope["attributes"].size());
const auto scope_attribute = scope["attributes"].front();
EXPECT_EQ("scope_key", scope_attribute["key"].get<std::string>());
EXPECT_EQ("scope_value", scope_attribute["value"]["stringValue"].get<std::string>());
ASSERT_EQ(1, scope["attributes"].size());
const auto scope_attribute = scope["attributes"].front();
EXPECT_EQ("scope_key", scope_attribute["key"].get<std::string>());
EXPECT_EQ("scope_value", scope_attribute["value"]["stringValue"].get<std::string>());
#endif
EXPECT_EQ("resource_url", resource_span["schemaUrl"].get<std::string>());
EXPECT_EQ("scope_url", scope_span["schemaUrl"].get<std::string>());
EXPECT_EQ("scope_name", scope["name"].get<std::string>());
EXPECT_EQ("scope_version", scope["version"].get<std::string>());
EXPECT_EQ("resource_url", resource_span["schemaUrl"].get<std::string>());
EXPECT_EQ("scope_url", scope_span["schemaUrl"].get<std::string>());
EXPECT_EQ("scope_name", scope["name"].get<std::string>());
EXPECT_EQ("scope_version", scope["version"].get<std::string>());
EXPECT_EQ(report_trace_id, span["traceId"].get<std::string>());
}
else
Expand Down
12 changes: 5 additions & 7 deletions exporters/otlp/test/otlp_file_metric_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class OtlpFileMetricExporterTestPeer : public ::testing::Test
opentelemetry::sdk::resource::ResourceAttributes{}, resource_schema_url);
data.resource_ = &resource;

const std::string instrumentation_scope_name{"library_name"};
const std::string instrumentation_scope_version{"1.5.0"};
const std::string instrumentation_scope_name{"library_name"};
const std::string instrumentation_scope_version{"1.5.0"};
const std::string instrumentation_scope_schema_url{"https://opentelemetry.io/schemas/1.2.0"};

auto scope = opentelemetry::sdk::instrumentationscope::InstrumentationScope::Create(
Expand Down Expand Up @@ -130,18 +130,16 @@ class OtlpFileMetricExporterTestPeer : public ::testing::Test
auto resource_metrics = *check_json["resourceMetrics"].begin();
auto scope_metrics = *resource_metrics["scopeMetrics"].begin();
auto scope = scope_metrics["scope"];


EXPECT_EQ(resource_schema_url, resource_metrics["schemaUrl"].get<std::string>());

EXPECT_EQ(instrumentation_scope_schema_url, scope_metrics["schemaUrl"].get<std::string>());
EXPECT_EQ(instrumentation_scope_name, scope["name"].get<std::string>());
EXPECT_EQ(instrumentation_scope_version, scope["version"].get<std::string>());
ASSERT_EQ(1, scope["attributes"].size());
const auto scope_attribute = scope["attributes"].front();
EXPECT_EQ("scope_key", scope_attribute["key"].get<std::string>());
EXPECT_EQ("scope_value", scope_attribute["value"]["stringValue"].get<std::string>());

const auto scope_attribute = scope["attributes"].front();
EXPECT_EQ("scope_key", scope_attribute["key"].get<std::string>());
EXPECT_EQ("scope_value", scope_attribute["value"]["stringValue"].get<std::string>());

auto metric = *scope_metrics["metrics"].begin();
EXPECT_EQ("metrics_library_name", metric["name"].get<std::string>());
Expand Down
13 changes: 7 additions & 6 deletions exporters/otlp/test/otlp_recordable_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ TEST(OtlpRecordable, SetInstrumentationScopeWithAttributes)

ASSERT_EQ(proto_instr_libr.attributes_size(), 1);
const auto &proto_attributes = proto_instr_libr.attributes(0);
ASSERT_TRUE(proto_attributes.value().has_string_value());
ASSERT_TRUE(proto_attributes.value().has_string_value());
EXPECT_EQ("test_key", proto_attributes.key());
EXPECT_EQ("test_value", proto_attributes.value().string_value());
}
Expand Down Expand Up @@ -346,7 +346,8 @@ TEST(OtlpRecordable, PopulateRequest)
auto rec1 = std::unique_ptr<sdk::trace::Recordable>(new OtlpRecordable);
auto resource1 = resource::Resource::Create({{"service.name", "one"}});
rec1->SetResource(resource1);
auto inst_lib1 = trace_sdk::InstrumentationScope::Create("one", "1", "scope_schema", {{"scope_key", "scope_value"}});
auto inst_lib1 = trace_sdk::InstrumentationScope::Create("one", "1", "scope_schema",
{{"scope_key", "scope_value"}});
rec1->SetInstrumentationScope(*inst_lib1);

auto rec2 = std::unique_ptr<sdk::trace::Recordable>(new OtlpRecordable);
Expand All @@ -372,20 +373,20 @@ TEST(OtlpRecordable, PopulateRequest)
EXPECT_EQ(req.resource_spans().size(), 2);
for (const auto &resource_spans : req.resource_spans())
{
ASSERT_GT(resource_spans.resource().attributes_size(), 0);
ASSERT_GT(resource_spans.resource().attributes_size(), 0);
const auto service_name = resource_spans.resource().attributes(0).value().string_value();
const auto scope_spans_size = resource_spans.scope_spans().size();
if (service_name == "one")
{
ASSERT_GT(resource_spans.scope_spans_size(), 0);
const auto& scope_one = resource_spans.scope_spans(0).scope();
ASSERT_GT(resource_spans.scope_spans_size(), 0);
const auto &scope_one = resource_spans.scope_spans(0).scope();

EXPECT_EQ(scope_spans_size, 1);
EXPECT_EQ(scope_one.name(), "one");
EXPECT_EQ(scope_one.version(), "1");

ASSERT_EQ(scope_one.attributes_size(), 1);
const auto& scope_attribute = scope_one.attributes(0);
const auto &scope_attribute = scope_one.attributes(0);

EXPECT_EQ(scope_attribute.key(), "scope_key");
EXPECT_EQ(scope_attribute.value().string_value(), "scope_value");
Expand Down

0 comments on commit d6317b5

Please sign in to comment.