Skip to content

Commit 34e8e0e

Browse files
authored
fix: Upgrade sentry-actix based on latest changes (#87)
* ci: Test and lint all workspace packages and examples * fix: Upgrade sentry-actix based on latest changes * ci: Remove a default job from build matrix
1 parent 6d06bce commit 34e8e0e

File tree

4 files changed

+30
-23
lines changed

4 files changed

+30
-23
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ branches:
1313

1414
script: make $SUITE
1515

16-
env: # Needed for allow_failures
17-
1816
matrix:
1917
include:
2018
- env: SUITE=format-check

Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ doc:
1515

1616
check-all-features:
1717
@echo 'ALL FEATURES'
18-
@RUSTFLAGS=-Dwarnings cargo check --all-features
18+
@RUSTFLAGS=-Dwarnings cargo check --all-features --all --examples
1919
.PHONY: check-all-features
2020

2121
check-no-default-features:
@@ -53,10 +53,15 @@ check-all-impls:
5353
@RUSTFLAGS=-Dwarnings cargo check --no-default-features --features 'with_failure,with_log,with_panic,with_error_chain'
5454
.PHONY: check-all-impls
5555

56+
check-actix:
57+
@echo 'ACTIX INTEGRATION'
58+
@RUSTFLAGS=-Dwarnings cargo check --manifest-path integrations/sentry-actix/Cargo.toml
59+
.PHONY: check-actix
60+
5661
check: check-no-default-features check-default-features
5762
.PHONY: check-all-features
5863

59-
checkall: check-all-features check-no-default-features check-default-features check-failure check-log check-panic check-error-chain check-all-impls
64+
checkall: check-all-features check-no-default-features check-default-features check-failure check-log check-panic check-error-chain check-all-impls check-actix
6065
.PHONY: checkall
6166

6267
cargotest:
@@ -66,7 +71,7 @@ cargotest:
6671

6772
cargotestall:
6873
@echo 'TESTSUITE'
69-
@cargo test --all-features
74+
@cargo test --all-features --all --examples
7075
.PHONY: cargotest
7176

7277
test: checkall cargotestall
@@ -79,7 +84,7 @@ format-check:
7984

8085
lint:
8186
@rustup component add clippy-preview 2> /dev/null
82-
@cargo clippy --all-features --tests -- -D clippy
87+
@cargo clippy --all-features --tests --all --examples -- -D clippy
8388
.PHONY: lint
8489

8590
travis-push-docs:

integrations/sentry-actix/src/lib.rs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ use actix_web::middleware::{Middleware, Response, Started};
8383
use actix_web::{Error, HttpMessage, HttpRequest, HttpResponse};
8484
use failure::Fail;
8585
use sentry::integrations::failure::exception_from_single_fail;
86-
use sentry::protocol::{ClientSdkPackageInfo, Event, Level};
86+
use sentry::protocol::{ClientSdkPackage, Event, Level};
8787
use sentry::{Hub, Uuid};
8888
use std::borrow::Cow;
8989
use std::sync::{Arc, Mutex};
@@ -93,13 +93,6 @@ pub struct SentryMiddlewareBuilder {
9393
middleware: SentryMiddleware,
9494
}
9595

96-
/// Reports certain failures to sentry.
97-
pub struct SentryMiddleware {
98-
hub: Option<Arc<Hub>>,
99-
emit_header: bool,
100-
capture_server_errors: bool,
101-
}
102-
10396
impl SentryMiddlewareBuilder {
10497
/// Finishes the building and returns a middleware
10598
pub fn finish(self) -> SentryMiddleware {
@@ -133,6 +126,13 @@ impl SentryMiddlewareBuilder {
133126
}
134127
}
135128

129+
/// Reports certain failures to sentry.
130+
pub struct SentryMiddleware {
131+
hub: Option<Arc<Hub>>,
132+
emit_header: bool,
133+
capture_server_errors: bool,
134+
}
135+
136136
impl SentryMiddleware {
137137
/// Creates a new sentry middleware.
138138
pub fn new() -> SentryMiddleware {
@@ -158,19 +158,23 @@ impl SentryMiddleware {
158158
}
159159
}
160160

161+
impl Default for SentryMiddleware {
162+
fn default() -> Self {
163+
SentryMiddleware::new()
164+
}
165+
}
166+
161167
fn extract_request<S: 'static>(
162168
req: &HttpRequest<S>,
163169
with_pii: bool,
164170
) -> (Option<String>, sentry::protocol::Request) {
165171
let resource = req.resource();
166172
let transaction = if let Some(rdef) = resource.rdef() {
167173
Some(rdef.pattern().to_string())
174+
} else if resource.name() != "" {
175+
Some(resource.name().to_string())
168176
} else {
169-
if resource.name() != "" {
170-
Some(resource.name().to_string())
171-
} else {
172-
None
173-
}
177+
None
174178
};
175179
let mut sentry_req = sentry::protocol::Request {
176180
url: format!(
@@ -229,8 +233,8 @@ impl<S: 'static> Middleware<S> for SentryMiddleware {
229233

230234
if let Some(sdk) = event.sdk.take() {
231235
let mut sdk = sdk.into_owned();
232-
sdk.packages.push(ClientSdkPackageInfo {
233-
package_name: "sentry-actix".into(),
236+
sdk.packages.push(ClientSdkPackage {
237+
name: "sentry-actix".into(),
234238
version: env!("CARGO_PKG_VERSION").into(),
235239
});
236240
event.sdk = Some(Cow::Owned(sdk));
@@ -255,7 +259,7 @@ impl<S: 'static> Middleware<S> for SentryMiddleware {
255259
Some(event_id) if self.emit_header => {
256260
resp.headers_mut().insert(
257261
"x-sentry-event",
258-
event_id.simple().to_string().parse().unwrap(),
262+
event_id.to_simple_ref().to_string().parse().unwrap(),
259263
);
260264
}
261265
_ => {}

src/backtrace_support.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ lazy_static!{
5050
#[cfg(feature = "with_error_chain")] {
5151
rv.push(("error_chain::make_backtrace", "<T as core::convert::Into<U>>::into"));
5252
}
53-
rv
53+
{rv}
5454
};
5555

5656
pub static ref COMMON_RUST_SYMBOL_ESCAPES_RE: Regex = Regex::new(r#"(?x)

0 commit comments

Comments
 (0)