Skip to content

Commit

Permalink
Merge branch 'main' into fix_otlp_histogram_max
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo authored Dec 2, 2022
2 parents 1b4ba49 + f23c4a2 commit 4d59b03
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 39 deletions.
20 changes: 2 additions & 18 deletions exporters/otlp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,17 @@ cc_library(
],
)

cc_library(
name = "otlp_grpc_utils",
srcs = [
"src/otlp_grpc_utils.cc",
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_grpc_utils.h",
],
strip_include_prefix = "include",
tags = ["otlp"],
deps = [
"//api",
"//sdk:headers",
"@com_github_grpc_grpc//:grpc++",
],
)

cc_library(
name = "otlp_grpc_client",
srcs = [
"src/otlp_grpc_client.cc",
"src/otlp_grpc_utils.cc",
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_environment.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_client.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_utils.h",
"include/opentelemetry/exporters/otlp/protobuf_include_prefix.h",
"include/opentelemetry/exporters/otlp/protobuf_include_suffix.h",
],
Expand Down Expand Up @@ -111,7 +96,6 @@ cc_library(
deps = [
":otlp_recordable",
":otlp_grpc_client",
":otlp_grpc_utils",
"//ext:headers",
"//sdk/src/trace",

Expand Down
5 changes: 3 additions & 2 deletions exporters/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_library(
opentelemetry_otlp_recordable
src/otlp_log_recordable.cc src/otlp_recordable.cc
src/otlp_populate_attribute_utils.cc src/otlp_recordable_utils.cc
src/otlp_metric_utils.cc src/otlp_grpc_utils.cc)
src/otlp_metric_utils.cc)
set_target_properties(opentelemetry_otlp_recordable PROPERTIES EXPORT_NAME
otlp_recordable)

Expand All @@ -24,7 +24,8 @@ target_link_libraries(opentelemetry_otlp_recordable

if(WITH_OTLP_GRPC)
find_package(gRPC REQUIRED)
add_library(opentelemetry_exporter_otlp_grpc_client src/otlp_grpc_client.cc)
add_library(opentelemetry_exporter_otlp_grpc_client src/otlp_grpc_client.cc
src/otlp_grpc_utils.cc)
set_target_properties(opentelemetry_exporter_otlp_grpc_client
PROPERTIES EXPORT_NAME otlp_grpc_client)
target_link_libraries(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct OtlpGrpcMetricExporterOptions : public OtlpGrpcExporterOptions

// Preferred Aggregation Temporality
sdk::metrics::AggregationTemporality aggregation_temporality =
sdk::metrics::AggregationTemporality::kDelta;
sdk::metrics::AggregationTemporality::kCumulative;
};

} // namespace otlp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct OtlpHttpMetricExporterOptions

// Preferred Aggregation Temporality
sdk::metrics::AggregationTemporality aggregation_temporality =
sdk::metrics::AggregationTemporality::kDelta;
sdk::metrics::AggregationTemporality::kCumulative;

#ifdef ENABLE_ASYNC_EXPORT
// Concurrent requests
Expand Down
34 changes: 17 additions & 17 deletions exporters/otlp/src/otlp_grpc_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,39 @@ const char *grpc_status_code_to_string(::grpc::StatusCode status_code)
{
switch (status_code)
{
case GRPC_STATUS_OK:
case ::grpc::StatusCode::OK:
return "OK";
case GRPC_STATUS_CANCELLED:
case ::grpc::StatusCode::CANCELLED:
return "CANCELLED";
case GRPC_STATUS_UNKNOWN:
case ::grpc::StatusCode::UNKNOWN:
return "UNKNOWN";
case GRPC_STATUS_INVALID_ARGUMENT:
case ::grpc::StatusCode::INVALID_ARGUMENT:
return "INVALID_ARGUMENT";
case GRPC_STATUS_DEADLINE_EXCEEDED:
case ::grpc::StatusCode::DEADLINE_EXCEEDED:
return "DEADLINE_EXCEEDED";
case GRPC_STATUS_NOT_FOUND:
case ::grpc::StatusCode::NOT_FOUND:
return "NOT_FOUND";
case GRPC_STATUS_ALREADY_EXISTS:
case ::grpc::StatusCode::ALREADY_EXISTS:
return "ALREADY_EXISTS";
case GRPC_STATUS_PERMISSION_DENIED:
case ::grpc::StatusCode::PERMISSION_DENIED:
return "PERMISSION_DENIED";
case GRPC_STATUS_UNAUTHENTICATED:
case ::grpc::StatusCode::UNAUTHENTICATED:
return "UNAUTHENTICATED";
case GRPC_STATUS_RESOURCE_EXHAUSTED:
case ::grpc::StatusCode::RESOURCE_EXHAUSTED:
return "RESOURCE_EXHAUSTED";
case GRPC_STATUS_FAILED_PRECONDITION:
case ::grpc::StatusCode::FAILED_PRECONDITION:
return "FAILED_PRECONDITION";
case GRPC_STATUS_ABORTED:
case ::grpc::StatusCode::ABORTED:
return "ABORTED";
case GRPC_STATUS_OUT_OF_RANGE:
case ::grpc::StatusCode::OUT_OF_RANGE:
return "OUT_OF_RANGE";
case GRPC_STATUS_UNIMPLEMENTED:
case ::grpc::StatusCode::UNIMPLEMENTED:
return "UNIMPLEMENTED";
case GRPC_STATUS_INTERNAL:
case ::grpc::StatusCode::INTERNAL:
return "INTERNAL";
case GRPC_STATUS_UNAVAILABLE:
case ::grpc::StatusCode::UNAVAILABLE:
return "UNAVAILABLE";
case GRPC_STATUS_DATA_LOSS:
case ::grpc::StatusCode::DATA_LOSS:
return "DATA_LOSS";
default:
return "UNKNOWN";
Expand Down
22 changes: 22 additions & 0 deletions exporters/otlp/test/otlp_http_metric_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,28 @@ TEST_F(OtlpHttpMetricExporterTestPeer, DefaultEndpoint)
EXPECT_EQ("http://localhost:4318/v1/metrics", GetOtlpDefaultMetricsEndpoint());
}

TEST_F(OtlpHttpMetricExporterTestPeer, CheckDefaultTemporality)
{
std::unique_ptr<OtlpHttpMetricExporter> exporter(new OtlpHttpMetricExporter());
EXPECT_EQ(
opentelemetry::sdk::metrics::AggregationTemporality::kCumulative,
exporter->GetAggregationTemporality(opentelemetry::sdk::metrics::InstrumentType::kCounter));
EXPECT_EQ(
opentelemetry::sdk::metrics::AggregationTemporality::kCumulative,
exporter->GetAggregationTemporality(opentelemetry::sdk::metrics::InstrumentType::kHistogram));
EXPECT_EQ(opentelemetry::sdk::metrics::AggregationTemporality::kCumulative,
exporter->GetAggregationTemporality(
opentelemetry::sdk::metrics::InstrumentType::kUpDownCounter));
EXPECT_EQ(opentelemetry::sdk::metrics::AggregationTemporality::kCumulative,
exporter->GetAggregationTemporality(
opentelemetry::sdk::metrics::InstrumentType::kObservableCounter));
EXPECT_EQ(opentelemetry::sdk::metrics::AggregationTemporality::kCumulative,
exporter->GetAggregationTemporality(
opentelemetry::sdk::metrics::InstrumentType::kObservableGauge));
EXPECT_EQ(opentelemetry::sdk::metrics::AggregationTemporality::kCumulative,
exporter->GetAggregationTemporality(
opentelemetry::sdk::metrics::InstrumentType::kObservableUpDownCounter));
}
#endif

} // namespace otlp
Expand Down

0 comments on commit 4d59b03

Please sign in to comment.