Skip to content

Commit aabdc94

Browse files
author
Nacho Bonafonte
committed
Add support for Ajpan Datacenter
1 parent 79ea143 commit aabdc94

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Sources/DatadogSDKTesting/DDTracer.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ internal class DDTracer {
6767
endpoint = Endpoint.us5
6868
case "eu", "EU", "eu1", "EU1", "https://app.datadoghq.eu", "app.datadoghq.eu", "datadoghq.eu":
6969
endpoint = Endpoint.eu1
70+
case "ap1", "AP!", "https://ap1.datadoghq.com", "ap1.datadoghq.com":
71+
endpoint = Endpoint.ap1
7072
// case "gov", "GOV", "us1_fed", "US1_FED", "https://app.ddog-gov.com", "app.ddog-gov.com", "ddog-gov.com":
7173
// endpoint = Endpoint.us1_fed
7274
case "staging", "Staging", "https://dd.datad0g.com", "dd.datad0g.com", "datad0g.com":
@@ -324,7 +326,6 @@ internal class DDTracer {
324326

325327
self.tracerProviderSdk.forceFlush()
326328
Log.debug("Tracer flush finished")
327-
328329
}
329330

330331
func addPropagationsHeadersToEnvironment() {

Sources/EventsExporter/Upload/DatadogEndpoints.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public enum Endpoint {
1919
/// Europe based servers.
2020
/// Sends data to [app.datadoghq.eu](https://app.datadoghq.eu/).
2121
case eu1
22+
/// Japan based servers.
23+
/// Sends data to [app.datadoghq.eu](https://ap1.datadoghq.com/).
24+
case ap1
2225
/// Gov servers.
2326
/// Sends data to [app.ddog-gov.com](https://app.ddog-gov.com/).
2427
// case us1_fed
@@ -35,6 +38,7 @@ public enum Endpoint {
3538
case .us3: return URL(string: "https://logs.browser-intake-us3-datadoghq.com/" + endpoint)!
3639
case .us5: return URL(string: "https://logs.browser-intake-us5-datadoghq.com/" + endpoint)!
3740
case .eu1: return URL(string: "https://mobile-http-intake.logs.datadoghq.eu/" + endpoint)!
41+
case .ap1: return URL(string: "https://logs.browser-intake-ap1-datadoghq.com/" + endpoint)!
3842
case .staging: return URL(string: "https://logs.browser-intake-datad0g.com/" + endpoint)!
3943
case let .custom(_, logsURL: logsUrl): return logsUrl
4044
}
@@ -47,6 +51,7 @@ public enum Endpoint {
4751
case .us3: return URL(string: "https://citestcycle-intake.us3.datadoghq.com/" + endpoint)!
4852
case .us5: return URL(string: "https://citestcycle-intake.us5.datadoghq.com/" + endpoint)!
4953
case .eu1: return URL(string: "https://citestcycle-intake.datadoghq.eu/" + endpoint)!
54+
case .ap1: return URL(string: "https://citestcycle-intake.ap1.datadoghq.com/" + endpoint)!
5055
case .staging: return URL(string: "https://citestcycle-intake.datad0g.com/" + endpoint)!
5156
case let .custom(testsURL: testsURL, _): return testsURL
5257
}
@@ -59,6 +64,7 @@ public enum Endpoint {
5964
case .us3: return URL(string: "https://event-platform-intake.us3.datadoghq.com/" + endpoint)!
6065
case .us5: return URL(string: "https://event-platform-intake.us5.datadoghq.com/" + endpoint)!
6166
case .eu1: return URL(string: "https://event-platform-intake.datadoghq.eu/" + endpoint)!
67+
case .ap1: return URL(string: "https://event-platform-intake.ap1.datadoghq.com/" + endpoint)!
6268
case .staging: return URL(string: "https://event-platform-intake.datad0g.com/" + endpoint)!
6369
case let .custom(testsURL: testsURL, _): return testsURL
6470
}
@@ -71,6 +77,7 @@ public enum Endpoint {
7177
case .us3: return URL(string: "https://api.us3.datadoghq.com/" + endpoint)!
7278
case .us5: return URL(string: "https://api.us5.datadoghq.com/" + endpoint)!
7379
case .eu1: return URL(string: "https://api.datadoghq.eu/" + endpoint)!
80+
case .ap1: return URL(string: "https://api.ap1.datadoghq.com/" + endpoint)!
7481
case .staging: return URL(string: "https://api.datad0g.com/" + endpoint)!
7582
case let .custom(testsURL: testsURL, _): return testsURL
7683
}
@@ -83,6 +90,7 @@ public enum Endpoint {
8390
case .us3: return URL(string: "https://api.us3.datadoghq.com/" + endpoint)!
8491
case .us5: return URL(string: "https://api.us5.datadoghq.com/" + endpoint)!
8592
case .eu1: return URL(string: "https://api.datadoghq.eu/" + endpoint)!
93+
case .ap1: return URL(string: "https://api.ap1.datadoghq.com/" + endpoint)!
8694
case .staging: return URL(string: "https://api.datad0g.com/" + endpoint)!
8795
case let .custom(testsURL: testsURL, _): return testsURL
8896
}
@@ -95,6 +103,7 @@ public enum Endpoint {
95103
case .us3: return URL(string: "https://api.us3.datadoghq.com/" + endpoint)!
96104
case .us5: return URL(string: "https://api.us5.datadoghq.com/" + endpoint)!
97105
case .eu1: return URL(string: "https://api.datadoghq.eu/" + endpoint)!
106+
case .ap1: return URL(string: "https://api.ap1.datadoghq.com/" + endpoint)!
98107
case .staging: return URL(string: "https://api.datad0g.com/" + endpoint)!
99108
case let .custom(testsURL: testsURL, _): return testsURL
100109
}
@@ -107,6 +116,7 @@ public enum Endpoint {
107116
case .us3: return URL(string: "https://api.us3.datadoghq.com/" + endpoint)!
108117
case .us5: return URL(string: "https://api.us5.datadoghq.com/" + endpoint)!
109118
case .eu1: return URL(string: "https://api.datadoghq.eu/" + endpoint)!
119+
case .ap1: return URL(string: "https://api.ap1.datadoghq.com/" + endpoint)!
110120
case .staging: return URL(string: "https://api.datad0g.com/" + endpoint)!
111121
case let .custom(testsURL: testsURL, _): return testsURL
112122
}

Tests/DatadogSDKTesting/DDTracerTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ class DDTracerTests: XCTestCase {
149149
XCTAssertTrue(tracer.endpointURLs().contains("https://mobile-http-intake.logs.datadoghq.eu/api/v2/logs"))
150150
DDEnvironmentValues.environment["DD_ENDPOINT"] = nil
151151
}
152+
153+
func testEndpointChangeToAP1() {
154+
DDEnvironmentValues.environment["DD_ENDPOINT"] = "ap1"
155+
resetEnvironmentVariables()
156+
157+
let tracer = DDTracer()
158+
XCTAssertTrue(tracer.endpointURLs().contains("https://citestcycle-intake.ap1.datadoghq.com/api/v2/citestcycle"))
159+
XCTAssertTrue(tracer.endpointURLs().contains("https://logs.browser-intake-ap1-datadoghq.com/api/v2/logs"))
160+
DDEnvironmentValues.environment["DD_ENDPOINT"] = nil
161+
}
152162

153163
// func testEndpointChangeToGov() {
154164
// DDEnvironmentValues.environment["DD_ENDPOINT"] = "GOV"

0 commit comments

Comments
 (0)