Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUMM-1397 Update Endpoints #523

Merged
merged 2 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Datadog/Core/FeaturesConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ extension FeaturesConfiguration {
sdkServiceName: "dd-sdk-ios",
sdkEnvironment: "prod",
logsUploadURLWithClientToken: try ifValid(
endpointURLString: Datadog.Configuration.DatadogEndpoint.us.logsEndpoint.url,
endpointURLString: Datadog.Configuration.DatadogEndpoint.us1.logsEndpoint.url,
clientToken: internalMonitoringClientToken
)
)
Expand Down
90 changes: 87 additions & 3 deletions Sources/Datadog/DatadogConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,35 @@ extension Datadog {
public enum DatadogEndpoint {
/// US based servers.
/// Sends data to [app.datadoghq.com](https://app.datadoghq.com/).
case us1
/// US based servers.
/// Sends data to [app.datadoghq.com](https://us3.datadoghq.com/).
case us3
/// Europe based servers.
/// Sends data to [app.datadoghq.eu](https://app.datadoghq.eu/).
case eu1
/// US based servers, FedRAMP compatible.
/// Sends data to [app.ddog-gov.com](https://app.ddog-gov.com/).
case us1_fed
/// US based servers.
/// Sends data to [app.datadoghq.com](https://app.datadoghq.com/).
@available(*, deprecated, message: "Renamed to us1")
case us
/// Europe based servers.
/// Sends data to [app.datadoghq.eu](https://app.datadoghq.eu/).
@available(*, deprecated, message: "Renamed to eu1")
case eu
/// Gov servers.
/// Sends data to [app.ddog-gov.com](https://app.ddog-gov.com/).
@available(*, deprecated, message: "Renamed to us1_fed")
case gov

internal var logsEndpoint: LogsEndpoint {
switch self {
case .us1: return .us1
case .us3: return .us3
case .eu1: return .eu1
case .us1_fed: return .us1_fed
case .us: return .us
case .eu: return .eu
case .gov: return .gov
Expand All @@ -56,6 +75,10 @@ extension Datadog {

internal var tracesEndpoint: TracesEndpoint {
switch self {
case .us1: return .us1
case .us3: return .us3
case .eu1: return .eu1
case .us1_fed: return .us1_fed
case .us: return .us
case .eu: return .eu
case .gov: return .gov
Expand All @@ -64,6 +87,10 @@ extension Datadog {

internal var rumEndpoint: RUMEndpoint {
switch self {
case .us1: return .us1
case .us3: return .us3
case .eu1: return .eu1
case .us1_fed: return .us1_fed
case .us: return .us
case .eu: return .eu
case .gov: return .gov
Expand All @@ -75,18 +102,37 @@ extension Datadog {
public enum LogsEndpoint {
/// US based servers.
/// Sends logs to [app.datadoghq.com](https://app.datadoghq.com/).
case us1
/// US based servers.
/// Sends logs to [app.datadoghq.com](https://us3.datadoghq.com/).
case us3
/// Europe based servers.
/// Sends logs to [app.datadoghq.eu](https://app.datadoghq.eu/).
case eu1
/// US based servers, FedRAMP compatible.
/// Sends logs to [app.ddog-gov.com](https://app.ddog-gov.com/).
case us1_fed
/// US based servers.
/// Sends logs to [app.datadoghq.com](https://app.datadoghq.com/).
@available(*, deprecated, message: "Renamed to us1")
case us
/// Europe based servers.
/// Sends logs to [app.datadoghq.eu](https://app.datadoghq.eu/).
@available(*, deprecated, message: "Renamed to eu1")
case eu
/// Gov servers.
/// Sends logs to [app.ddog-gov.com](https://app.ddog-gov.com/).
@available(*, deprecated, message: "Renamed to us1_fed")
case gov
/// User-defined server.
case custom(url: String)

internal var url: String {
switch self {
case .us1: return "https://logs.browser-intake-datadoghq.com/v1/input/"
case .us3: return "https://logs.browser-intake-us3-datadoghq.com/v1/input/"
case .eu1: return "https://mobile-http-intake.logs.datadoghq.eu/v1/input/"
case .us1_fed: return "https://logs.browser-intake-ddog-gov.com/v1/input/"
case .us: return "https://mobile-http-intake.logs.datadoghq.com/v1/input/"
case .eu: return "https://mobile-http-intake.logs.datadoghq.eu/v1/input/"
case .gov: return "https://logs.browser-intake-ddog-gov.com/v1/input/"
Expand All @@ -99,18 +145,37 @@ extension Datadog {
public enum TracesEndpoint {
/// US based servers.
/// Sends traces to [app.datadoghq.com](https://app.datadoghq.com/).
case us1
/// US based servers.
/// Sends traces to [app.datadoghq.com](https://us3.datadoghq.com/).
case us3
/// Europe based servers.
/// Sends traces to [app.datadoghq.eu](https://app.datadoghq.eu/).
case eu1
/// US based servers, FedRAMP compatible.
/// Sends traces to [app.ddog-gov.com](https://app.ddog-gov.com/).
case us1_fed
/// US based servers.
/// Sends traces to [app.datadoghq.com](https://app.datadoghq.com/).
@available(*, deprecated, message: "Renamed to us1")
case us
/// Europe based servers.
/// Sends traces to [app.datadoghq.eu](https://app.datadoghq.eu/).
@available(*, deprecated, message: "Renamed to eu1")
case eu
/// Gov servers.
/// Sends traces to [app.ddog-gov.com](https://app.ddog-gov.com/).
@available(*, deprecated, message: "Renamed to us1_fed")
case gov
/// User-defined server.
case custom(url: String)

internal var url: String {
switch self {
case .us1: return "https://trace.browser-intake-datadoghq.com/v1/input/"
case .us3: return "https://trace.browser-intake-us3-datadoghq.com/v1/input/"
case .eu1: return "https:/public-trace-http-intake.logs.datadoghq.eu/v1/input/"
case .us1_fed: return "https://trace.browser-intake-ddog-gov.com/v1/input/"
case .us: return "https://public-trace-http-intake.logs.datadoghq.com/v1/input/"
case .eu: return "https://public-trace-http-intake.logs.datadoghq.eu/v1/input/"
case .gov: return "https://trace.browser-intake-ddog-gov.com/v1/input/"
Expand All @@ -123,18 +188,37 @@ extension Datadog {
public enum RUMEndpoint {
/// US based servers.
/// Sends RUM events to [app.datadoghq.com](https://app.datadoghq.com/).
case us1
/// US based servers.
/// Sends RUM events to [app.datadoghq.com](https://us3.datadoghq.com/).
case us3
/// Europe based servers.
/// Sends RUM events to [app.datadoghq.eu](https://app.datadoghq.eu/).
case eu1
/// US based servers, FedRAMP compatible.
/// Sends RUM events to [app.ddog-gov.com](https://app.ddog-gov.com/).
case us1_fed
/// US based servers.
/// Sends RUM events to [app.datadoghq.com](https://app.datadoghq.com/).
@available(*, deprecated, message: "Renamed to us1")
case us
/// Europe based servers.
/// Sends RUM events to [app.datadoghq.eu](https://app.datadoghq.eu/).
@available(*, deprecated, message: "Renamed to eu1")
case eu
/// Gov servers.
/// Sends RUM events to [app.ddog-gov.com](https://app.ddog-gov.com/).
@available(*, deprecated, message: "Renamed to us1_fed")
case gov
/// User-defined server.
case custom(url: String)

internal var url: String {
switch self {
case .us1: return "https://rum.browser-intake-datadoghq.com/v1/input/"
case .us3: return "https://rum.browser-intake-us3-datadoghq.com/v1/input/"
case .eu1: return "https://rum-http-intake.logs.datadoghq.eu/v1/input/"
case .us1_fed: return "https://rum.browser-intake-ddog-gov.com/v1/input/"
case .us: return "https://rum-http-intake.logs.datadoghq.com/v1/input/"
case .eu: return "https://rum-http-intake.logs.datadoghq.eu/v1/input/"
case .gov: return "https://rum.browser-intake-ddog-gov.com/v1/input/"
Expand Down Expand Up @@ -237,9 +321,9 @@ extension Datadog {
customLogsEndpoint: nil,
customTracesEndpoint: nil,
customRUMEndpoint: nil,
logsEndpoint: .us,
tracesEndpoint: .us,
rumEndpoint: .us,
logsEndpoint: .us1,
tracesEndpoint: .us1,
rumEndpoint: .us1,
serviceName: nil,
firstPartyHosts: nil,
spanEventMapper: nil,
Expand Down
36 changes: 36 additions & 0 deletions Sources/DatadogObjc/DatadogConfiguration+objc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ public class DDEndpoint: NSObject {

// MARK: - Public

@objc
public static func us1() -> DDEndpoint { .init(sdkEndpoint: .us1) }

@objc
public static func us3() -> DDEndpoint { .init(sdkEndpoint: .us3) }

@objc
public static func eu1() -> DDEndpoint { .init(sdkEndpoint: .eu1) }

@objc
public static func us1_fed() -> DDEndpoint { .init(sdkEndpoint: .us1_fed) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have DDLogsEndpoint / DDTracesEndpoint but we don't have DDRUMEndpoint, did we forget it or should we deprecate DDLogsEndpoint / DDTracesEndpoint as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both set(logsEndpoint: DDLogsEndpoint) and public func set(tracessEndpoint: DDLogsEndpoint) were deprecated when introducing common func set(endpoint: DDEndpoint). Enum cases were not deprecated, but they could be.


@objc
public static func eu() -> DDEndpoint { .init(sdkEndpoint: .eu) }

Expand All @@ -37,6 +49,18 @@ public class DDLogsEndpoint: NSObject {

// MARK: - Public

@objc
public static func us1() -> DDLogsEndpoint { .init(sdkEndpoint: .us1) }

@objc
public static func us3() -> DDLogsEndpoint { .init(sdkEndpoint: .us3) }

@objc
public static func eu1() -> DDLogsEndpoint { .init(sdkEndpoint: .eu1) }

@objc
public static func us1_fed() -> DDLogsEndpoint { .init(sdkEndpoint: .us1_fed) }

@objc
public static func eu() -> DDLogsEndpoint { .init(sdkEndpoint: .eu) }

Expand All @@ -60,6 +84,18 @@ public class DDTracesEndpoint: NSObject {

// MARK: - Public

@objc
public static func us1() -> DDTracesEndpoint { .init(sdkEndpoint: .us1) }

@objc
public static func us3() -> DDTracesEndpoint { .init(sdkEndpoint: .us3) }

@objc
public static func eu1() -> DDTracesEndpoint { .init(sdkEndpoint: .eu1) }

@objc
public static func us1_fed() -> DDTracesEndpoint { .init(sdkEndpoint: .us1_fed) }

@objc
public static func eu() -> DDTracesEndpoint { .init(sdkEndpoint: .eu) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,22 @@ class FeaturesConfigurationTests: XCTestCase {
)
}

XCTAssertEqual(
try configuration(datadogEndpoint: .us1).logging?.uploadURLWithClientToken.absoluteString,
"https://logs.browser-intake-datadoghq.com/v1/input/" + clientToken
)
XCTAssertEqual(
try configuration(datadogEndpoint: .us3).logging?.uploadURLWithClientToken.absoluteString,
"https://logs.browser-intake-us3-datadoghq.com/v1/input/" + clientToken
)
XCTAssertEqual(
try configuration(datadogEndpoint: .eu1).logging?.uploadURLWithClientToken.absoluteString,
"https://mobile-http-intake.logs.datadoghq.eu/v1/input/" + clientToken
)
XCTAssertEqual(
try configuration(datadogEndpoint: .us1_fed).logging?.uploadURLWithClientToken.absoluteString,
"https://logs.browser-intake-ddog-gov.com/v1/input/" + clientToken
)
XCTAssertEqual(
try configuration(datadogEndpoint: .us).logging?.uploadURLWithClientToken.absoluteString,
"https://mobile-http-intake.logs.datadoghq.com/v1/input/" + clientToken
Expand All @@ -150,6 +166,22 @@ class FeaturesConfigurationTests: XCTestCase {
"https://logs.browser-intake-ddog-gov.com/v1/input/" + clientToken
)

XCTAssertEqual(
try configuration(datadogEndpoint: .us1).tracing?.uploadURLWithClientToken.absoluteString,
"https://trace.browser-intake-datadoghq.com/v1/input/" + clientToken
)
XCTAssertEqual(
try configuration(datadogEndpoint: .us3).tracing?.uploadURLWithClientToken.absoluteString,
"https://trace.browser-intake-us3-datadoghq.com/v1/input/" + clientToken
)
XCTAssertEqual(
try configuration(datadogEndpoint: .eu1).tracing?.uploadURLWithClientToken.absoluteString,
"https:/public-trace-http-intake.logs.datadoghq.eu/v1/input/" + clientToken
)
XCTAssertEqual(
try configuration(datadogEndpoint: .us1_fed).tracing?.uploadURLWithClientToken.absoluteString,
"https://trace.browser-intake-ddog-gov.com/v1/input/" + clientToken
)
XCTAssertEqual(
try configuration(datadogEndpoint: .us).tracing?.uploadURLWithClientToken.absoluteString,
"https://public-trace-http-intake.logs.datadoghq.com/v1/input/" + clientToken
Expand All @@ -163,6 +195,22 @@ class FeaturesConfigurationTests: XCTestCase {
"https://trace.browser-intake-ddog-gov.com/v1/input/" + clientToken
)

XCTAssertEqual(
try configuration(datadogEndpoint: .us1).rum?.uploadURLWithClientToken.absoluteString,
"https://rum.browser-intake-datadoghq.com/v1/input/" + clientToken
)
XCTAssertEqual(
try configuration(datadogEndpoint: .us3).rum?.uploadURLWithClientToken.absoluteString,
"https://rum.browser-intake-us3-datadoghq.com/v1/input/" + clientToken
)
XCTAssertEqual(
try configuration(datadogEndpoint: .eu1).rum?.uploadURLWithClientToken.absoluteString,
"https://rum-http-intake.logs.datadoghq.eu/v1/input/" + clientToken
)
XCTAssertEqual(
try configuration(datadogEndpoint: .us1_fed).rum?.uploadURLWithClientToken.absoluteString,
"https://rum.browser-intake-ddog-gov.com/v1/input/" + clientToken
)
XCTAssertEqual(
try configuration(datadogEndpoint: .us).rum?.uploadURLWithClientToken.absoluteString,
"https://rum-http-intake.logs.datadoghq.com/v1/input/" + clientToken
Expand Down Expand Up @@ -543,7 +591,7 @@ class FeaturesConfigurationTests: XCTestCase {
XCTAssertEqual(configuration.sdkEnvironment, "prod", "Internal monitoring data should be available under \"env:prod\"")
XCTAssertEqual(
configuration.logsUploadURLWithClientToken.absoluteString,
"https://mobile-http-intake.logs.datadoghq.com/v1/input/" + internalMonitoringClientToken
"https://logs.browser-intake-datadoghq.com/v1/input/" + internalMonitoringClientToken
)
}

Expand Down Expand Up @@ -690,9 +738,9 @@ class FeaturesConfigurationTests: XCTestCase {
customLogsEndpoint: URL? = nil,
customTracesEndpoint: URL? = nil,
customRUMEndpoint: URL? = nil,
logsEndpoint: Datadog.Configuration.LogsEndpoint = .us,
tracesEndpoint: Datadog.Configuration.TracesEndpoint = .us,
rumEndpoint: Datadog.Configuration.RUMEndpoint = .us
logsEndpoint: Datadog.Configuration.LogsEndpoint = .us1,
tracesEndpoint: Datadog.Configuration.TracesEndpoint = .us1,
rumEndpoint: Datadog.Configuration.RUMEndpoint = .us1
) throws -> FeaturesConfiguration {
return try FeaturesConfiguration(
configuration: .mockWith(
Expand Down
22 changes: 11 additions & 11 deletions Tests/DatadogTests/Datadog/DatadogConfigurationBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class DatadogConfigurationBuilderTests: XCTestCase {
XCTAssertNil(configuration.customLogsEndpoint)
XCTAssertNil(configuration.customTracesEndpoint)
XCTAssertNil(configuration.customRUMEndpoint)
XCTAssertEqual(configuration.logsEndpoint, .us)
XCTAssertEqual(configuration.tracesEndpoint, .us)
XCTAssertEqual(configuration.rumEndpoint, .us)
XCTAssertEqual(configuration.logsEndpoint, .us1)
XCTAssertEqual(configuration.tracesEndpoint, .us1)
XCTAssertEqual(configuration.rumEndpoint, .us1)
XCTAssertNil(configuration.serviceName)
XCTAssertNil(configuration.firstPartyHosts)
XCTAssertNil(configuration.spanEventMapper)
Expand Down Expand Up @@ -73,7 +73,7 @@ class DatadogConfigurationBuilderTests: XCTestCase {
.enableTracing(false)
.enableRUM(false)
.enableCrashReporting(using: mockCrashReportingPlugin)
.set(endpoint: .eu)
.set(endpoint: .eu1)
.set(customLogsEndpoint: URL(string: "https://api.custom.logs/")!)
.set(customTracesEndpoint: URL(string: "https://api.custom.traces/")!)
.set(customRUMEndpoint: URL(string: "https://api.custom.rum/")!)
Expand Down Expand Up @@ -118,7 +118,7 @@ class DatadogConfigurationBuilderTests: XCTestCase {
XCTAssertFalse(configuration.tracingEnabled)
XCTAssertFalse(configuration.rumEnabled)
XCTAssertTrue(configuration.crashReportingPlugin === mockCrashReportingPlugin)
XCTAssertEqual(configuration.datadogEndpoint, .eu)
XCTAssertEqual(configuration.datadogEndpoint, .eu1)
XCTAssertEqual(configuration.customLogsEndpoint, URL(string: "https://api.custom.logs/")!)
XCTAssertEqual(configuration.customTracesEndpoint, URL(string: "https://api.custom.traces/")!)
XCTAssertEqual(configuration.customRUMEndpoint, URL(string: "https://api.custom.rum/")!)
Expand All @@ -145,16 +145,16 @@ class DatadogConfigurationBuilderTests: XCTestCase {
func testDeprecatedAPIs() {
let builder = Datadog.Configuration.builderUsing(clientToken: "abc-123", environment: "tests")
_ = (builder as ConfigurationBuilderDeprecatedAPIs).set(tracedHosts: ["example.com"])
_ = (builder as ConfigurationBuilderDeprecatedAPIs).set(logsEndpoint: .eu)
_ = (builder as ConfigurationBuilderDeprecatedAPIs).set(tracesEndpoint: .eu)
_ = (builder as ConfigurationBuilderDeprecatedAPIs).set(rumEndpoint: .eu)
_ = (builder as ConfigurationBuilderDeprecatedAPIs).set(logsEndpoint: .eu1)
_ = (builder as ConfigurationBuilderDeprecatedAPIs).set(tracesEndpoint: .eu1)
_ = (builder as ConfigurationBuilderDeprecatedAPIs).set(rumEndpoint: .eu1)

let configuration = builder.build()

XCTAssertEqual(configuration.firstPartyHosts, ["example.com"])
XCTAssertEqual(configuration.logsEndpoint, .eu)
XCTAssertEqual(configuration.tracesEndpoint, .eu)
XCTAssertEqual(configuration.rumEndpoint, .eu)
XCTAssertEqual(configuration.logsEndpoint, .eu1)
XCTAssertEqual(configuration.tracesEndpoint, .eu1)
XCTAssertEqual(configuration.rumEndpoint, .eu1)
}
}

Expand Down
Loading