Skip to content

Commit 99704a4

Browse files
committed
Cleanup
1 parent dbb1921 commit 99704a4

File tree

5 files changed

+105
-16
lines changed

5 files changed

+105
-16
lines changed

exporters/otlp/src/otlp_http_span_builder.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <memory>
66
#include <string>
77

8-
#include "opentelemetry/exporters/otlp/otlp_http.h"
98
#include "opentelemetry/exporters/otlp/otlp_http_exporter_factory.h"
109
#include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h"
1110
#include "opentelemetry/exporters/otlp/otlp_http_span_builder.h"

sdk/include/opentelemetry/sdk/configuration/otlp_http_log_record_exporter_configuration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class OtlpHttpLogRecordExporterConfiguration : public LogRecordExporterConfigura
3636
std::string headers_list;
3737
std::string compression;
3838
size_t timeout{0};
39-
enum_otlp_http_encoding encoding;
39+
enum_otlp_http_encoding encoding{protobuf};
4040
};
4141

4242
} // namespace configuration

sdk/include/opentelemetry/sdk/configuration/otlp_http_span_exporter_configuration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class OtlpHttpSpanExporterConfiguration : public SpanExporterConfiguration
3636
std::string headers_list;
3737
std::string compression;
3838
size_t timeout{0};
39-
enum_otlp_http_encoding encoding;
39+
enum_otlp_http_encoding encoding{protobuf};
4040
};
4141

4242
} // namespace configuration

sdk/src/configuration/configuration_factory.cc

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,21 +1326,74 @@ static std::unique_ptr<AttributesConfiguration> ParseAttributesConfiguration(
13261326

13271327
OTEL_INTERNAL_LOG_ERROR("ParseAttributesConfiguration: FIXME");
13281328

1329-
// Schema has changed
1330-
#ifdef NEVER
1331-
for (auto it = node->begin_properties(); it != node->end_properties(); ++it)
1329+
std::unique_ptr<DocumentNode> attribute_name_value;
1330+
std::unique_ptr<DocumentNode> name_child;
1331+
std::unique_ptr<DocumentNode> value_child;
1332+
std::unique_ptr<DocumentNode> type_child;
1333+
std::string name;
1334+
std::string value;
1335+
std::string type;
1336+
1337+
for (auto it = node->begin(); it != node->end(); ++it)
13321338
{
1333-
std::string name = it.Name();
1334-
std::unique_ptr<DocumentNode> child = it.Value();
1335-
std::string string_value = child->AsString();
1339+
attribute_name_value = *it;
13361340

1337-
OTEL_INTERNAL_LOG_DEBUG(
1338-
"ParseAttributesConfiguration() name = " << name << ", value = " << string_value);
1341+
name_child = attribute_name_value->GetRequiredChildNode("name");
1342+
value_child = attribute_name_value->GetRequiredChildNode("value");
1343+
type_child = attribute_name_value->GetChildNode("type");
13391344

1340-
std::pair<std::string, std::string> entry(name, string_value);
1341-
model->kv_map.insert(entry);
1345+
name = name_child->AsString();
1346+
value = value_child->AsString();
1347+
if (type_child)
1348+
{
1349+
type = type_child->AsString();
1350+
}
1351+
else
1352+
{
1353+
type = "string";
1354+
}
1355+
1356+
if (type == "string")
1357+
{
1358+
OTEL_INTERNAL_LOG_DEBUG("ParseAttributesConfiguration() name = " << name
1359+
<< ", value = " << value);
1360+
std::pair<std::string, std::string> entry(name, value);
1361+
model->kv_map.insert(entry);
1362+
}
1363+
else if (type == "bool")
1364+
{
1365+
OTEL_INTERNAL_LOG_ERROR("ParseAttributesConfiguration: FIXME: bool");
1366+
}
1367+
else if (type == "int")
1368+
{
1369+
OTEL_INTERNAL_LOG_ERROR("ParseAttributesConfiguration: FIXME: int");
1370+
}
1371+
else if (type == "double")
1372+
{
1373+
OTEL_INTERNAL_LOG_ERROR("ParseAttributesConfiguration: FIXME: double");
1374+
}
1375+
else if (type == "string_array")
1376+
{
1377+
OTEL_INTERNAL_LOG_ERROR("ParseAttributesConfiguration: FIXME: string_array");
1378+
}
1379+
else if (type == "bool_array")
1380+
{
1381+
OTEL_INTERNAL_LOG_ERROR("ParseAttributesConfiguration: FIXME: bool_array");
1382+
}
1383+
else if (type == "int_array")
1384+
{
1385+
OTEL_INTERNAL_LOG_ERROR("ParseAttributesConfiguration: FIXME: int_array");
1386+
}
1387+
else if (type == "double_array")
1388+
{
1389+
OTEL_INTERNAL_LOG_ERROR("ParseAttributesConfiguration: FIXME: double_array");
1390+
}
1391+
else
1392+
{
1393+
OTEL_INTERNAL_LOG_ERROR("ParseAttributesConfiguration: unknown type " << type);
1394+
throw InvalidSchemaException("Illegal attribute type");
1395+
}
13421396
}
1343-
#endif
13441397

13451398
return model;
13461399
}

sdk/test/configuration/yaml_resource_test.cc

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ file_format: xx.yy
5050
ASSERT_EQ(config->resource->attributes->kv_map.size(), 0);
5151
}
5252

53-
TEST(YamlResource, some_attributes)
53+
TEST(YamlResource, some_attributes_0_10)
5454
{
55+
// This is the old 0.10 format, must fail
5556
std::string yaml = R"(
5657
file_format: xx.yy
5758
resource:
@@ -60,6 +61,23 @@ file_format: xx.yy
6061
bar: "5678"
6162
)";
6263

64+
auto config = DoParse(yaml);
65+
ASSERT_EQ(config, nullptr);
66+
}
67+
68+
TEST(YamlResource, some_attributes_0_30)
69+
{
70+
// This is the new 0.30 format, must pass
71+
std::string yaml = R"(
72+
file_format: xx.yy
73+
resource:
74+
attributes:
75+
- name: foo
76+
value: "1234"
77+
- name: bar
78+
value: "5678"
79+
)";
80+
6381
auto config = DoParse(yaml);
6482
ASSERT_NE(config, nullptr);
6583
ASSERT_NE(config->resource, nullptr);
@@ -97,8 +115,9 @@ file_format: xx.yy
97115
ASSERT_EQ(config->resource->attributes_list, "foo=1234,bar=5678");
98116
}
99117

100-
TEST(YamlResource, both)
118+
TEST(YamlResource, both_0_10)
101119
{
120+
// This is the old 0.10 format, must fail
102121
std::string yaml = R"(
103122
file_format: xx.yy
104123
resource:
@@ -108,6 +127,24 @@ file_format: xx.yy
108127
attributes_list: "foo=aaaa,bar=bbbb"
109128
)";
110129

130+
auto config = DoParse(yaml);
131+
ASSERT_EQ(config, nullptr);
132+
}
133+
134+
TEST(YamlResource, both_0_30)
135+
{
136+
// This is the new 0.30 format, must pass
137+
std::string yaml = R"(
138+
file_format: xx.yy
139+
resource:
140+
attributes:
141+
- name: foo
142+
value: "1234"
143+
- name: bar
144+
value: "5678"
145+
attributes_list: "foo=aaaa,bar=bbbb"
146+
)";
147+
111148
auto config = DoParse(yaml);
112149
ASSERT_NE(config, nullptr);
113150
ASSERT_NE(config->resource, nullptr);

0 commit comments

Comments
 (0)