Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add --raw flag to send-envelope #1468

Merged
merged 5 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

"You know what they say. Fool me once, strike one, but fool me twice... strike three." — Michael Scott

## Unreleased

### Various fixes & improvements

- feat: Added the `--raw` flag to `send-envelope` to allow sending envelopes without parsing or validation. (#1468)

## 2.12.0

### Various fixes & improvements
Expand Down
24 changes: 12 additions & 12 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ regex = "1.7.1"
runas = "0.2.1"
rust-ini = "0.18.0"
semver = "1.0.16"
sentry = { version = "0.29.2", default-features = false, features = [
sentry = { version = "0.29.3", default-features = false, features = [
"anyhow",
"curl",
"contexts",
Expand Down
12 changes: 11 additions & 1 deletion src/commands/send_envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ pub fn make_command(command: Command) -> Command {
.required(true)
.help("The path or glob to the file(s) in envelope format to send as envelope(s)."),
)
.arg(
Arg::new("raw")
.long("raw")
.help("Send envelopes without attempting to parse their contents."),
)
}

fn send_raw_envelope(envelope: Envelope, dsn: Dsn) {
Expand All @@ -36,6 +41,7 @@ fn send_raw_envelope(envelope: Envelope, dsn: Dsn) {
pub fn execute(matches: &ArgMatches) -> Result<()> {
let config = Config::current();
let dsn = config.get_dsn()?;
let raw = matches.is_present("raw");

let path = matches.value_of("path").unwrap();

Expand All @@ -51,7 +57,11 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {

for path in collected_paths {
let p = path.as_path();
let envelope: Envelope = Envelope::from_path(p)?;
let envelope: Envelope = if raw {
Envelope::from_path_raw(p)
} else {
Envelope::from_path(p)
}?;
send_raw_envelope(envelope, dsn.clone());
println!("Envelope from file {} dispatched", p.display());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $ sentry-cli send-envelope tests/integration/_fixtures/envelope.dat --log-level=
? success
DEBUG [..] sentry-cli version: [VERSION], platform: [..], architecture: [..]
INFO [..] sentry-cli was invoked with the following command line: "[CWD]/target/debug/sentry-cli[EXE]" "send-envelope" "tests/integration/_fixtures/envelope.dat" "--log-level=debug"
DEBUG [..] Envelope { event_id: Some(22d00b3f-d1b1-4b5d-8d20-49d138cd8a9c), items: [Event(Event { event_id: 22d00b3f-d1b1-4b5d-8d20-49d138cd8a9c, level: Error, fingerprint: ["{{ default }}"], culprit: None, transaction: None, message: None, logentry: None, logger: None, modules: {}, platform: "other", timestamp: [..], server_name: None, release: None, dist: None, environment: None, user: None, request: None, contexts: {}, breadcrumbs: Values { values: [] }, exception: Values { values: [] }, stacktrace: None, template: None, threads: Values { values: [] }, tags: {}, extra: {}, debug_meta: DebugMeta { sdk_info: None, images: [] }, sdk: None }), Transaction(Transaction { event_id: 22d00b3f-d1b1-4b5d-8d20-49d138cd8a9d, name: None, release: None, environment: None, tags: {}, extra: {}, sdk: None, platform: "other", timestamp: None, start_timestamp: [..], spans: [Span { span_id: SpanId([212, 44, 238, 159, 195, 231, 79, 92]), trace_id: TraceId([51, 94, 83, 214, 20, 71, 74, 204, 159, 137, 230, 50, 183, 118, 204, 40]), parent_span_id: None, same_process_as_parent: None, op: None, description: None, timestamp: None, start_timestamp: [..], status: None, tags: {}, data: {} }], contexts: {}, request: None, active_thread_id: None }), SessionUpdate(SessionUpdate { session_id: 22d00b3f-d1b1-4b5d-8d20-49d138cd8a9c, distinct_id: Some("[email protected]"), sequence: None, timestamp: None, started: [..], init: true, duration: Some(1.234), status: Ok, errors: 123, attributes: SessionAttributes { release: "[email protected]", environment: Some("production"), ip_address: None, user_agent: None } }), Attachment(Attachment { buffer: 12, filename: "file.txt", content_type: Some("application/octet-stream"), type: Some(Attachment) })] }
DEBUG [..] Envelope { event_id: Some(22d00b3f-d1b1-4b5d-8d20-49d138cd8a9c), items: EnvelopeItems([Event(Event { event_id: 22d00b3f-d1b1-4b5d-8d20-49d138cd8a9c, level: Error, fingerprint: ["{{ default }}"], culprit: None, transaction: None, message: None, logentry: None, logger: None, modules: {}, platform: "other", timestamp: [..], server_name: None, release: None, dist: None, environment: None, user: None, request: None, contexts: {}, breadcrumbs: Values { values: [] }, exception: Values { values: [] }, stacktrace: None, template: None, threads: Values { values: [] }, tags: {}, extra: {}, debug_meta: DebugMeta { sdk_info: None, images: [] }, sdk: None }), Transaction(Transaction { event_id: 22d00b3f-d1b1-4b5d-8d20-49d138cd8a9d, name: None, release: None, environment: None, tags: {}, extra: {}, sdk: None, platform: "other", timestamp: None, start_timestamp: [..], spans: [Span { span_id: SpanId([212, 44, 238, 159, 195, 231, 79, 92]), trace_id: TraceId([51, 94, 83, 214, 20, 71, 74, 204, 159, 137, 230, 50, 183, 118, 204, 40]), parent_span_id: None, same_process_as_parent: None, op: None, description: None, timestamp: None, start_timestamp: [..], status: None, tags: {}, data: {} }], contexts: {}, request: None, active_thread_id: None }), SessionUpdate(SessionUpdate { session_id: 22d00b3f-d1b1-4b5d-8d20-49d138cd8a9c, distinct_id: Some("[email protected]"), sequence: None, timestamp: None, started: [..], init: true, duration: Some(1.234), status: Ok, errors: 123, attributes: SessionAttributes { release: "[email protected]", environment: Some("production"), ip_address: None, user_agent: None } }), Attachment(Attachment { buffer: 12, filename: "file.txt", content_type: Some("application/octet-stream"), type: Some(Attachment) })]) }
Envelope from file tests/integration/_fixtures/envelope.dat dispatched

```
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ OPTIONS:

[aliases: silent]

--raw
Send envelopes without attempting to parse their contents.

```