mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
mononoke: move facebook/scuba_ext to common/scuba_ext
Summary: common/sql_ext will now be buildable in OSS Reviewed By: krallin Differential Revision: D19876764 fbshipit-source-id: 0f51abd1169f6b8108e7e4cab85b5f193c28e2cd
This commit is contained in:
parent
1ebacd1c26
commit
0ccc5f678a
@ -1,6 +1,7 @@
|
||||
[workspace]
|
||||
|
||||
members = [
|
||||
"common/scuba_ext",
|
||||
"server/session_id",
|
||||
"sshrelay",
|
||||
]
|
||||
|
@ -2,8 +2,7 @@
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This software may be used and distributed according to the terms of the
|
||||
* GNU General Public License found in the LICENSE file in the root
|
||||
* directory of this source tree.
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
use futures::ready;
|
||||
|
@ -2,8 +2,7 @@
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This software may be used and distributed according to the terms of the
|
||||
* GNU General Public License found in the LICENSE file in the root
|
||||
* directory of this source tree.
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
use super::{
|
||||
|
@ -2,8 +2,7 @@
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This software may be used and distributed according to the terms of the
|
||||
* GNU General Public License found in the LICENSE file in the root
|
||||
* directory of this source tree.
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
//! Read the documentation of [bounded_traversal](crate::bounded_traversal),
|
||||
|
@ -2,8 +2,7 @@
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This software may be used and distributed according to the terms of the
|
||||
* GNU General Public License found in the LICENSE file in the root
|
||||
* directory of this source tree.
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
use futures::{
|
||||
|
@ -2,8 +2,7 @@
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This software may be used and distributed according to the terms of the
|
||||
* GNU General Public License found in the LICENSE file in the root
|
||||
* directory of this source tree.
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
use super::{bounded_traversal, bounded_traversal_dag, bounded_traversal_stream};
|
||||
|
@ -2,8 +2,7 @@
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This software may be used and distributed according to the terms of the
|
||||
* GNU General Public License found in the LICENSE file in the root
|
||||
* directory of this source tree.
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
use super::{
|
||||
|
18
eden/mononoke/common/scuba_ext/Cargo.toml
Normal file
18
eden/mononoke/common/scuba_ext/Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "scuba_ext"
|
||||
edition = "2018"
|
||||
version = "0.1.0"
|
||||
authors = ['Facebook']
|
||||
license = "GPLv2+"
|
||||
include = ["src/**/*.rs"]
|
||||
|
||||
[dependencies]
|
||||
sshrelay = { path = "../../sshrelay" }
|
||||
fbinit = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
||||
futures_ext = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
||||
futures_stats = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
||||
scuba = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
||||
time_ext = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
||||
tracing = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
||||
futures = "0.1" # todo: rename to "futures-old"
|
||||
rand = { version = "0.7", features = ["small_rng"] }
|
87
eden/mononoke/common/scuba_ext/src/lib.rs
Normal file
87
eden/mononoke/common/scuba_ext/src/lib.rs
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This software may be used and distributed according to the terms of the
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#![deny(warnings)]
|
||||
|
||||
use fbinit::FacebookInit;
|
||||
use futures_ext::BoxFuture;
|
||||
use futures_stats::{FutureStats, StreamStats};
|
||||
pub use scuba::{ScubaSampleBuilder, ScubaValue};
|
||||
use sshrelay::Preamble;
|
||||
use time_ext::DurationExt;
|
||||
use tracing::TraceContext;
|
||||
|
||||
#[cfg(fbcode_build)]
|
||||
mod facebook;
|
||||
#[cfg(fbcode_build)]
|
||||
pub use facebook::*;
|
||||
|
||||
pub trait ScubaSampleBuilderExt {
|
||||
fn with_opt_table(fb: FacebookInit, scuba_table: Option<String>) -> Self;
|
||||
fn add_preamble(&mut self, preamble: &Preamble) -> &mut Self;
|
||||
fn log_with_msg<S: Into<Option<String>>>(&mut self, log_tag: &'static str, msg: S);
|
||||
fn add_stream_stats(&mut self, stats: &StreamStats) -> &mut Self;
|
||||
fn add_future_stats(&mut self, stats: &FutureStats) -> &mut Self;
|
||||
fn log_with_trace(&mut self, fb: FacebookInit, trace: &TraceContext) -> BoxFuture<(), ()>;
|
||||
}
|
||||
|
||||
impl ScubaSampleBuilderExt for ScubaSampleBuilder {
|
||||
fn with_opt_table(fb: FacebookInit, scuba_table: Option<String>) -> Self {
|
||||
match scuba_table {
|
||||
None => ScubaSampleBuilder::with_discard(),
|
||||
Some(scuba_table) => ScubaSampleBuilder::new(fb, scuba_table),
|
||||
}
|
||||
}
|
||||
|
||||
fn add_preamble(&mut self, preamble: &Preamble) -> &mut Self {
|
||||
self.add("repo", preamble.reponame.as_ref());
|
||||
for (key, value) in preamble.misc.iter() {
|
||||
self.add(key, value.as_ref());
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
fn log_with_msg<S: Into<Option<String>>>(&mut self, log_tag: &'static str, msg: S) {
|
||||
self.add("log_tag", log_tag);
|
||||
if let Some(msg) = msg.into() {
|
||||
self.add("msg", msg);
|
||||
}
|
||||
self.log();
|
||||
}
|
||||
|
||||
fn add_stream_stats(&mut self, stats: &StreamStats) -> &mut Self {
|
||||
self.add("poll_count", stats.poll_count)
|
||||
.add("poll_time_us", stats.poll_time.as_micros_unchecked())
|
||||
.add("count", stats.count)
|
||||
.add(
|
||||
"completion_time_us",
|
||||
stats.completion_time.as_micros_unchecked(),
|
||||
)
|
||||
}
|
||||
|
||||
fn add_future_stats(&mut self, stats: &FutureStats) -> &mut Self {
|
||||
self.add("poll_count", stats.poll_count)
|
||||
.add("poll_time_us", stats.poll_time.as_micros_unchecked())
|
||||
.add(
|
||||
"completion_time_us",
|
||||
stats.completion_time.as_micros_unchecked(),
|
||||
)
|
||||
}
|
||||
|
||||
fn log_with_trace(&mut self, fb: FacebookInit, trace: &TraceContext) -> BoxFuture<(), ()> {
|
||||
#[cfg(not(fbcode_build))]
|
||||
{
|
||||
use futures_ext::FutureExt;
|
||||
let _ = (fb, trace);
|
||||
futures::future::ok(()).boxify()
|
||||
}
|
||||
#[cfg(fbcode_build)]
|
||||
{
|
||||
facebook::log_with_trace(self, fb, trace)
|
||||
}
|
||||
}
|
||||
}
|
@ -2,8 +2,7 @@
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This software may be used and distributed according to the terms of the
|
||||
* GNU General Public License found in the LICENSE file in the root
|
||||
* directory of this source tree.
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#![deny(warnings)]
|
||||
|
Loading…
Reference in New Issue
Block a user