// 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 "server_call_tracer.h" #include #include #include #include #include #include #include #include #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" #include "absl/time/clock.h" #include "absl/time/time.h" #include "constants.h" #include "observability_util.h" #include "python_observability_context.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_buffer.h" #include "src/core/lib/transport/metadata_batch.h" #include "src/core/telemetry/call_tracer.h" namespace grpc_observability { namespace { // server metadata elements struct ServerO11yMetadata { grpc_core::Slice path; grpc_core::Slice tracing_slice; grpc_core::Slice census_proto; }; void GetO11yMetadata(const grpc_metadata_batch* b, ServerO11yMetadata* som) { const auto* path = b->get_pointer(grpc_core::HttpPathMetadata()); if (path != nullptr) { som->path = path->Ref(); } if (PythonCensusTracingEnabled()) { const auto* grpc_trace_bin = b->get_pointer(grpc_core::GrpcTraceBinMetadata()); if (grpc_trace_bin != nullptr) { som->tracing_slice = grpc_trace_bin->Ref(); } } if (PythonCensusStatsEnabled()) { const auto* grpc_tags_bin = b->get_pointer(grpc_core::GrpcTagsBinMetadata()); if (grpc_tags_bin != nullptr) { som->census_proto = grpc_tags_bin->Ref(); } } } bool KeyInLabels(std::string key, const std::vector