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

Remove duplicated LogPayload. #563

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package io.embrace.android.embracesdk.comms.api

import io.embrace.android.embracesdk.BuildConfig
import io.embrace.android.embracesdk.EventType
import io.embrace.android.embracesdk.internal.logs.LogPayload
import io.embrace.android.embracesdk.internal.payload.Envelope
import io.embrace.android.embracesdk.internal.payload.LogPayload
import io.embrace.android.embracesdk.internal.payload.SessionPayload
import io.embrace.android.embracesdk.network.http.HttpMethod
import io.embrace.android.embracesdk.payload.BlobMessage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.embrace.android.embracesdk.comms.api

import io.embrace.android.embracesdk.config.remote.RemoteConfig
import io.embrace.android.embracesdk.internal.logs.LogPayload
import io.embrace.android.embracesdk.internal.payload.Envelope
import io.embrace.android.embracesdk.internal.payload.LogPayload
import io.embrace.android.embracesdk.internal.payload.SessionPayload
import io.embrace.android.embracesdk.internal.utils.SerializationAction
import io.embrace.android.embracesdk.payload.BlobMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import io.embrace.android.embracesdk.comms.delivery.PendingApiCallsSender
import io.embrace.android.embracesdk.config.remote.RemoteConfig
import io.embrace.android.embracesdk.internal.Systrace
import io.embrace.android.embracesdk.internal.compression.ConditionalGzipOutputStream
import io.embrace.android.embracesdk.internal.logs.LogPayload
import io.embrace.android.embracesdk.internal.payload.Envelope
import io.embrace.android.embracesdk.internal.payload.LogPayload
import io.embrace.android.embracesdk.internal.payload.SessionPayload
import io.embrace.android.embracesdk.internal.serialization.EmbraceSerializer
import io.embrace.android.embracesdk.internal.utils.SerializationAction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.embrace.android.embracesdk.comms.delivery

import io.embrace.android.embracesdk.internal.logs.LogPayload
import io.embrace.android.embracesdk.internal.payload.LogPayload
import io.embrace.android.embracesdk.internal.payload.SessionPayload
import io.embrace.android.embracesdk.ndk.NdkService
import io.embrace.android.embracesdk.payload.BlobMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package io.embrace.android.embracesdk.comms.delivery
import io.embrace.android.embracesdk.comms.api.ApiService
import io.embrace.android.embracesdk.gating.GatingService
import io.embrace.android.embracesdk.internal.compression.ConditionalGzipOutputStream
import io.embrace.android.embracesdk.internal.logs.LogPayload
import io.embrace.android.embracesdk.internal.payload.Envelope
import io.embrace.android.embracesdk.internal.payload.LogPayload
import io.embrace.android.embracesdk.internal.payload.SessionPayload
import io.embrace.android.embracesdk.internal.serialization.EmbraceSerializer
import io.embrace.android.embracesdk.logging.InternalEmbraceLogger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package io.embrace.android.embracesdk.internal.logs

import io.embrace.android.embracesdk.comms.delivery.DeliveryService
import io.embrace.android.embracesdk.internal.clock.Clock
import io.embrace.android.embracesdk.internal.payload.LogPayload
import io.embrace.android.embracesdk.internal.payload.toNewPayload
import io.embrace.android.embracesdk.worker.ScheduledWorker
import java.lang.Long.min
import java.util.concurrent.ScheduledFuture
Expand Down Expand Up @@ -59,7 +61,7 @@ internal class LogOrchestrator(
val storedLogs = sink.flushLogs(MAX_LOGS_PER_BATCH)

if (storedLogs.isNotEmpty()) {
deliveryService.sendLogs(LogPayload(logs = storedLogs))
deliveryService.sendLogs(LogPayload(logs = storedLogs.map(EmbraceLogRecordData::toNewPayload)))
}

return true
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package io.embrace.android.embracesdk.internal.payload

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import io.embrace.android.embracesdk.internal.logs.LogPayload

/**
* Envelope used for Embrace API requests for different types of data:
* - [LogPayload]
* - LogPayload
* - SessionPayload
* - BlobPayload
* - CrashPayload
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.embrace.android.embracesdk

import io.embrace.android.embracesdk.comms.delivery.DeliveryService
import io.embrace.android.embracesdk.internal.logs.LogPayload
import io.embrace.android.embracesdk.internal.payload.LogPayload
import io.embrace.android.embracesdk.internal.payload.SessionPayload
import io.embrace.android.embracesdk.ndk.NdkService
import io.embrace.android.embracesdk.payload.BlobMessage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.embrace.android.embracesdk.comms.api

import io.embrace.android.embracesdk.EventType
import io.embrace.android.embracesdk.internal.logs.EmbraceLogBody
import io.embrace.android.embracesdk.internal.logs.EmbraceLogRecordData
import io.embrace.android.embracesdk.internal.logs.LogPayload
import io.embrace.android.embracesdk.internal.payload.Attribute
import io.embrace.android.embracesdk.internal.payload.Envelope
import io.embrace.android.embracesdk.internal.payload.Log
import io.embrace.android.embracesdk.internal.payload.LogBody
import io.embrace.android.embracesdk.internal.payload.LogPayload
import io.embrace.android.embracesdk.network.http.HttpMethod
import io.embrace.android.embracesdk.payload.AppInfo
import io.embrace.android.embracesdk.payload.BlobMessage
Expand Down Expand Up @@ -68,14 +69,14 @@ internal class ApiRequestMapperTest {
Envelope(
data = LogPayload(
logs = listOf(
EmbraceLogRecordData(
Log(
traceId = "traceId",
spanId = "spanId",
timeUnixNanos = 1234567890,
timeUnixNano = 1234567890,
severityText = "severityText",
severityNumber = 1,
body = EmbraceLogBody("a message"),
attributes = mapOf("key" to "value")
body = LogBody("a message"),
attributes = listOf(Attribute("key", "value")),
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import io.embrace.android.embracesdk.fakes.FakeDeliveryCacheManager
import io.embrace.android.embracesdk.fakes.FakeNetworkConnectivityService
import io.embrace.android.embracesdk.fakes.FakePendingApiCallsSender
import io.embrace.android.embracesdk.internal.compression.ConditionalGzipOutputStream
import io.embrace.android.embracesdk.internal.logs.EmbraceLogBody
import io.embrace.android.embracesdk.internal.logs.EmbraceLogRecordData
import io.embrace.android.embracesdk.internal.logs.LogPayload
import io.embrace.android.embracesdk.internal.payload.Attribute
import io.embrace.android.embracesdk.internal.payload.Envelope
import io.embrace.android.embracesdk.internal.payload.Log
import io.embrace.android.embracesdk.internal.payload.LogBody
import io.embrace.android.embracesdk.internal.payload.LogPayload
import io.embrace.android.embracesdk.internal.payload.SessionPayload
import io.embrace.android.embracesdk.internal.serialization.EmbraceSerializer
import io.embrace.android.embracesdk.logging.InternalEmbraceLogger
Expand Down Expand Up @@ -261,14 +262,14 @@ internal class EmbraceApiServiceTest {
val logsEnvelope = Envelope(
data = LogPayload(
logs = listOf(
EmbraceLogRecordData(
Log(
traceId = "traceId",
spanId = "spanId",
timeUnixNanos = 1234567890,
timeUnixNano = 1234567890,
severityText = "severityText",
severityNumber = 1,
body = EmbraceLogBody("a message"),
attributes = mapOf("key" to "value")
body = LogBody("a message"),
attributes = listOf(Attribute("key", "value"))
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package io.embrace.android.embracesdk.fakes
import io.embrace.android.embracesdk.comms.api.ApiService
import io.embrace.android.embracesdk.comms.api.CachedConfig
import io.embrace.android.embracesdk.config.remote.RemoteConfig
import io.embrace.android.embracesdk.internal.logs.LogPayload
import io.embrace.android.embracesdk.internal.payload.Envelope
import io.embrace.android.embracesdk.internal.payload.LogPayload
import io.embrace.android.embracesdk.internal.payload.SessionPayload
import io.embrace.android.embracesdk.internal.serialization.EmbraceSerializer
import io.embrace.android.embracesdk.internal.utils.SerializationAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ internal class LogOrchestratorTest {
latch.await(1000L, TimeUnit.MILLISECONDS)

assertEquals("Too many payloads sent", 1, deliveryService.lastSentLogPayloads.size)
assertEquals("Too many logs in payload", 50, deliveryService.lastSentLogPayloads[0].logs.size)
assertEquals("Too many logs in payload", 50, deliveryService.lastSentLogPayloads[0].logs?.size)
}

private fun verifyPayload(numberOfLogs: Int) {
assertNotNull(deliveryService.lastSentLogPayloads)
assertEquals(1, deliveryService.lastSentLogPayloads.size)
assertEquals(numberOfLogs, deliveryService.lastSentLogPayloads[0].logs.size)
assertEquals(numberOfLogs, deliveryService.lastSentLogPayloads[0].logs?.size)
}

private fun verifyPayloadNotSent() {
Expand Down