mirror of https://github.com/grpc/grpc.git
GcpObservability: Add client api latency (#32645)
This PR adds the view `grpc.io/client/api_latency` for GCP Observability which aims to collect the end-to-end time taken by a call. Changes made to support this - 1) A global interceptor factory registration is created for stats plugins. 2) OpenCensus plugin now provides a new interceptor that's responsible for collecting the new latency. 3) Gcp Observability registers this plugin. 4) A new OpenCensus measurement and view is created for api latency. Note that this is internal as of now, since it's not clear if it should be exposed as public experimental API. Leaving that decision for the future. <!-- If you know who should review your pull request, please assign it to that person, otherwise the pull request would get assigned randomly. If your pull request is for a specific language, please add the appropriate lang label. -->pull/32687/head
parent
87818f60fe
commit
bf1a26cde8
22 changed files with 269 additions and 8 deletions
@ -0,0 +1,40 @@ |
||||
//
|
||||
//
|
||||
// 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 <grpcpp/support/client_interceptor.h> |
||||
|
||||
#include "src/core/lib/gprpp/crash.h" |
||||
|
||||
namespace grpc { |
||||
namespace internal { |
||||
|
||||
experimental::ClientInterceptorFactoryInterface* |
||||
g_global_client_stats_interceptor_factory = nullptr; |
||||
|
||||
void RegisterGlobalClientStatsInterceptorFactory( |
||||
grpc::experimental::ClientInterceptorFactoryInterface* factory) { |
||||
if (internal::g_global_client_stats_interceptor_factory != nullptr) { |
||||
grpc_core::Crash( |
||||
"It is illegal to call RegisterGlobalClientStatsInterceptorFactory " |
||||
"multiple times."); |
||||
} |
||||
internal::g_global_client_interceptor_factory = factory; |
||||
} |
||||
|
||||
} // namespace internal
|
||||
} // namespace grpc
|
@ -0,0 +1,33 @@ |
||||
//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef GRPC_SRC_CPP_CLIENT_CLIENT_STATS_INTERCEPTOR_H |
||||
#define GRPC_SRC_CPP_CLIENT_CLIENT_STATS_INTERCEPTOR_H |
||||
|
||||
#include <grpcpp/support/client_interceptor.h> |
||||
|
||||
namespace grpc { |
||||
namespace internal { |
||||
|
||||
void RegisterGlobalClientStatsInterceptorFactory( |
||||
grpc::experimental::ClientInterceptorFactoryInterface* factory); |
||||
|
||||
} |
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPC_SRC_CPP_CLIENT_CLIENT_STATS_INTERCEPTOR_H
|
Loading…
Reference in new issue