Skip to content

Commit f2562d6

Browse files
committed
Fix startup metric scaling and plugin names
1 parent 527b4bc commit f2562d6

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

core/src/main/java/com/segment/analytics/kotlin/core/Telemetry.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ object Telemetry: Subscriber {
119119
// Assume sampleRate is now set and everything in the queue hasn't had it applied
120120
if (Math.random() > sampleRate) {
121121
resetQueue()
122+
} else {
123+
queue.forEach {
124+
it.value = (it.value / sampleRate).roundToInt()
125+
}
122126
}
123127

124128
telemetryJob = telemetryScope.launch(telemetryDispatcher) {

core/src/main/java/com/segment/analytics/kotlin/core/platform/Mediator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ internal class Mediator(internal var plugins: CopyOnWriteArrayList<Plugin> = Cop
3737
try {
3838
Telemetry.increment(Telemetry.INTEGRATION_METRIC) {
3939
it["message"] = "event-${event.type}"
40-
"plugin" to "${plugin.type}-${plugin.javaClass}"
40+
it["plugin"] = "${plugin.type}-${plugin.javaClass}"
4141
}
4242
when (plugin) {
4343
is DestinationPlugin -> {

core/src/main/java/com/segment/analytics/kotlin/core/platform/Timeline.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ internal class Timeline {
8080
}
8181
Telemetry.increment(Telemetry.INTEGRATION_METRIC) {
8282
it["message"] = "added"
83-
it["plugin"] = "${plugin.type.toString()}-${plugin.javaClass.toString()}"
83+
it["plugin"] = "${plugin.type}-${plugin.javaClass}"
8484
}
8585
plugins[plugin.type]?.add(plugin)
8686
with(analytics) {
@@ -109,7 +109,7 @@ internal class Timeline {
109109
list.remove(plugin)
110110
Telemetry.increment(Telemetry.INTEGRATION_METRIC) {
111111
it["message"] = "removed"
112-
it["plugin"] = "${plugin.type.toString()}-${plugin.javaClass.toString()}"
112+
it["plugin"] = "${plugin.type}-${plugin.javaClass}"
113113
}
114114
}
115115
}

0 commit comments

Comments
 (0)