Skip to content

Commit

Permalink
RUM-1836 feat(otel-tracer): send telemetry for Tracer API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshnj committed Mar 11, 2024
1 parent 6100722 commit 1198e51
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 2 deletions.
8 changes: 8 additions & 0 deletions DatadogInternal/Sources/Telemetry/Telemetry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public struct ConfigurationTelemetry: Equatable {
public let startSessionReplayRecordingManually: Bool?
public let telemetryConfigurationSampleRate: Int64?
public let telemetrySampleRate: Int64?
public let tracerAPI: String?
public let tracerAPIVersion: String?
public let traceSampleRate: Int64?
public let trackBackgroundEvents: Bool?
public let trackCrossPlatformLongTasks: Bool?
Expand Down Expand Up @@ -199,6 +201,8 @@ extension Telemetry {
startSessionReplayRecordingManually: Bool? = nil,
telemetryConfigurationSampleRate: Int64? = nil,
telemetrySampleRate: Int64? = nil,
tracerAPI: String? = nil,
tracerAPIVersion: String? = nil,
traceSampleRate: Int64? = nil,
trackBackgroundEvents: Bool? = nil,
trackCrossPlatformLongTasks: Bool? = nil,
Expand Down Expand Up @@ -250,6 +254,8 @@ extension Telemetry {
startSessionReplayRecordingManually: startSessionReplayRecordingManually,
telemetryConfigurationSampleRate: telemetryConfigurationSampleRate,
telemetrySampleRate: telemetrySampleRate,
tracerAPI: tracerAPI,
tracerAPIVersion: tracerAPIVersion,
traceSampleRate: traceSampleRate,
trackBackgroundEvents: trackBackgroundEvents,
trackCrossPlatformLongTasks: trackCrossPlatformLongTasks,
Expand Down Expand Up @@ -356,6 +362,8 @@ extension ConfigurationTelemetry {
startSessionReplayRecordingManually: other.startSessionReplayRecordingManually ?? startSessionReplayRecordingManually,
telemetryConfigurationSampleRate: other.telemetryConfigurationSampleRate ?? telemetryConfigurationSampleRate,
telemetrySampleRate: other.telemetrySampleRate ?? telemetrySampleRate,
tracerAPI: other.tracerAPI ?? tracerAPI,
tracerAPIVersion: other.tracerAPIVersion ?? tracerAPIVersion,
traceSampleRate: other.traceSampleRate ?? traceSampleRate,
trackBackgroundEvents: other.trackBackgroundEvents ?? trackBackgroundEvents,
trackCrossPlatformLongTasks: other.trackCrossPlatformLongTasks ?? trackCrossPlatformLongTasks,
Expand Down
2 changes: 2 additions & 0 deletions DatadogInternal/Tests/Telemetry/TelemetryMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ extension ConfigurationTelemetry {
startSessionReplayRecordingManually: .mockRandom(),
telemetryConfigurationSampleRate: .mockRandom(),
telemetrySampleRate: .mockRandom(),
tracerAPI: .mockRandom(),
tracerAPIVersion: .mockRandom(),
traceSampleRate: .mockRandom(),
trackBackgroundEvents: .mockRandom(),
trackCrossPlatformLongTasks: .mockRandom(),
Expand Down
2 changes: 2 additions & 0 deletions DatadogInternal/Tests/Telemetry/TelemetryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ class TelemetryTest: Telemetry {
startSessionReplayRecordingManually: configuration.startSessionReplayRecordingManually,
telemetryConfigurationSampleRate: configuration.telemetryConfigurationSampleRate,
telemetrySampleRate: configuration.telemetrySampleRate,
tracerAPI: configuration.tracerAPI,
tracerAPIVersion: configuration.tracerAPIVersion,
traceSampleRate: configuration.traceSampleRate,
trackBackgroundEvents: configuration.trackBackgroundEvents,
trackCrossPlatformLongTasks: configuration.trackCrossPlatformLongTasks,
Expand Down
12 changes: 11 additions & 1 deletion DatadogObjc/Sources/RUM/RUMDataModels+objc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6055,6 +6055,16 @@ public class DDTelemetryConfigurationEventTelemetryConfiguration: NSObject {
root.swiftModel.telemetry.configuration.traceSampleRate as NSNumber?
}

@objc public var tracerApi: String? {
set { root.swiftModel.telemetry.configuration.tracerApi = newValue }
get { root.swiftModel.telemetry.configuration.tracerApi }
}

@objc public var tracerApiVersion: String? {
set { root.swiftModel.telemetry.configuration.tracerApiVersion = newValue }
get { root.swiftModel.telemetry.configuration.tracerApiVersion }
}

@objc public var trackBackgroundEvents: NSNumber? {
set { root.swiftModel.telemetry.configuration.trackBackgroundEvents = newValue?.boolValue }
get { root.swiftModel.telemetry.configuration.trackBackgroundEvents as NSNumber? }
Expand Down Expand Up @@ -6303,4 +6313,4 @@ public class DDTelemetryConfigurationEventView: NSObject {

// swiftlint:enable force_unwrapping

// Generated from https://github.com/DataDog/rum-events-format/tree/389581be98dcf8efbfcfe7bffaa32d53f960fb6f
// Generated from https://github.com/DataDog/rum-events-format/tree/ee2a723eee85de3007dffff7aff941cc154a0bdb
10 changes: 9 additions & 1 deletion DatadogRUM/Sources/DataModels/RUMDataModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3007,6 +3007,12 @@ public struct TelemetryConfigurationEvent: RUMDataModel {
/// The percentage of requests traced
public let traceSampleRate: Int64?

/// The tracer API used by the SDK. Possible values: 'Datadog', 'OpenTelemetry', 'OpenTracing'
public var tracerApi: String?

/// The version of the tracer API used by the SDK. Eg. '0.1.0'
public var tracerApiVersion: String?

/// Whether RUM events are tracked when the application is in Background
public var trackBackgroundEvents: Bool?

Expand Down Expand Up @@ -3119,6 +3125,8 @@ public struct TelemetryConfigurationEvent: RUMDataModel {
case telemetryConfigurationSampleRate = "telemetry_configuration_sample_rate"
case telemetrySampleRate = "telemetry_sample_rate"
case traceSampleRate = "trace_sample_rate"
case tracerApi = "tracer_api"
case tracerApiVersion = "tracer_api_version"
case trackBackgroundEvents = "track_background_events"
case trackCrossPlatformLongTasks = "track_cross_platform_long_tasks"
case trackErrors = "track_errors"
Expand Down Expand Up @@ -3567,4 +3575,4 @@ public enum RUMMethod: String, Codable {
case patch = "PATCH"
}

// Generated from https://github.com/DataDog/rum-events-format/tree/389581be98dcf8efbfcfe7bffaa32d53f960fb6f
// Generated from https://github.com/DataDog/rum-events-format/tree/500bf36463aaeffb2363627368262d5e27023b0f
2 changes: 2 additions & 0 deletions DatadogRUM/Sources/Integrations/TelemetryReceiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ private extension TelemetryConfigurationEvent.Telemetry.Configuration {
telemetryConfigurationSampleRate: nil,
telemetrySampleRate: configuration.telemetrySampleRate,
traceSampleRate: configuration.traceSampleRate,
tracerApi: configuration.tracerAPI,
tracerApiVersion: configuration.tracerAPIVersion,
trackBackgroundEvents: configuration.trackBackgroundEvents,
trackCrossPlatformLongTasks: configuration.trackCrossPlatformLongTasks,
trackErrors: configuration.trackErrors,
Expand Down
3 changes: 3 additions & 0 deletions DatadogTrace/Sources/OpenTelemetry/OTelTracerProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public class OTelTracerProvider: OpenTelemetryApi.TracerProvider {
)
}

// Send tracer API usage to telemetry
core?.telemetry.configuration(tracerAPI: "OpenTelemetry", tracerAPIVersion: OpenTelemetry.version)

return feature.tracer
} catch {
consolePrint("\(error)", .error)
Expand Down
3 changes: 3 additions & 0 deletions DatadogTrace/Sources/Tracer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public class Tracer {
)
}

// Send tracer API usage to telemetry
core.telemetry.configuration(tracerAPI: "OpenTracing")

return feature.tracer
} catch {
consolePrint("\(error)", .error)
Expand Down

0 comments on commit 1198e51

Please sign in to comment.