Skip to content

Commit 703c477

Browse files
author
Ignacio Bonafonte
committed
Apply suggestions from @ncreated code review
1 parent b89615e commit 703c477

File tree

5 files changed

+8
-38
lines changed

5 files changed

+8
-38
lines changed

Sources/Exporters/DatadogExporter/ExporterConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public struct ExporterConfiguration {
3838
/// Option to add a custom prefix to all the metrics sent by the exporter
3939
var metricsNamePrefix: String?
4040

41-
public init(serviceName: String, resource: String, applicationName: String, applicationVersion: String, environment: String, apiKey: String, endpoint: Endpoint, source: String = "otel-swift-exporter", uploadCondition: @escaping () -> Bool, performancePreset: PerformancePreset = .default, exportUnsampledSpans: Bool = true, exportUnsampledLogs: Bool = true, hostName: String? = nil, metricsNamePrefix: String? = "otel") {
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") {
4242
self.serviceName = serviceName
4343
self.resource = resource
4444
self.applicationName = applicationName

Sources/Exporters/DatadogExporter/Upload/DataUploadStatus.swift

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

6-
76
import Foundation
87

98
private enum HTTPResponseStatusCode: Int {
@@ -52,35 +51,17 @@ internal struct DataUploadStatus {
5251
/// If set to `false` then data associated with the upload should be deleted as it does not need any more upload
5352
/// attempts (i.e. the upload succeeded or failed due to unrecoverable client error).
5453
let needsRetry: Bool
55-
56-
// MARK: - Debug Info
57-
58-
/// Upload status description printed to the console if SDK `.debug` verbosity is enabled.
59-
let userDebugDescription: String
60-
61-
/// An optional error printed to the console if SDK `.error` (or lower) verbosity is enabled.
62-
/// It is meant to indicate user action that must be taken to fix the upload issue (e.g. if the client token is invalid, it needs to be fixed).
63-
let userErrorMessage: String?
6454
}
6555

6656
extension DataUploadStatus {
6757
// MARK: - Initialization
6858

6959
init(httpResponse: HTTPURLResponse, ddRequestID: String?) {
7060
let statusCode = HTTPResponseStatusCode(rawValue: httpResponse.statusCode) ?? .unexpected
71-
72-
self.init(
73-
needsRetry: statusCode.needsRetry,
74-
userDebugDescription: "[response code: \(httpResponse.statusCode) (\(statusCode)), request ID: \(ddRequestID ?? "(???)")]",
75-
userErrorMessage: statusCode == .unauthorized ? "⚠️ The client token you provided seems to be invalid." : nil
76-
)
61+
self.init(needsRetry: statusCode.needsRetry)
7762
}
7863

7964
init(networkError: Error) {
80-
self.init(
81-
needsRetry: true, // retry this upload as it failed due to network transport isse
82-
userDebugDescription: "[error: \(networkError.localizedDescription)]", // e.g. "[error: A data connection is not currently allowed]"
83-
userErrorMessage: nil // nothing actionable for the user
84-
)
65+
self.init(needsRetry: true)
8566
}
8667
}

Sources/Exporters/DatadogExporter/Upload/DataUploader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal protocol DataUploaderType {
1414
/// Synchronously uploads data to server using `HTTPClient`.
1515
internal final class DataUploader: DataUploaderType {
1616
/// An unreachable upload status - only meant to satisfy the compiler.
17-
private static let unreachableUploadStatus = DataUploadStatus(needsRetry: false, userDebugDescription: "", userErrorMessage: nil)
17+
private static let unreachableUploadStatus = DataUploadStatus(needsRetry: false)
1818

1919
private let httpClient: HTTPClient
2020
private let requestBuilder: RequestBuilder

Sources/Exporters/DatadogExporter/Upload/RequestBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ internal struct RequestBuilder {
130130

131131
/// Creates `URLRequest` for uploading given `data` to Datadog.
132132
/// - Parameter data: data to be uploaded
133-
/// - Returns: the `URLRequest` object and `DD-REQUEST-ID` header value (for debugging).
133+
/// - Returns: the `URLRequest` object.
134134
func uploadRequest(with data: Data) -> URLRequest {
135135
var request = URLRequest(url: url)
136136
var headers = precomputedHeaders

Tests/ExportersTests/DatadogExporter/Helpers/CoreMocks.swift

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,24 +163,13 @@ struct DataUploaderMock: DataUploaderType {
163163
extension DataUploadStatus: RandomMockable {
164164
static func mockRandom() -> DataUploadStatus {
165165
let retryRandom: Bool = .random()
166-
return DataUploadStatus(
167-
needsRetry: retryRandom,
168-
userDebugDescription: .mockRandom(),
169-
userErrorMessage: .mockRandom()
170-
)
166+
return DataUploadStatus(needsRetry: retryRandom)
171167
}
172168

173169
static func mockWith(
174170
needsRetry: Bool = .mockAny(),
175-
accepted: Bool = true,
176-
userDebugDescription: String = .mockAny(),
177-
userErrorMessage: String? = nil,
178-
internalMonitoringError: (message: String, error: Error?, attributes: [String: String]?)? = nil
171+
accepted: Bool = true
179172
) -> DataUploadStatus {
180-
return DataUploadStatus(
181-
needsRetry: needsRetry,
182-
userDebugDescription: userDebugDescription,
183-
userErrorMessage: userErrorMessage
184-
)
173+
return DataUploadStatus(needsRetry: needsRetry)
185174
}
186175
}

0 commit comments

Comments
 (0)