Skip to content

Commit

Permalink
fix(azure_blob sink): Base Content-Type on encoder and not compression (
Browse files Browse the repository at this point in the history
vectordotdev#18184)

* content-type reflects non compressed encoding

* update tests

* Update src/sinks/azure_blob/integration_tests.rs

Good callout, yeah this slipped past me since that particular test is currently ignored.

Co-authored-by: Doug Smith <[email protected]>

* fix formatting

---------

Co-authored-by: Doug Smith <[email protected]>
  • Loading branch information
stemjacobs and dsmith3197 authored Aug 8, 2023
1 parent e476e12 commit 4a049d4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
15 changes: 9 additions & 6 deletions src/sinks/azure_blob/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ async fn azure_blob_insert_json_into_blob() {
assert_eq!(blobs.len(), 1);
assert!(blobs[0].clone().ends_with(".log"));
let (blob, blob_lines) = config.get_blob(blobs[0].clone()).await;
assert_eq!(blob.properties.content_type, String::from("text/plain"));
assert_eq!(blob.properties.content_encoding, None);
assert_eq!(
blob.properties.content_type,
String::from("application/x-ndjson")
);
let expected = events
.iter()
.map(|event| serde_json::to_string(&event.as_log().all_fields().unwrap()).unwrap())
Expand All @@ -138,10 +142,8 @@ async fn azure_blob_insert_lines_into_blob_gzip() {
assert_eq!(blobs.len(), 1);
assert!(blobs[0].clone().ends_with(".log.gz"));
let (blob, blob_lines) = config.get_blob(blobs[0].clone()).await;
assert_eq!(
blob.properties.content_type,
String::from("application/gzip")
);
assert_eq!(blob.properties.content_encoding, Some(String::from("gzip")));
assert_eq!(blob.properties.content_type, String::from("text/plain"));
assert_eq!(lines, blob_lines);
}

Expand Down Expand Up @@ -170,9 +172,10 @@ async fn azure_blob_insert_json_into_blob_gzip() {
assert_eq!(blobs.len(), 1);
assert!(blobs[0].clone().ends_with(".log.gz"));
let (blob, blob_lines) = config.get_blob(blobs[0].clone()).await;
assert_eq!(blob.properties.content_encoding, Some(String::from("gzip")));
assert_eq!(
blob.properties.content_type,
String::from("application/gzip")
String::from("application/x-ndjson")
);
let expected = events
.iter()
Expand Down
13 changes: 1 addition & 12 deletions src/sinks/azure_blob/request_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,9 @@ impl RequestBuilder<(String, Vec<Event>)> for AzureBlobRequestOptions {
AzureBlobRequest {
blob_data,
content_encoding: self.compression.content_encoding(),
content_type: self.compression.content_type(),
content_type: self.encoder.1.content_type(),
metadata: azure_metadata,
request_metadata,
}
}
}

impl Compression {
pub const fn content_type(self) -> &'static str {
match self {
Self::None => "text/plain",
Self::Gzip(_) => "application/gzip",
Self::Zlib(_) => "application/zlib",
Self::Zstd(_) => "application/zstd",
}
}
}
2 changes: 1 addition & 1 deletion src/sinks/azure_blob/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn azure_blob_build_request_with_compression() {

assert_eq!(request.metadata.partition_key, "blob.log.gz".to_string());
assert_eq!(request.content_encoding, Some("gzip"));
assert_eq!(request.content_type, "application/gzip");
assert_eq!(request.content_type, "text/plain");
}

#[test]
Expand Down

0 comments on commit 4a049d4

Please sign in to comment.