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-1588 + RUMM-1610 Update E2E test monitors to new metric format #601

Merged
merged 3 commits into from
Sep 23, 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
13 changes: 7 additions & 6 deletions Datadog/E2ETests/E2ETests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,24 @@ class E2ETests: XCTestCase {

/// - common performance monitor - measures `Datadog.initialize(...)` performance:
/// ```apm
/// $feature = core
/// $monitor_id = sdk_initialize_performance
/// $monitor_name = "[RUM] [iOS] Nightly Performance - sdk_initialize: has a high average execution time"
/// $monitor_query = "avg(last_1d):avg:trace.sdk_initialize{env:instrumentation,resource_name:sdk_initialize,service:com.datadog.ios.nightly} > 0.016"
/// $monitor_query = "avg(last_1d):avg:trace.perf_measure{env:instrumentation,resource_name:sdk_initialize,service:com.datadog.ios.nightly} > 0.016"
/// $monitor_threshold = 0.016
/// ```

// MARK: - Measuring Performance with APM

/// Measures time of execution for given `block` - sends it as a `Span` with a given name.
func measure(spanName: String, _ block: () -> Void) {
/// Measures time of execution for given `block` - sends it as a `"perf_measure"` `Span` with a given resource name.
func measure(resourceName: String, _ block: () -> Void) {
let start = Date()
block()
let stop = Date()

Global.sharedTracer
.startRootSpan(operationName: spanName, startTime: start)
.finish(at: stop)
let performanceSpan = Global.sharedTracer.startRootSpan(operationName: "perf_measure", startTime: start)
performanceSpan.setTag(key: DDTags.resource, value: resourceName)
performanceSpan.finish(at: stop)
}

// MARK: - SDK Lifecycle
Expand Down
27 changes: 14 additions & 13 deletions Datadog/E2ETests/Logging/LoggerBuilderE2ETests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ class LoggerBuilderE2ETests: E2ETests {

/// - common performance monitor - measures `Logger.builder.build()` performance:
/// ```apm
/// $feature = logs
/// $monitor_id = logs_logger_initialize_performance
/// $monitor_name = "[RUM] [iOS] Nightly Performance - logs_logger_initialize: has a high average execution time"
/// $monitor_query = "avg(last_1d):avg:trace.logs_logger_initialize{env:instrumentation,resource_name:logs_logger_initialize,service:com.datadog.ios.nightly} > 0.016"
/// $monitor_query = "avg(last_1d):avg:trace.perf_measure{env:instrumentation,resource_name:logs_logger_initialize,service:com.datadog.ios.nightly} > 0.016"
/// $monitor_threshold = 0.016
/// ```

Expand All @@ -35,7 +36,7 @@ class LoggerBuilderE2ETests: E2ETests {
/// $monitor_query = "logs(\"service:com.datadog.ios.nightly.custom @test_method_name:logs_logger_builder_set_service_name\").index(\"*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_logs_logger_builder_set_SERVICE_NAME() {
measure(spanName: DD.PerfSpanName.loggerInitialize) {
measure(resourceName: DD.PerfSpanName.loggerInitialize) {
logger = Logger.builder.set(serviceName: "com.datadog.ios.nightly.custom").build()
}

Expand All @@ -51,7 +52,7 @@ class LoggerBuilderE2ETests: E2ETests {
/// $monitor_query = "logs(\"service:com.datadog.ios.nightly @test_method_name:logs_logger_builder_set_logger_name @logger.name:custom_logger_name\").index(\"*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_logs_logger_builder_set_LOGGER_NAME() {
measure(spanName: DD.PerfSpanName.loggerInitialize) {
measure(resourceName: DD.PerfSpanName.loggerInitialize) {
logger = Logger.builder.set(loggerName: "custom_logger_name").build()
}

Expand All @@ -67,7 +68,7 @@ class LoggerBuilderE2ETests: E2ETests {
/// $monitor_query = "logs(\"service:com.datadog.ios.nightly @test_method_name:logs_logger_builder_send_network_info_enabled @network.client.reachability:*\").index(\"*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_logs_logger_builder_SEND_NETWORK_INFO_enabled() {
measure(spanName: DD.PerfSpanName.loggerInitialize) {
measure(resourceName: DD.PerfSpanName.loggerInitialize) {
logger = Logger.builder.sendNetworkInfo(true).build()
}

Expand All @@ -85,7 +86,7 @@ class LoggerBuilderE2ETests: E2ETests {
/// $notify_no_data = false
/// ```
func test_logs_logger_builder_SEND_NETWORK_INFO_disabled() {
measure(spanName: DD.PerfSpanName.loggerInitialize) {
measure(resourceName: DD.PerfSpanName.loggerInitialize) {
logger = Logger.builder.sendNetworkInfo(false).build()
}

Expand All @@ -103,7 +104,7 @@ class LoggerBuilderE2ETests: E2ETests {
/// $monitor_query = "logs(\"service:com.datadog.ios.nightly @test_method_name:logs_logger_builder_send_logs_to_datadog_enabled\").index(\"*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_logs_logger_builder_SEND_LOGS_TO_DATADOG_enabled() {
measure(spanName: DD.PerfSpanName.loggerInitialize) {
measure(resourceName: DD.PerfSpanName.loggerInitialize) {
logger = Logger.builder.sendLogsToDatadog(true).build()
}

Expand All @@ -121,7 +122,7 @@ class LoggerBuilderE2ETests: E2ETests {
/// $notify_no_data = false
/// ```
func test_logs_logger_builder_SEND_LOGS_TO_DATADOG_disabled() {
measure(spanName: DD.PerfSpanName.loggerInitialize) {
measure(resourceName: DD.PerfSpanName.loggerInitialize) {
logger = Logger.builder.sendLogsToDatadog(false).build()
}

Expand All @@ -137,7 +138,7 @@ class LoggerBuilderE2ETests: E2ETests {
/// $monitor_query = "logs(\"service:com.datadog.ios.nightly @test_method_name:logs_logger_builder_print_logs_to_console_enabled\").index(\"*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_logs_logger_builder_PRINT_LOGS_TO_CONSOLE_enabled() {
measure(spanName: DD.PerfSpanName.loggerInitialize) {
measure(resourceName: DD.PerfSpanName.loggerInitialize) {
logger = Logger.builder.printLogsToConsole(true, usingFormat: .random()).build()
}

Expand All @@ -153,7 +154,7 @@ class LoggerBuilderE2ETests: E2ETests {
/// $monitor_query = "logs(\"service:com.datadog.ios.nightly @test_method_name:logs_logger_builder_print_logs_to_console_disabled\").index(\"*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_logs_logger_builder_PRINT_LOGS_TO_CONSOLE_disabled() {
measure(spanName: DD.PerfSpanName.loggerInitialize) {
measure(resourceName: DD.PerfSpanName.loggerInitialize) {
logger = Logger.builder.printLogsToConsole(false, usingFormat: .random()).build()
}

Expand All @@ -171,7 +172,7 @@ class LoggerBuilderE2ETests: E2ETests {
/// $monitor_query = "logs(\"service:com.datadog.ios.nightly @test_method_name:logs_logger_builder_bundle_with_rum_enabled @application_id:* @session_id:*\").index(\"*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_logs_logger_builder_BUNDLE_WITH_RUM_enabled() {
measure(spanName: DD.PerfSpanName.loggerInitialize) {
measure(resourceName: DD.PerfSpanName.loggerInitialize) {
logger = Logger.builder.bundleWithRUM(true).build()
}

Expand All @@ -193,7 +194,7 @@ class LoggerBuilderE2ETests: E2ETests {
/// $notify_no_data = false
/// ```
func test_logs_logger_builder_BUNDLE_WITH_RUM_disabled() {
measure(spanName: DD.PerfSpanName.loggerInitialize) {
measure(resourceName: DD.PerfSpanName.loggerInitialize) {
logger = Logger.builder.bundleWithRUM(false).build()
}

Expand All @@ -215,7 +216,7 @@ class LoggerBuilderE2ETests: E2ETests {
/// $monitor_query = "logs(\"service:com.datadog.ios.nightly @test_method_name:logs_logger_builder_bundle_with_trace_enabled\").index(\"*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_logs_logger_builder_BUNDLE_WITH_TRACE_enabled() {
measure(spanName: DD.PerfSpanName.loggerInitialize) {
measure(resourceName: DD.PerfSpanName.loggerInitialize) {
logger = Logger.builder.bundleWithTrace(true).build()
}

Expand All @@ -235,7 +236,7 @@ class LoggerBuilderE2ETests: E2ETests {
/// $monitor_query = "logs(\"service:com.datadog.ios.nightly @test_method_name:logs_logger_builder_bundle_with_trace_disabled\").index(\"*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_logs_logger_builder_BUNDLE_WITH_TRACE_disabled() {
measure(spanName: DD.PerfSpanName.loggerInitialize) {
measure(resourceName: DD.PerfSpanName.loggerInitialize) {
logger = Logger.builder.bundleWithTrace(false).build()
}

Expand Down
Loading