userver: userver/ugrpc/client/middlewares/log/component.hpp Source File
Loading...
Searching...
No Matches
component.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/ugrpc/client/middlewares/log/component.hpp
4/// @brief @copybrief ugrpc::client::middlewares::log::Component
5
6#include <userver/ugrpc/client/middlewares/base.hpp>
7
8USERVER_NAMESPACE_BEGIN
9
10/// Client logging middleware
11namespace ugrpc::client::middlewares::log {
12
13struct Settings;
14
15// clang-format off
16
17/// @ingroup userver_components
18///
19/// @brief Component for gRPC client logging
20///
21/// @warning Logs are currently written with log level `debug` by default, which typically means that they are not
22/// written in production. See details below.
23///
24/// ## Static options:
25/// Name | Description | Default value
26/// ---- | ----------- | -------------
27/// log-level | log level to use for `Span`, status code and the facts of sending requests receiving responses arriving | debug
28/// msg-log-level | log level to use for request and response messages themselves | debug
29/// msg-size-log-limit | max message size to log, the rest will be truncated | 512
30/// trim-secrets | trim the secrets from logs as marked by the protobuf option | true (*)
31///
32/// @warning * Trimming secrets causes a segmentation fault for messages that contain
33/// optional fields in protobuf versions prior to 3.13. You should set trim-secrets to false
34/// if this is the case for you. See https://github.com/protocolbuffers/protobuf/issues/7801
35///
36/// ## Static configuration example:
37///
38/// @snippet grpc/functional_tests/basic_chaos/static_config.yaml Sample grpc client logging middleware component config
39///
40/// In this example, we enable logs for gRPC clients in production.
41
42// clang-format on
43
44class Component final : public MiddlewareFactoryComponentBase {
45public:
46 /// @ingroup userver_component_names
47 /// @brief The default name of ugrpc::client::middlewares::log::Component.
48 static constexpr std::string_view kName = "grpc-client-logging";
49
50 Component(const components::ComponentConfig& config, const components::ComponentContext& context);
51
52 ~Component() override;
53
54 static yaml_config::Schema GetStaticConfigSchema();
55
57
58 std::shared_ptr<MiddlewareBase>
59 CreateMiddleware(const ugrpc::client::ClientInfo&, const yaml_config::YamlConfig& middleware_config) const override;
60};
61
62} // namespace ugrpc::client::middlewares::log
63
64template <>
65inline constexpr bool components::kHasValidate<ugrpc::client::middlewares::log::Component> = true;
66
67template <>
68inline constexpr auto components::kConfigFileMode<ugrpc::client::middlewares::log::Component> =
70
71USERVER_NAMESPACE_END