Skip to content

Commit 4a049d4

Browse files
fix(azure_blob sink): Base Content-Type on encoder and not compression (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]>
1 parent e476e12 commit 4a049d4

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

src/sinks/azure_blob/integration_tests.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ async fn azure_blob_insert_json_into_blob() {
111111
assert_eq!(blobs.len(), 1);
112112
assert!(blobs[0].clone().ends_with(".log"));
113113
let (blob, blob_lines) = config.get_blob(blobs[0].clone()).await;
114-
assert_eq!(blob.properties.content_type, String::from("text/plain"));
114+
assert_eq!(blob.properties.content_encoding, None);
115+
assert_eq!(
116+
blob.properties.content_type,
117+
String::from("application/x-ndjson")
118+
);
115119
let expected = events
116120
.iter()
117121
.map(|event| serde_json::to_string(&event.as_log().all_fields().unwrap()).unwrap())
@@ -138,10 +142,8 @@ async fn azure_blob_insert_lines_into_blob_gzip() {
138142
assert_eq!(blobs.len(), 1);
139143
assert!(blobs[0].clone().ends_with(".log.gz"));
140144
let (blob, blob_lines) = config.get_blob(blobs[0].clone()).await;
141-
assert_eq!(
142-
blob.properties.content_type,
143-
String::from("application/gzip")
144-
);
145+
assert_eq!(blob.properties.content_encoding, Some(String::from("gzip")));
146+
assert_eq!(blob.properties.content_type, String::from("text/plain"));
145147
assert_eq!(lines, blob_lines);
146148
}
147149

@@ -170,9 +172,10 @@ async fn azure_blob_insert_json_into_blob_gzip() {
170172
assert_eq!(blobs.len(), 1);
171173
assert!(blobs[0].clone().ends_with(".log.gz"));
172174
let (blob, blob_lines) = config.get_blob(blobs[0].clone()).await;
175+
assert_eq!(blob.properties.content_encoding, Some(String::from("gzip")));
173176
assert_eq!(
174177
blob.properties.content_type,
175-
String::from("application/gzip")
178+
String::from("application/x-ndjson")
176179
);
177180
let expected = events
178181
.iter()

src/sinks/azure_blob/request_builder.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,9 @@ impl RequestBuilder<(String, Vec<Event>)> for AzureBlobRequestOptions {
9393
AzureBlobRequest {
9494
blob_data,
9595
content_encoding: self.compression.content_encoding(),
96-
content_type: self.compression.content_type(),
96+
content_type: self.encoder.1.content_type(),
9797
metadata: azure_metadata,
9898
request_metadata,
9999
}
100100
}
101101
}
102-
103-
impl Compression {
104-
pub const fn content_type(self) -> &'static str {
105-
match self {
106-
Self::None => "text/plain",
107-
Self::Gzip(_) => "application/gzip",
108-
Self::Zlib(_) => "application/zlib",
109-
Self::Zstd(_) => "application/zstd",
110-
}
111-
}
112-
}

src/sinks/azure_blob/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn azure_blob_build_request_with_compression() {
129129

130130
assert_eq!(request.metadata.partition_key, "blob.log.gz".to_string());
131131
assert_eq!(request.content_encoding, Some("gzip"));
132-
assert_eq!(request.content_type, "application/gzip");
132+
assert_eq!(request.content_type, "text/plain");
133133
}
134134

135135
#[test]

0 commit comments

Comments
 (0)