Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
move Metrics to utils (#1765)
Browse files Browse the repository at this point in the history
  • Loading branch information
ordian authored Sep 29, 2020
1 parent ec55686 commit 77d04d4
Show file tree
Hide file tree
Showing 29 changed files with 99 additions and 120 deletions.
7 changes: 6 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions node/collation-generation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ use polkadot_node_primitives::CollationGenerationConfig;
use polkadot_node_subsystem::{
messages::{AllMessages, CollationGenerationMessage, CollatorProtocolMessage},
FromOverseer, SpawnedSubsystem, Subsystem, SubsystemContext, SubsystemResult,
metrics::{self, prometheus},
};
use polkadot_node_subsystem_util::{
request_availability_cores_ctx, request_full_validation_data_ctx,
request_validators_ctx,
metrics::{self, prometheus},
};
use polkadot_primitives::v1::{
collator_signature_payload, AvailableData, CandidateCommitments,
Expand Down Expand Up @@ -164,8 +164,6 @@ impl<Context> Subsystem<Context> for CollationGenerationSubsystem
where
Context: SubsystemContext<Message = CollationGenerationMessage>,
{
type Metrics = Metrics;

fn start(self, ctx: Context) -> SpawnedSubsystem {
let future = Box::pin(self.run(ctx));

Expand Down
15 changes: 9 additions & 6 deletions node/core/av-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

[dependencies]
derive_more = "0.99.9"
futures = "0.3.5"
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" }
polkadot-overseer = { path = "../../overseer" }
polkadot-primitives = { path = "../../../primitives" }
erasure = { package = "polkadot-erasure-coding", path = "../../../erasure-coding" }
log = "0.4.8"

kvdb = "0.7.0"
kvdb-rocksdb = "0.9.1"
codec = { package = "parity-scale-codec", version = "1.3.1", features = ["derive"] }
log = "0.4.8"
derive_more = "0.99.9"

erasure = { package = "polkadot-erasure-coding", path = "../../../erasure-coding" }
polkadot-overseer = { path = "../../overseer" }
polkadot-primitives = { path = "../../../primitives" }
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" }
polkadot-node-subsystem-util = { path = "../../subsystem-util" }

[dev-dependencies]
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
4 changes: 2 additions & 2 deletions node/core/av-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ use polkadot_primitives::v1::{
};
use polkadot_subsystem::{
FromOverseer, SubsystemError, Subsystem, SubsystemContext, SpawnedSubsystem,
};
use polkadot_node_subsystem_util::{
metrics::{self, prometheus},
};
use polkadot_subsystem::messages::AvailabilityStoreMessage;
Expand Down Expand Up @@ -276,8 +278,6 @@ impl<Context> Subsystem<Context> for AvailabilityStoreSubsystem
where
Context: SubsystemContext<Message=AvailabilityStoreMessage>,
{
type Metrics = Metrics;

fn start(self, ctx: Context) -> SpawnedSubsystem {
let future = Box::pin(async move {
if let Err(e) = run(self, ctx).await {
Expand Down
2 changes: 1 addition & 1 deletion node/core/backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ use polkadot_subsystem::{
ProvisionerMessage, RuntimeApiMessage, StatementDistributionMessage, ValidationFailed,
RuntimeApiRequest,
},
metrics::{self, prometheus},
};
use polkadot_node_subsystem_util::{
self as util,
Expand All @@ -55,6 +54,7 @@ use polkadot_node_subsystem_util::{
request_from_runtime,
Validator,
delegated_subsystem,
metrics::{self, prometheus},
};
use statement_table::{
generic::AttestedCandidate as TableAttestedCandidate,
Expand Down
4 changes: 2 additions & 2 deletions node/core/bitfield-signing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ use polkadot_node_subsystem::{
BitfieldSigningMessage, CandidateBackingMessage, RuntimeApiMessage,
},
errors::RuntimeApiError,
metrics::{self, prometheus},
};
use polkadot_node_subsystem_util::{
self as util, JobManager, JobTrait, ToJobTrait, Validator
self as util, JobManager, JobTrait, ToJobTrait, Validator,
metrics::{self, prometheus},
};
use polkadot_primitives::v1::{AvailabilityBitfield, CoreState, Hash, ValidatorIndex};
use std::{convert::TryFrom, pin::Pin, time::Duration};
Expand Down
4 changes: 3 additions & 1 deletion node/core/candidate-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ use polkadot_node_subsystem::{
AllMessages, CandidateBackingMessage, CandidateSelectionMessage,
CandidateValidationMessage, CollatorProtocolMessage,
},
};
use polkadot_node_subsystem_util::{
self as util, delegated_subsystem, JobTrait, ToJobTrait,
metrics::{self, prometheus},
};
use polkadot_node_subsystem_util::{self as util, delegated_subsystem, JobTrait, ToJobTrait};
use polkadot_primitives::v1::{
CandidateDescriptor, CandidateReceipt, CollatorId, Hash, Id as ParaId, PoV,
};
Expand Down
6 changes: 4 additions & 2 deletions node/core/candidate-validation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

[dependencies]
derive_more = "0.99.9"
futures = "0.3.5"
log = "0.4.8"

sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { package = "sp-core", git = "https://github.com/paritytech/substrate", branch = "master" }
parity-scale-codec = { version = "1.3.0", default-features = false, features = ["bit-vec", "derive"] }
Expand All @@ -14,8 +17,7 @@ polkadot-primitives = { path = "../../../primitives" }
polkadot-parachain = { path = "../../../parachain" }
polkadot-node-primitives = { path = "../../primitives" }
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" }
derive_more = "0.99.9"
log = "0.4.8"
polkadot-node-subsystem-util = { path = "../../subsystem-util" }

[dev-dependencies]
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
4 changes: 2 additions & 2 deletions node/core/candidate-validation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ use polkadot_subsystem::{
AllMessages, CandidateValidationMessage, RuntimeApiMessage,
ValidationFailed, RuntimeApiRequest,
},
};
use polkadot_node_subsystem_util::{
metrics::{self, prometheus},
};
use polkadot_subsystem::errors::RuntimeApiError;
Expand Down Expand Up @@ -113,8 +115,6 @@ impl<S, C> Subsystem<C> for CandidateValidationSubsystem<S> where
C: SubsystemContext<Message = CandidateValidationMessage>,
S: SpawnNamed + Clone + 'static,
{
type Metrics = Metrics;

fn start(self, ctx: C) -> SpawnedSubsystem {
SpawnedSubsystem {
name: "candidate-validation-subsystem",
Expand Down
1 change: 1 addition & 0 deletions node/core/chain-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ futures = { version = "0.3.5" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
polkadot-primitives = { path = "../../../primitives" }
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" }
polkadot-node-subsystem-util = { path = "../../subsystem-util" }

[dev-dependencies]
futures = { version = "0.3.5", features = ["thread-pool"] }
Expand Down
4 changes: 2 additions & 2 deletions node/core/chain-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ use polkadot_subsystem::{
FromOverseer, OverseerSignal,
SpawnedSubsystem, Subsystem, SubsystemResult, SubsystemContext,
messages::ChainApiMessage,
};
use polkadot_node_subsystem_util::{
metrics::{self, prometheus},
};
use polkadot_primitives::v1::{Block, BlockId};
Expand Down Expand Up @@ -57,8 +59,6 @@ impl<Client, Context> Subsystem<Context> for ChainApiSubsystem<Client> where
Client: HeaderBackend<Block> + 'static,
Context: SubsystemContext<Message = ChainApiMessage>
{
type Metrics = Metrics;

fn start(self, ctx: Context) -> SpawnedSubsystem {
SpawnedSubsystem {
future: run(ctx, self).map(|_| ()).boxed(),
Expand Down
2 changes: 1 addition & 1 deletion node/core/provisioner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ use polkadot_node_subsystem::{
AllMessages, ChainApiMessage, ProvisionableData, ProvisionerInherentData,
ProvisionerMessage, RuntimeApiMessage,
},
metrics::{self, prometheus},
};
use polkadot_node_subsystem_util::{
self as util,
delegated_subsystem,
request_availability_cores, request_persisted_validation_data, JobTrait, ToJobTrait,
metrics::{self, prometheus},
};
use polkadot_primitives::v1::{
BackedCandidate, BlockNumber, CoreState, Hash, OccupiedCoreAssumption,
Expand Down
1 change: 1 addition & 0 deletions node/core/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "mas
polkadot-primitives = { path = "../../../primitives" }
polkadot-node-primitives = { path = "../../primitives" }
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" }
polkadot-node-subsystem-util = { path = "../../subsystem-util" }

[dev-dependencies]
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
12 changes: 6 additions & 6 deletions node/core/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
use polkadot_subsystem::{
Subsystem, SpawnedSubsystem, SubsystemResult, SubsystemContext,
FromOverseer, OverseerSignal,
metrics::{self, prometheus},
messages::{
RuntimeApiMessage, RuntimeApiRequest as Request,
},
errors::RuntimeApiError,
};
use polkadot_subsystem::messages::{
RuntimeApiMessage, RuntimeApiRequest as Request,
use polkadot_node_subsystem_util::{
metrics::{self, prometheus},
};
use polkadot_subsystem::errors::RuntimeApiError;
use polkadot_primitives::v1::{Block, BlockId, Hash, ParachainHost};

use sp_api::{ProvideRuntimeApi};
Expand All @@ -52,8 +54,6 @@ impl<Client, Context> Subsystem<Context> for RuntimeApiSubsystem<Client> where
Client::Api: ParachainHost<Block>,
Context: SubsystemContext<Message = RuntimeApiMessage>
{
type Metrics = Metrics;

fn start(self, ctx: Context) -> SpawnedSubsystem {
SpawnedSubsystem {
future: run(ctx, self).map(|_| ()).boxed(),
Expand Down
2 changes: 0 additions & 2 deletions node/network/availability-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,6 @@ impl<Context> Subsystem<Context> for AvailabilityDistributionSubsystem
where
Context: SubsystemContext<Message = AvailabilityDistributionMessage> + Sync + Send,
{
type Metrics = ();

fn start(self, ctx: Context) -> SpawnedSubsystem {
SpawnedSubsystem {
name: "availability-distribution-subsystem",
Expand Down
2 changes: 0 additions & 2 deletions node/network/bitfield-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,6 @@ impl<C> Subsystem<C> for BitfieldDistribution
where
C: SubsystemContext<Message = BitfieldDistributionMessage> + Sync + Send,
{
type Metrics = ();

fn start(self, ctx: C) -> SpawnedSubsystem {
SpawnedSubsystem {
name: "bitfield-distribution-subsystem",
Expand Down
2 changes: 0 additions & 2 deletions node/network/bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ impl<Net, Context> Subsystem<Context> for NetworkBridge<Net>
Net: Network,
Context: SubsystemContext<Message=NetworkBridgeMessage>,
{
type Metrics = ();

fn start(self, ctx: Context) -> SpawnedSubsystem {
// Swallow error because failure is fatal to the node and we log with more precision
// within `run_network`.
Expand Down
2 changes: 1 addition & 1 deletion node/network/collator-protocol/src/collator_side.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ use polkadot_subsystem::{
AllMessages, CollatorProtocolMessage, RuntimeApiMessage, RuntimeApiRequest,
NetworkBridgeMessage,
},
metrics::{self, prometheus},
};
use polkadot_node_network_protocol::{
v1 as protocol_v1, View, PeerId, PeerSet, NetworkBridgeEvent, RequestId,
};
use polkadot_node_subsystem_util::{
request_validators_ctx,
request_validator_groups_ctx,
metrics::{self, prometheus},
};

#[derive(Clone, Default)]
Expand Down
9 changes: 4 additions & 5 deletions node/network/collator-protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use log::trace;
use polkadot_subsystem::{
Subsystem, SubsystemContext, SubsystemError, SpawnedSubsystem,
errors::RuntimeApiError,
metrics::{self, prometheus},
messages::{
AllMessages, CollatorProtocolMessage, NetworkBridgeMessage,
},
Expand All @@ -35,7 +34,10 @@ use polkadot_node_network_protocol::{
PeerId, ReputationChange as Rep,
};
use polkadot_primitives::v1::CollatorId;
use polkadot_node_subsystem_util as util;
use polkadot_node_subsystem_util::{
self as util,
metrics::{self, prometheus},
};

mod collator_side;
mod validator_side;
Expand Down Expand Up @@ -109,9 +111,6 @@ impl<Context> Subsystem<Context> for CollatorProtocolSubsystem
where
Context: SubsystemContext<Message = CollatorProtocolMessage> + Sync + Send,
{
// The actual `Metrics` type depends on whether we're on the collator or validator side.
type Metrics = ();

fn start(self, ctx: Context) -> SpawnedSubsystem {
SpawnedSubsystem {
name: "collator-protocol-subsystem",
Expand Down
6 changes: 4 additions & 2 deletions node/network/collator-protocol/src/validator_side.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ use polkadot_subsystem::{
messages::{
AllMessages, CandidateSelectionMessage, CollatorProtocolMessage, NetworkBridgeMessage,
},
metrics::{self, prometheus},
};
use polkadot_node_network_protocol::{
v1 as protocol_v1, View, PeerId, ReputationChange as Rep, RequestId,
NetworkBridgeEvent,
};
use polkadot_node_subsystem_util::TimeoutExt;
use polkadot_node_subsystem_util::{
TimeoutExt as _,
metrics::{self, prometheus},
};

use super::{modify_reputation, TARGET, Result};

Expand Down
2 changes: 0 additions & 2 deletions node/network/pov-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ pub struct PoVDistribution;
impl<C> Subsystem<C> for PoVDistribution
where C: SubsystemContext<Message = PoVDistributionMessage>
{
type Metrics = ();

fn start(self, ctx: C) -> SpawnedSubsystem {
// Swallow error because failure is fatal to the node and we log with more precision
// within `run`.
Expand Down
2 changes: 0 additions & 2 deletions node/network/statement-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ pub struct StatementDistribution;
impl<C> Subsystem<C> for StatementDistribution
where C: SubsystemContext<Message=StatementDistributionMessage>
{
type Metrics = ();

fn start(self, ctx: C) -> SpawnedSubsystem {
// Swallow error because failure is fatal to the node and we log with more precision
// within `run`.
Expand Down
1 change: 1 addition & 0 deletions node/overseer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ streamunordered = "0.5.1"
polkadot-primitives = { path = "../../primitives" }
client = { package = "sc-client-api", git = "https://github.com/paritytech/substrate", branch = "master" }
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../subsystem" }
polkadot-node-subsystem-util = { path = "../subsystem-util" }
polkadot-node-primitives = { package = "polkadot-node-primitives", path = "../primitives" }
async-trait = "0.1"

Expand Down
Loading

0 comments on commit 77d04d4

Please sign in to comment.