mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-10-01 01:26:08 -04:00
fix otlp
This commit is contained in:
parent
c33f78ac8b
commit
a3e43ef68b
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -3139,6 +3139,15 @@ dependencies = [
|
||||
"tonic-build",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "opentelemetry-semantic-conventions"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "985cc35d832d412224b2cffe2f9194b1b89b6aa5d0bef76d080dce09d90e62bd"
|
||||
dependencies = [
|
||||
"opentelemetry",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ordered-multimap"
|
||||
version = "0.4.3"
|
||||
@ -5280,10 +5289,12 @@ dependencies = [
|
||||
"failure",
|
||||
"flume",
|
||||
"futures",
|
||||
"hostname",
|
||||
"lazy_static",
|
||||
"nix 0.24.1",
|
||||
"opentelemetry",
|
||||
"opentelemetry-otlp",
|
||||
"opentelemetry-semantic-conventions",
|
||||
"parking_lot 0.12.1",
|
||||
"rpassword 6.0.1",
|
||||
"serde 1.0.137",
|
||||
|
@ -90,6 +90,7 @@ impl Default for NetworkManagerStats {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct ClientWhitelistEntry {
|
||||
last_seen_ts: u64,
|
||||
}
|
||||
@ -364,7 +365,6 @@ impl NetworkManager {
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(self))]
|
||||
pub fn purge_client_whitelist(&self) {
|
||||
let timeout_ms = self.config.get().network.client_whitelist_timeout_ms;
|
||||
let mut inner = self.inner.lock();
|
||||
@ -376,7 +376,8 @@ impl NetworkManager {
|
||||
.map(|v| v.1.last_seen_ts < cutoff_timestamp)
|
||||
.unwrap_or_default()
|
||||
{
|
||||
inner.client_whitelist.remove_lru();
|
||||
let (k, v) = inner.client_whitelist.remove_lru().unwrap();
|
||||
trace!(key=?k, value=?v, "purge_client_whitelist: remove_lru")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ tracing-appender = "^0"
|
||||
tracing-opentelemetry = "^0"
|
||||
opentelemetry = { version = "^0", features = ["rt-async-std"] }
|
||||
opentelemetry-otlp = { version = "^0", features = ["grpc-sys"] }
|
||||
opentelemetry-semantic-conventions = "^0"
|
||||
clap = "^3"
|
||||
async-std = { version = "^1", features = ["unstable"] }
|
||||
async-tungstenite = { version = "^0", features = ["async-std-runtime", "async-tls"] }
|
||||
@ -38,6 +39,7 @@ lazy_static = "^1"
|
||||
bugsalot = "^0"
|
||||
flume = { version = "^0", features = ["async"] }
|
||||
rpassword = "^6"
|
||||
hostname = "^0"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows-service = "^0"
|
||||
|
@ -66,7 +66,7 @@ fn do_clap_matches(default_config_path: &OsStr) -> Result<clap::ArgMatches, clap
|
||||
.long("otlp")
|
||||
.takes_value(true)
|
||||
.value_name("endpoint")
|
||||
.default_missing_value("http://localhost:4317")
|
||||
.default_missing_value("localhost:4317")
|
||||
.help("Turn on OpenTelemetry tracing"),
|
||||
)
|
||||
.arg(
|
||||
@ -207,15 +207,13 @@ pub fn process_command_line() -> Result<(Settings, ArgMatches), String> {
|
||||
}
|
||||
if matches.occurrences_of("otlp") != 0 {
|
||||
settingsrw.logging.otlp.enabled = true;
|
||||
settingsrw.logging.otlp.grpc_endpoint = Some(
|
||||
ParsedUrl::from_str(
|
||||
&matches
|
||||
.value_of("otlp")
|
||||
.expect("should not be null because of default missing value")
|
||||
.to_string(),
|
||||
)
|
||||
.map_err(|e| format!("failed to parse OTLP url: {}", e))?,
|
||||
);
|
||||
settingsrw.logging.otlp.grpc_endpoint = NamedSocketAddrs::from_str(
|
||||
&matches
|
||||
.value_of("otlp")
|
||||
.expect("should not be null because of default missing value")
|
||||
.to_string(),
|
||||
)
|
||||
.map_err(|e| format!("failed to parse OTLP address: {}", e))?;
|
||||
settingsrw.logging.otlp.level = LogLevel::Trace;
|
||||
}
|
||||
if matches.is_present("attach") {
|
||||
|
@ -39,7 +39,7 @@ logging:
|
||||
otlp:
|
||||
enabled: false
|
||||
level: 'trace'
|
||||
grpc_endpoint: 'http://localhost:4317'
|
||||
grpc_endpoint: 'localhost:4317'
|
||||
testing:
|
||||
subnode_index: 0
|
||||
core:
|
||||
@ -435,7 +435,7 @@ pub struct Api {
|
||||
pub struct Otlp {
|
||||
pub enabled: bool,
|
||||
pub level: LogLevel,
|
||||
pub grpc_endpoint: Option<ParsedUrl>,
|
||||
pub grpc_endpoint: NamedSocketAddrs,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
@ -1423,7 +1423,7 @@ mod tests {
|
||||
assert_eq!(s.logging.otlp.level, LogLevel::Trace);
|
||||
assert_eq!(
|
||||
s.logging.otlp.grpc_endpoint,
|
||||
Some(ParsedUrl::from_str("http://127.0.0.1:4317").unwrap())
|
||||
NamedSocketAddrs::from_str("localhost:4317").unwrap()
|
||||
);
|
||||
assert_eq!(s.testing.subnode_index, 0);
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
use crate::settings::*;
|
||||
use cfg_if::*;
|
||||
use opentelemetry::sdk::*;
|
||||
use opentelemetry::*;
|
||||
use opentelemetry_otlp::WithExportConfig;
|
||||
use std::path::*;
|
||||
use tracing::*;
|
||||
@ -61,12 +63,7 @@ impl VeilidLogs {
|
||||
convert_loglevel(settingsr.logging.otlp.level)
|
||||
.to_tracing_level()
|
||||
.into();
|
||||
let grpc_endpoint = match &settingsr.logging.otlp.grpc_endpoint {
|
||||
Some(v) => &v.urlstring,
|
||||
None => {
|
||||
return Err("missing OTLP GRPC endpoint url".to_owned());
|
||||
}
|
||||
};
|
||||
let grpc_endpoint = settingsr.logging.otlp.grpc_endpoint.name.clone();
|
||||
|
||||
// Required for GRPC dns resolution to work
|
||||
std::env::set_var("GRPC_DNS_RESOLVER", "native");
|
||||
@ -78,6 +75,17 @@ impl VeilidLogs {
|
||||
.grpcio()
|
||||
.with_endpoint(grpc_endpoint),
|
||||
)
|
||||
.with_trace_config(opentelemetry::sdk::trace::config().with_resource(
|
||||
Resource::new(vec![KeyValue::new(
|
||||
opentelemetry_semantic_conventions::resource::SERVICE_NAME,
|
||||
format!(
|
||||
"veilid_server:{}",
|
||||
hostname::get()
|
||||
.map(|s| s.to_string_lossy().into_owned())
|
||||
.unwrap_or_else(|_| "unknown".to_owned())
|
||||
),
|
||||
)]),
|
||||
))
|
||||
.install_batch(opentelemetry::runtime::AsyncStd)
|
||||
.map_err(|e| format!("failed to install OpenTelemetry tracer: {}", e))?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user