Skip to content

Commit 9522240

Browse files
Dvernon: MOB-3260/MOB-3261 - New Options (#154)
* MOB-3260 Add an option for slowRenderingDetectionEnabled * MOB-3260 adding slowRenderingDetectionEnabled to builder * MOB-3261 create new option for spanScheduleDelay * MOB-3261 renaming bspScheduleDelay and updating description
1 parent 83db163 commit 9522240

File tree

3 files changed

+61
-16
lines changed

3 files changed

+61
-16
lines changed

SplunkOtel.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
Pod::Spec.new do |s|
1313
s.name = 'SplunkOtel'
14-
s.version = '0.11.0'
14+
s.version = '0.11.1'
1515
s.summary = 'Splunk OpenTelemetry pod for iOS'
1616
s.description = <<-DESC
1717
The Splunk RUM agent for iOS provides a Swift package that captures:

SplunkRumWorkspace/SplunkRum/SplunkRum/SplunkRum.swift

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Foundation
1919
import WebKit
2020

2121
// Make sure the version numbers on the podspec and SplunkRum.swift match
22-
let SplunkRumVersionString = "0.11.0"
22+
let SplunkRumVersionString = "0.11.1"
2323

2424
/**
2525
Default maximum size of the disk cache in bytes.
@@ -48,9 +48,11 @@ public let DEFAULT_DISK_CACHE_MAX_SIZE_BYTES: Int64 = 25 * 1024 * 1024
4848
networkInstrumentation: Bool = true,
4949
enableDiskCache: Bool = false,
5050
spanDiskCacheMaxSize: Int64 = DEFAULT_DISK_CACHE_MAX_SIZE_BYTES,
51+
slowRenderingDetectionEnabled: Bool = true,
5152
slowFrameDetectionThresholdMs: Double = 16.7,
5253
frozenFrameDetectionThresholdMs: Double = 700,
53-
sessionSamplingRatio: Double = 1.0
54+
sessionSamplingRatio: Double = 1.0,
55+
spanSchedulingDelay: TimeInterval = 5.0
5456
) {
5557
// rejectionFilter not specified to make it possible to call from objc
5658
self.allowInsecureBeacon = allowInsecureBeacon
@@ -62,6 +64,7 @@ public let DEFAULT_DISK_CACHE_MAX_SIZE_BYTES: Int64 = 25 * 1024 * 1024
6264
self.networkInstrumentation = networkInstrumentation
6365
self.enableDiskCache = enableDiskCache
6466
self.spanDiskCacheMaxSize = spanDiskCacheMaxSize
67+
self.slowRenderingDetectionEnabled = slowRenderingDetectionEnabled
6568
self.slowFrameDetectionThresholdMs = slowFrameDetectionThresholdMs
6669
self.frozenFrameDetectionThresholdMs = frozenFrameDetectionThresholdMs
6770
self.sessionSamplingRatio = sessionSamplingRatio
@@ -79,12 +82,14 @@ public let DEFAULT_DISK_CACHE_MAX_SIZE_BYTES: Int64 = 25 * 1024 * 1024
7982
self.spanFilter = opts.spanFilter
8083
self.showVCInstrumentation = opts.showVCInstrumentation
8184
self.screenNameSpans = opts.screenNameSpans
85+
self.slowRenderingDetectionEnabled = opts.slowRenderingDetectionEnabled
8286
self.slowFrameDetectionThresholdMs = opts.slowFrameDetectionThresholdMs
8387
self.frozenFrameDetectionThresholdMs = opts.frozenFrameDetectionThresholdMs
8488
self.networkInstrumentation = opts.networkInstrumentation
8589
self.enableDiskCache = opts.enableDiskCache
8690
self.spanDiskCacheMaxSize = opts.spanDiskCacheMaxSize
8791
self.sessionSamplingRatio = opts.sessionSamplingRatio
92+
self.bspScheduleDelay = opts.bspScheduleDelay
8893
}
8994

9095
/**
@@ -130,6 +135,11 @@ public let DEFAULT_DISK_CACHE_MAX_SIZE_BYTES: Int64 = 25 * 1024 * 1024
130135
*/
131136
@objc public var networkInstrumentation: Bool = true
132137

138+
/**
139+
Enable slow rendering detection. Slow rendering detection generates spans whenever it detects a slow or frozen frame render.
140+
*/
141+
@objc public var slowRenderingDetectionEnabled: Bool = true
142+
133143
/**
134144
Threshold, in milliseconds, from which to count a rendered frame as slow.
135145
*/
@@ -156,6 +166,11 @@ public let DEFAULT_DISK_CACHE_MAX_SIZE_BYTES: Int64 = 25 * 1024 * 1024
156166
*/
157167
@objc public var sessionSamplingRatio: Double = 1.0
158168

169+
/**
170+
Set the maximum interval between 2 consecutive span exports
171+
*/
172+
@objc public var bspScheduleDelay: TimeInterval = 5.0
173+
159174
func toAttributeValue() -> String {
160175
var answer = "debug: "+debug.description
161176
if spanFilter != nil {
@@ -259,7 +274,9 @@ var splunkRumInitializeCalledTime = Date()
259274
spanDb: spanDb,
260275
maxFileSizeBytes: options?.spanDiskCacheMaxSize ?? DEFAULT_DISK_CACHE_MAX_SIZE_BYTES)
261276
let limiting = LimitingExporter(proxy: diskExporter, spanFilter: options?.spanFilter ?? nil)
262-
tracerProvider.addSpanProcessor(BatchSpanProcessor(spanExporter: limiting))
277+
let delay = options?.bspScheduleDelay ?? 5.0
278+
tracerProvider.addSpanProcessor(BatchSpanProcessor(spanExporter: limiting,
279+
scheduleDelay: delay))
263280
} else {
264281
DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async {
265282
SpanDb.deleteAtDefaultLocation()
@@ -268,7 +285,9 @@ var splunkRumInitializeCalledTime = Date()
268285
let zipkin = ZipkinTraceExporter(options: exportOptions)
269286
let retry = RetryExporter(proxy: zipkin)
270287
let limiting = LimitingExporter(proxy: retry, spanFilter: options?.spanFilter ?? nil)
271-
tracerProvider.addSpanProcessor(BatchSpanProcessor(spanExporter: limiting))
288+
let delay = options?.bspScheduleDelay ?? 5.0
289+
tracerProvider.addSpanProcessor(BatchSpanProcessor(spanExporter: limiting,
290+
scheduleDelay: delay))
272291
}
273292

274293
if options?.debug ?? false {
@@ -288,10 +307,12 @@ var splunkRumInitializeCalledTime = Date()
288307
}
289308
initializeNetworkTypeMonitoring()
290309
initalizeUIInstrumentation()
291-
startSlowFrameDetector(
292-
slowFrameDetectionThresholdMs: options?.slowFrameDetectionThresholdMs,
293-
frozenFrameDetectionThresholdMs: options?.frozenFrameDetectionThresholdMs
294-
)
310+
if options?.slowRenderingDetectionEnabled ?? true {
311+
startSlowFrameDetector(
312+
slowFrameDetectionThresholdMs: options?.slowFrameDetectionThresholdMs,
313+
frozenFrameDetectionThresholdMs: options?.frozenFrameDetectionThresholdMs
314+
)
315+
}
295316
// not initializeAppLifecycleInstrumentation, done at end of AppStart
296317
srInit.end()
297318
initialized = true
@@ -351,7 +372,9 @@ var splunkRumInitializeCalledTime = Date()
351372
spanDb: spanDb,
352373
maxFileSizeBytes: options.spanDiskCacheMaxSize)
353374
let limiting = LimitingExporter(proxy: diskExporter, spanFilter: options.spanFilter)
354-
tracerProvider.addSpanProcessor(BatchSpanProcessor(spanExporter: limiting))
375+
let delay = options.bspScheduleDelay
376+
tracerProvider.addSpanProcessor(BatchSpanProcessor(spanExporter: limiting,
377+
scheduleDelay: delay))
355378
} else {
356379
DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async {
357380
SpanDb.deleteAtDefaultLocation()
@@ -360,7 +383,9 @@ var splunkRumInitializeCalledTime = Date()
360383
let zipkin = ZipkinTraceExporter(options: exportOptions)
361384
let retry = RetryExporter(proxy: zipkin)
362385
let limiting = LimitingExporter(proxy: retry, spanFilter: options.spanFilter)
363-
tracerProvider.addSpanProcessor(BatchSpanProcessor(spanExporter: limiting))
386+
let delay = options.bspScheduleDelay
387+
tracerProvider.addSpanProcessor(BatchSpanProcessor(spanExporter: limiting,
388+
scheduleDelay: delay))
364389
}
365390

366391
if options.debug {
@@ -378,10 +403,12 @@ var splunkRumInitializeCalledTime = Date()
378403
}
379404
initializeNetworkTypeMonitoring()
380405
initalizeUIInstrumentation()
381-
startSlowFrameDetector(
382-
slowFrameDetectionThresholdMs: options.slowFrameDetectionThresholdMs,
383-
frozenFrameDetectionThresholdMs: options.frozenFrameDetectionThresholdMs
384-
)
406+
if options.slowRenderingDetectionEnabled {
407+
startSlowFrameDetector(
408+
slowFrameDetectionThresholdMs: options.slowFrameDetectionThresholdMs,
409+
frozenFrameDetectionThresholdMs: options.frozenFrameDetectionThresholdMs
410+
)
411+
}
385412
// not initializeAppLifecycleInstrumentation, done at end of AppStart
386413
srInit.end()
387414
initialized = true

SplunkRumWorkspace/SplunkRum/SplunkRum/SplunkRumBuilder.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ import Foundation
3030
private var networkInstrumentation: Bool = true
3131
private var enableDiskCache: Bool = false
3232
private var spanDiskCacheMaxSize: Int64 = DEFAULT_DISK_CACHE_MAX_SIZE_BYTES
33+
private var slowRenderingDetectionEnabled: Bool = true
3334
private var slowFrameDetectionThresholdMs: Double = 16.7
3435
private var frozenFrameDetectionThresholdMs: Double = 700
3536
private var sessionSamplingRatio: Double = 1.0
3637
private var appName: String?
38+
private var spanSchedulingDelay: TimeInterval = 5.0
3739

3840
@objc public init(beaconUrl: String, rumAuth: String) {
3941
self.beaconUrl = beaconUrl
@@ -108,6 +110,13 @@ import Foundation
108110
return self
109111
}
110112

113+
@discardableResult
114+
@objc
115+
public func slowRenderingDetectionEnabled(_ enabled: Bool) -> SplunkRumBuilder {
116+
self.slowRenderingDetectionEnabled = enabled
117+
return self
118+
}
119+
111120
@discardableResult
112121
@objc
113122
public func slowFrameDetectionThresholdMs(thresholdMs: Double) -> SplunkRumBuilder {
@@ -136,6 +145,13 @@ import Foundation
136145
return self
137146
}
138147

148+
@discardableResult
149+
@objc
150+
public func setSpanSchedulingDelay(seconds: TimeInterval) -> SplunkRumBuilder {
151+
self.spanSchedulingDelay = seconds
152+
return self
153+
}
154+
139155
@discardableResult
140156
@objc
141157
public func build() -> Bool {
@@ -151,8 +167,10 @@ import Foundation
151167
networkInstrumentation: self.networkInstrumentation,
152168
enableDiskCache: self.enableDiskCache,
153169
spanDiskCacheMaxSize: self.spanDiskCacheMaxSize,
170+
slowRenderingDetectionEnabled: self.slowRenderingDetectionEnabled,
154171
slowFrameDetectionThresholdMs: self.slowFrameDetectionThresholdMs,
155172
frozenFrameDetectionThresholdMs: self.frozenFrameDetectionThresholdMs,
156-
sessionSamplingRatio: self.sessionSamplingRatio))
173+
sessionSamplingRatio: self.sessionSamplingRatio,
174+
spanSchedulingDelay: self.spanSchedulingDelay))
157175
}
158176
}

0 commit comments

Comments
 (0)