Skip to content

Commit 13ecada

Browse files
author
Ignacio Bonafonte
authored
Merge pull request #223 from open-telemetry/revert-datadog-payload-compression
Revert "Datadog Exporter: Set gzip compression for traces and logs up loads"
2 parents 62c9ced + e9a8684 commit 13ecada

File tree

5 files changed

+3
-36
lines changed

5 files changed

+3
-36
lines changed

Sources/Exporters/DatadogExporter/Logs/LogsExporter.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ internal class LogsExporter {
6969
appName: configuration.applicationName,
7070
appVersion: configuration.version,
7171
device: Device.current
72-
),
73-
.compressedContentEncodingHeader()
72+
)
7473
])
7574

7675
logsUpload = FeatureUpload(featureName: "logsUpload",

Sources/Exporters/DatadogExporter/Metrics/MetricsExporter.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ internal class MetricsExporter {
6060
appVersion: configuration.version,
6161
device: Device.current
6262
),
63-
// metrics endpoint doesnt accept gzipped content
64-
//.compressedContentEncodingHeader()
6563
])
6664

6765
metricsUpload = FeatureUpload(featureName: "metricsUpload",

Sources/Exporters/DatadogExporter/Spans/SpansExporter.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ internal class SpansExporter {
5959
appName: configuration.applicationName,
6060
appVersion: configuration.version,
6161
device: Device.current
62-
),
63-
.compressedContentEncodingHeader()
62+
)
6463
])
6564

6665
tracesUpload = FeatureUpload(featureName: "tracesUpload",

Sources/Exporters/DatadogExporter/Upload/DataUploader.swift

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import Compression
76
import Foundation
87

98
/// Creates URL and adds query items before providing them
@@ -108,33 +107,9 @@ internal final class DataUploader {
108107
var request = URLRequest(url: urlProvider.url)
109108
request.httpMethod = "POST"
110109
request.allHTTPHeaderFields = httpHeaders.all
111-
request.httpBody = httpHeaders.all["Content-Encoding"] != nil ? compressData(data: data) : data
110+
request.httpBody = data
112111
return request
113112
}
114-
115-
private func compressData(data: Data) -> Data {
116-
let destinationBuffer = UnsafeMutablePointer<UInt8>.allocate(capacity: data.count + 10)
117-
var compressedSize: Int = 0
118-
data.withUnsafeBytes { (source: UnsafeRawBufferPointer) in
119-
// Set gzip header
120-
destinationBuffer[0] = 31
121-
destinationBuffer[1] = 139
122-
destinationBuffer[2] = 8
123-
destinationBuffer[3] = 0
124-
destinationBuffer[4] = 0
125-
destinationBuffer[5] = 0
126-
destinationBuffer[6] = 0
127-
destinationBuffer[7] = 0
128-
destinationBuffer[8] = 0
129-
destinationBuffer[9] = 0
130-
// Actually compress the buffer
131-
compressedSize = compression_encode_buffer(destinationBuffer.advanced(by: 10), data.count,
132-
source.bindMemory(to: UInt8.self).baseAddress!, data.count,
133-
nil,
134-
COMPRESSION_ZLIB)
135-
}
136-
return Data(bytesNoCopy: destinationBuffer, count: compressedSize + 2, deallocator: .free)
137-
}
138113
}
139114

140115
internal enum DataUploadStatus: Equatable, Hashable {

Sources/Exporters/DatadogExporter/Upload/HTTPHeaders.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ internal struct HTTPHeaders {
2222
return HTTPHeader(field: "Content-Type", value: contentType.rawValue)
2323
}
2424

25-
static func compressedContentEncodingHeader() -> HTTPHeader {
26-
return HTTPHeader( field: "Content-Encoding", value: "gzip")
27-
}
28-
2925
static func userAgentHeader(appName: String, appVersion: String, device: Device) -> HTTPHeader {
3026
return HTTPHeader(
3127
field: "User-Agent",

0 commit comments

Comments
 (0)