Skip to content

Commit

Permalink
Merge pull request #62 from jjcomer/fix-deps
Browse files Browse the repository at this point in the history
Fix deps
  • Loading branch information
jjcomer authored May 19, 2021
2 parents ac810f2 + b413c01 commit 74f817d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 42 deletions.
28 changes: 20 additions & 8 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ doc = false

[package]
name = 'hogan'
version = '0.12.1'
version = '0.12.2'
authors = [
'Jonathan Morley <[email protected]>',
'Josh Comer <[email protected]>',
Expand Down Expand Up @@ -43,7 +43,7 @@ compression = '0.1'
which = '4.0'

[dependencies.tokio]
version = '1.1'
version = '0.2'
features = ['full']

[dependencies.rusqlite]
Expand Down
63 changes: 31 additions & 32 deletions src/app/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,46 +181,45 @@ async fn start_server(address: String, port: u16, state: ServerState) -> Result<
HttpServer::new(move || {
let dd_client = dd_client.clone();
actix_web::App::new()
.wrap(Logger::default())
.wrap(middleware::Compress::default())
.app_data(server_state.clone())
.wrap_fn(move |req, srv| {
let dd_client = dd_client.clone();
let start_time = if req.path() != "/ok" {
Some(SystemTime::now())
} else {
None
};
srv.call(req).map(move |res| {
if let Ok(result) = res {
if let Some(time) = start_time {
if let Ok(duration) = time.elapsed() {
let path = contextualize_path(result.request().path());
let method = result.request().method().as_str();
let ms = duration.as_millis();
let status = result.status();
debug!(
"Request for {} {} duration: {} status: {}",
method, path, ms, status
);

dd_client.time(
CustomMetrics::RequestTime.into(),
Some(vec![
format!("url:{}", path),
format!("method:{}", method),
format!("status:{}", status.as_str()),
]),
ms as i64,
);
}
let dd_client = dd_client.clone();
let fut = srv.call(req);

async move {
let res = fut.await?;
if let Some(start) = start_time {
if let Ok(duration) = start.elapsed() {
let path = contextualize_path(res.request().path());
let method = res.request().method().as_str();
let ms = duration.as_millis();
let status = res.status();
debug!(
"Request for {} {} duration: {} status: {}",
method, path, ms, status
);

dd_client.time(
CustomMetrics::RequestTime.into(),
Some(vec![
format!("url:{}", path),
format!("method:{}", method),
format!("status:{}", status.as_str()),
]),
ms as i64,
);
}
Ok(result)
} else {
res
}
})
};
Ok(res)
}
})
.wrap(Logger::default())
.wrap(middleware::Compress::default())
.app_data(server_state.clone())
.service(transform_route_sha_env)
.service(transform_branch_head)
.service(get_envs)
Expand Down

0 comments on commit 74f817d

Please sign in to comment.