DataDog / dd-sdk-ios

Datadog SDK for iOS - Swift and Objective-C.
Apache License 2.0
205 stars 123 forks source link

RUM-2491 fix: Fix missing `status` and `type` fields in RUM telemetry events #2042

Closed ncreated closed 2 weeks ago

ncreated commented 2 weeks ago

What and why?

📦 This fix addresses the issue of missing status and type fields in RUM telemetry events. The absence of these fields reduced SDK observability, causing logs classified as "error" to be incorrectly marked as "debug."

How?

The root cause was in the rum-models-generator, which started skipping encoding of immutable properties with default values after https://github.com/DataDog/dd-sdk-ios/pull/1378/commits/56ec883dca09d29036f2f1015789e81ec637505d. As a result, fields such as the following were excluded from telemetry event encoding:

/// Level/severity of the log
public let status: String = "debug"

/// Telemetry type
public let type: String? = "log"

The issue is resolved by ensuring these fields are included during encoding, but not during decoding (which was the original problem addressed in https://github.com/DataDog/dd-sdk-ios/pull/1378/commits/56ec883dca09d29036f2f1015789e81ec637505d. With this fix, all telemetry events now validate against the schema, confirmed through tests using the RUM Mock Server.

Additionally, a new UI was added to the Example project to help test various telemetry events:

Screenshot 2024-09-09 at 18 33 12

Review checklist

datadog-datadog-prod-us1[bot] commented 2 weeks ago

Datadog Report

Branch report: ncreated/RUM-2491/fix-telemetry-status Commit report: 66d0ad0 Test service: dd-sdk-ios

:white_check_mark: 0 Failed, 3432 Passed, 0 Skipped, 2m 17.48s Total Time :small_red_triangle_down: Test Sessions change in coverage: 11 decreased, 3 no change

:small_red_triangle_down: Code Coverage Decreases vs Default Branch (11)

This report shows up to 5 code coverage decreases.

  • test DatadogLogsTests tvOS 46.83% (-1.15%) - Details
  • test DatadogLogsTests iOS 46.78% (-1.14%) - Details
  • test DatadogCrashReportingTests tvOS 26.64% (-0.27%) - Details
  • test DatadogCrashReportingTests iOS 26.61% (-0.25%) - Details
  • test DatadogTraceTests iOS 54.29% (-0.12%) - Details