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-3458 Enable adding custom attributes to RUM telemetry (debug) logs #1378

Merged

Conversation

ncreated
Copy link
Collaborator

@ncreated ncreated commented Jul 18, 2023

What and why?

📦 This PR enables sending custom attributes with debug messages through Telemetry interface:

- public func debug(id: String, message: String)
+ public func debug(id: String, message: String, attributes: [String: Encodable]? = nil) {

It makes a preliminary step to enable metrics in this interface. Although we will introduce separate method for metrics, the foundation of telemetry attributes is done here to be leveraged in debug() logs as well.

How?

Fix in rum-models-generator

Because DataDog/rum-events-format#154 introduced "additionalProperties": true to telemetry schema, it surfaced a gap in our code generation where rum-models-generator was printing invalid Swift code for custom encode(to:) and decode(from:) conformance when a type includes constant property (immutable with default value).

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference
  • Add CHANGELOG entry for user facing changes

Custom CI job configuration (optional)

  • Run unit tests
  • Run integration tests
  • Run smoke tests

required updating the generator to not print custom coding implementation
for immutable properties with default value.
@ncreated ncreated self-assigned this Jul 18, 2023
@ncreated ncreated force-pushed the ncreated/RUMM-3458/custom-attributes-in-rum-telemetry branch from 573a9d3 to a2267db Compare July 18, 2023 18:04
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Jul 18, 2023

Datadog Report

Branch report: ncreated/RUMM-3458/custom-attributes-in-rum-telemetry
Commit report: 78a4974

dd-sdk-ios: 0 Failed, 0 New Flaky, 118 Passed, 0 Skipped, 2m 47.93s Wall Time

Comment on lines +295 to +300
/// This property will be ignored in coding because it uses default value and is immutable
public let ignoredProperty: String = "default value"

enum StaticCodingKeys: String, CodingKey {
case ignoredProperty = "ignoredProperty"
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without the fix, rum-models-generator would include this ignoredProperty key for custom coding in encode(to:) and init(from:) printed below, making the code snippet not compile.

@ncreated ncreated marked this pull request as ready for review July 19, 2023 06:12
@ncreated ncreated requested a review from a team as a code owner July 19, 2023 06:12
Copy link
Member

@maxep maxep left a comment

Choose a reason for hiding this comment

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

👌

@ncreated ncreated merged commit 4753d05 into develop Jul 19, 2023
7 checks passed
@ncreated ncreated deleted the ncreated/RUMM-3458/custom-attributes-in-rum-telemetry branch July 19, 2023 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants