mirror of
https://github.com/storytold/voder-proxy.git
synced 2026-10-21 07:45:21 +00:00
add newrelic attribute for speaker
This commit is contained in:
+22
-3
@@ -26,11 +26,30 @@ impl NewRelicLogger {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn web_transaction(&self, transaction_name: &str) -> Option<Transaction> {
|
||||
pub fn web_transaction(&self, transaction_name: &str) -> MaybeNewRelicTransaction {
|
||||
if let Some(ref newrelic_api) = self.newrelic_api {
|
||||
info!("Logging request to NewRelic");
|
||||
return newrelic_api.web_transaction(transaction_name).ok();
|
||||
let maybe_transaction = newrelic_api.web_transaction(transaction_name).ok();
|
||||
return MaybeNewRelicTransaction::from_optional(maybe_transaction);
|
||||
}
|
||||
None
|
||||
MaybeNewRelicTransaction::from_optional(None)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MaybeNewRelicTransaction {
|
||||
transaction: Option<Transaction>,
|
||||
}
|
||||
|
||||
impl MaybeNewRelicTransaction {
|
||||
pub fn from_optional(optional: Option<Transaction>) -> Self {
|
||||
Self {
|
||||
transaction: optional,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_attribute(&self, name: &str, value: &str) {
|
||||
if let Some(ref transaction) = self.transaction {
|
||||
let _result = transaction.add_attribute(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user