• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 //
3 // Copyright 2018 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18 
19 #ifndef GRPC_SRC_CPP_EXT_FILTERS_CENSUS_CLIENT_FILTER_H
20 #define GRPC_SRC_CPP_EXT_FILTERS_CENSUS_CLIENT_FILTER_H
21 
22 #include <grpc/support/port_platform.h>
23 #include <grpcpp/support/client_interceptor.h>
24 #include <grpcpp/support/interceptor.h>
25 
26 #include "absl/status/statusor.h"
27 #include "src/core/lib/channel/channel_args.h"
28 #include "src/core/lib/channel/channel_fwd.h"
29 #include "src/core/lib/channel/promise_based_filter.h"
30 #include "src/core/lib/promise/arena_promise.h"
31 #include "src/core/lib/transport/transport.h"
32 
33 namespace grpc {
34 namespace internal {
35 
36 class OpenCensusClientFilter : public grpc_core::ChannelFilter {
37  public:
38   static const grpc_channel_filter kFilter;
39 
TypeName()40   static absl::string_view TypeName() { return "opencensus_client"; }
41 
42   static absl::StatusOr<std::unique_ptr<OpenCensusClientFilter>> Create(
43       const grpc_core::ChannelArgs& args, ChannelFilter::Args /*filter_args*/);
44 
OpenCensusClientFilter(bool tracing_enabled)45   explicit OpenCensusClientFilter(bool tracing_enabled)
46       : tracing_enabled_(tracing_enabled) {}
47 
48   grpc_core::ArenaPromise<grpc_core::ServerMetadataHandle> MakeCallPromise(
49       grpc_core::CallArgs call_args,
50       grpc_core::NextPromiseFactory next_promise_factory) override;
51 
52  private:
53   bool tracing_enabled_ = true;
54 };
55 
56 class OpenCensusClientInterceptorFactory
57     : public grpc::experimental::ClientInterceptorFactoryInterface {
58  public:
59   grpc::experimental::Interceptor* CreateClientInterceptor(
60       grpc::experimental::ClientRpcInfo* info) override;
61 };
62 
63 }  // namespace internal
64 }  // namespace grpc
65 
66 #endif  // GRPC_SRC_CPP_EXT_FILTERS_CENSUS_CLIENT_FILTER_H
67