// // // Copyright 2023 gRPC authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // #include "src/cpp/ext/otel/otel_plugin.h" #include #include #include #include #include "absl/functional/any_invocable.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "opentelemetry/common/timestamp.h" #include "opentelemetry/metrics/provider.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include #include #include "src/core/lib/channel/call_tracer.h" #include "src/core/lib/config/core_configuration.h" #include "test/core/util/test_config.h" #include "test/cpp/end2end/test_service_impl.h" #include "test/cpp/ext/otel/otel_test_library.h" namespace grpc { namespace testing { namespace { #define GRPC_ARG_SERVER_SELECTOR_KEY "grpc.testing.server_selector_key" #define GRPC_ARG_SERVER_SELECTOR_VALUE "grpc.testing.server_selector_value" template void PopulateLabelMap( T label_keys, T label_values, std::unordered_map* label_maps) { for (size_t i = 0; i < label_keys.size(); ++i) { (*label_maps)[std::string(label_keys[i])] = std::string(label_values[i]); } } MATCHER_P4(AttributesEq, label_keys, label_values, optional_label_keys, optional_label_values, "") { std::unordered_map label_map; PopulateLabelMap(label_keys, label_values, &label_map); PopulateLabelMap(optional_label_keys, optional_label_values, &label_map); return ::testing::ExplainMatchResult( ::testing::UnorderedElementsAreArray(label_map), arg.attributes.GetAttributes(), result_listener); } template struct Extract; template