1 // Copyright 2023 gRPC authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef GRPC_PYTHON_OPENCENSUS_SERVER_CALL_TRACER_H 16 #define GRPC_PYTHON_OPENCENSUS_SERVER_CALL_TRACER_H 17 18 #include <grpc/support/port_platform.h> 19 20 #include "absl/strings/string_view.h" 21 #include "absl/strings/strip.h" 22 23 #include "src/core/lib/channel/call_tracer.h" 24 #include "src/core/lib/resource_quota/arena.h" 25 #include "src/core/lib/slice/slice.h" 26 27 namespace grpc_observability { 28 29 class PythonOpenCensusServerCallTracerFactory 30 : public grpc_core::ServerCallTracerFactory { 31 public: 32 grpc_core::ServerCallTracer* CreateNewServerCallTracer( 33 grpc_core::Arena* arena, 34 const grpc_core::ChannelArgs& channel_args) override; 35 }; 36 GetMethod(const grpc_core::Slice & path)37inline absl::string_view GetMethod(const grpc_core::Slice& path) { 38 if (path.empty()) { 39 return ""; 40 } 41 // Check for leading '/' and trim it if present. 42 return absl::StripPrefix(path.as_string_view(), "/"); 43 } 44 45 } // namespace grpc_observability 46 47 #endif // GRPC_PYTHON_OPENCENSUS_SERVER_CALL_TRACER_H 48