From 7c3a3f79baf6cc9cb89c0a99784ddf323a2a61d9 Mon Sep 17 00:00:00 2001
From: Roman Proskuryakov <humbug@deeptown.org>
Date: Wed, 5 May 2021 15:33:52 +0000
Subject: [PATCH] Add a readme about feature metered for sp-utils (#8736)

---
 substrate/primitives/utils/README.md  | 19 ++++++++++++++++++-
 substrate/primitives/utils/src/lib.rs | 17 +++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/substrate/primitives/utils/README.md b/substrate/primitives/utils/README.md
index b0e04a3f4f1..2da70f09ccb 100644
--- a/substrate/primitives/utils/README.md
+++ b/substrate/primitives/utils/README.md
@@ -1,3 +1,20 @@
 Utilities Primitives for Substrate
 
-License: Apache-2.0
\ No newline at end of file
+## Features
+
+### metered
+
+This feature changes the behaviour of the function `mpsc::tracing_unbounded`.
+With the disabled feature this function is an alias to `futures::channel::mpsc::unbounded`.
+However, when the feature is enabled it creates wrapper types to `UnboundedSender<T>`
+and `UnboundedReceiver<T>` to register every `send`/`received`/`dropped` action happened on
+the channel.
+
+Also this feature creates and registers a prometheus vector with name `unbounded_channel_len` and labels:
+
+| Label        | Description                                   |
+| ------------ | --------------------------------------------- |
+| entity       | Name of channel passed to `tracing_unbounded` |
+| action       | One of `send`/`received`/`dropped`            |
+
+License: Apache-2.0
diff --git a/substrate/primitives/utils/src/lib.rs b/substrate/primitives/utils/src/lib.rs
index 430ec1ecb6f..6461361c96d 100644
--- a/substrate/primitives/utils/src/lib.rs
+++ b/substrate/primitives/utils/src/lib.rs
@@ -16,6 +16,23 @@
 // limitations under the License.
 
 //! Utilities Primitives for Substrate
+//!
+//! # Features
+//!
+//! ## metered
+//!
+//! This feature changes the behaviour of the function `mpsc::tracing_unbounded`.
+//! With the disabled feature this function is an alias to `futures::channel::mpsc::unbounded`.
+//! However, when the feature is enabled it creates wrapper types to `UnboundedSender<T>`
+//! and `UnboundedReceiver<T>` to register every `send`/`received`/`dropped` action happened on
+//! the channel.
+//!
+//! Also this feature creates and registers a prometheus vector with name `unbounded_channel_len` and labels:
+//!
+//! | Label        | Description                                   |
+//! | ------------ | --------------------------------------------- |
+//! | entity       | Name of channel passed to `tracing_unbounded` |
+//! | action       | One of `send`/`received`/`dropped`            |
 
 pub mod metrics;
 pub mod mpsc;
-- 
GitLab