Skip to content

Commit 7387d58

Browse files
author
Ignacio Bonafonte
authored
Allow disabling payload compression (#249)
1 parent 724ad61 commit 7387d58

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Sources/Exporters/DatadogExporter/ExporterConfiguration.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public struct ExporterConfiguration {
2222
var apiKey: String
2323
/// Endpoint that will be used for reporting.
2424
var endpoint: Endpoint
25+
/// Exporter will deflate payloads before sending
26+
var payloadCompression: Bool
2527

2628
var source: String
2729
/// This conditon will be evaluated before trying to upload data
@@ -38,14 +40,15 @@ public struct ExporterConfiguration {
3840
/// Option to add a custom prefix to all the metrics sent by the exporter
3941
var metricsNamePrefix: String?
4042

41-
public init(serviceName: String, resource: String, applicationName: String, applicationVersion: String, environment: String, apiKey: String, endpoint: Endpoint, source: String = "ios", uploadCondition: @escaping () -> Bool, performancePreset: PerformancePreset = .default, exportUnsampledSpans: Bool = true, exportUnsampledLogs: Bool = true, hostName: String? = nil, metricsNamePrefix: String? = "otel") {
43+
public init(serviceName: String, resource: String, applicationName: String, applicationVersion: String, environment: String, apiKey: String, endpoint: Endpoint, payloadCompression: Bool = true, source: String = "ios", uploadCondition: @escaping () -> Bool, performancePreset: PerformancePreset = .default, exportUnsampledSpans: Bool = true, exportUnsampledLogs: Bool = true, hostName: String? = nil, metricsNamePrefix: String? = "otel") {
4244
self.serviceName = serviceName
4345
self.resource = resource
4446
self.applicationName = applicationName
4547
self.version = applicationVersion
4648
self.environment = environment
4749
self.apiKey = apiKey
4850
self.endpoint = endpoint
51+
self.payloadCompression = payloadCompression
4952
self.source = source
5053
self.uploadCondition = uploadCondition
5154
self.performancePreset = performancePreset

Sources/Exporters/DatadogExporter/Logs/LogsExporter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ internal class LogsExporter {
5858
],
5959
headers: [
6060
.contentTypeHeader(contentType: .applicationJSON),
61-
.contentEncodingHeader(contentEncoding: .deflate),
6261
.userAgentHeader(
6362
appName: configuration.applicationName,
6463
appVersion: configuration.version,
@@ -68,7 +67,8 @@ internal class LogsExporter {
6867
.ddEVPOriginHeader(source: configuration.source),
6968
.ddEVPOriginVersionHeader(version: configuration.version),
7069
.ddRequestIDHeader()
71-
]
70+
] + (configuration.payloadCompression ? [RequestBuilder.HTTPHeader.contentEncodingHeader(contentEncoding: .deflate)] : [])
71+
7272
)
7373

7474
logsUpload = FeatureUpload(featureName: "logsUpload",

Sources/Exporters/DatadogExporter/Spans/SpansExporter.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ internal class SpansExporter {
4747
queryItems: [],
4848
headers: [
4949
.contentTypeHeader(contentType: .textPlainUTF8),
50-
.contentEncodingHeader(contentEncoding: .deflate),
5150
.userAgentHeader(
5251
appName: configuration.applicationName,
5352
appVersion: configuration.version,
@@ -57,7 +56,7 @@ internal class SpansExporter {
5756
.ddEVPOriginHeader(source: configuration.source),
5857
.ddEVPOriginVersionHeader(version: configuration.version),
5958
.ddRequestIDHeader(),
60-
]
59+
] + (configuration.payloadCompression ? [RequestBuilder.HTTPHeader.contentEncodingHeader(contentEncoding: .deflate)] : [])
6160
)
6261

6362
tracesUpload = FeatureUpload(featureName: "tracesUpload",

0 commit comments

Comments
 (0)