1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde_json;
#[macro_use]
extern crate lazy_static;
extern crate failure;
extern crate observer_attribute;
pub mod context;
mod event;
mod frame;
pub mod observe;
pub mod observe_fields;
pub mod prelude;
pub mod queue;
mod utils;
pub use crate::context::Context;
pub use crate::event::{Event, OEvent, OID};
use std::env;
#[cfg(test)]
mod tests;
pub type Result<T> = std::result::Result<T, failure::Error>;
lazy_static! {
static ref LOG_DIR: String =
env::var("OBSERVER_LOGS").unwrap_or_else(|_| "/var/log/".to_string());
}
pub fn check_path() -> String {
format!("OBSERVER LOGDIR {:?}", LOG_DIR.to_string())
}
#[cfg(test)]
pub mod test_newrelic {
use ackorelic::{
newrelic_fn::{
nr_end_custom_segment, nr_end_transaction, nr_start_custom_segment,
nr_start_web_transaction,
},
App, NewRelicConfig,
};
use std::thread;
use std::time::Duration;
#[test]
fn test_log_path() {
println!("LOGDIR {:?}", super::check_path());
}
#[test]
fn new_relic_test() {
let mut count = 0;
nr_start_web_transaction("test_transaction");
while count < 1000 {
let seg1 = nr_start_custom_segment("db_pool");
thread::sleep(Duration::from_millis(10));
nr_end_custom_segment(seg1);
count += 1;
}
println!("Events Completed");
nr_end_transaction()
}
}