-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #519 from embrace-io/poc-type-system
Enforce data capture types via SchemaType
- Loading branch information
Showing
16 changed files
with
102 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
...-android-sdk/src/main/java/io/embrace/android/embracesdk/arch/destination/LogEventData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
package io.embrace.android.embracesdk.arch.destination | ||
|
||
import io.embrace.android.embracesdk.Severity | ||
import io.embrace.android.embracesdk.arch.schema.TelemetryType | ||
import io.embrace.android.embracesdk.arch.schema.SchemaType | ||
|
||
/** | ||
* Represents a Log event that can be added to the current session span. | ||
* | ||
* | ||
* @param embType the type of the span. Used to differentiate data from different sources | ||
* @param schemaType the type of the span. Used to differentiate data from different sources | ||
* by the backend. | ||
* @param severity the severity of the log | ||
* @param message the message of the log | ||
* @param attributes the attributes of the span. emb-type is automatically added to these. | ||
*/ | ||
internal class LogEventData( | ||
embType: TelemetryType, | ||
val schemaType: SchemaType, | ||
val severity: Severity, | ||
val message: String, | ||
attributes: Map<String, String>? = null | ||
val message: String | ||
) { | ||
val attributes = (attributes ?: emptyMap()).plus(Pair("emb.type", embType.description)) | ||
val attributes = schemaType.attrs.plus(Pair("emb.type", schemaType.telemetryType.description)) | ||
} |
14 changes: 5 additions & 9 deletions
14
...android-sdk/src/main/java/io/embrace/android/embracesdk/arch/destination/SpanEventData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
package io.embrace.android.embracesdk.arch.destination | ||
|
||
import io.embrace.android.embracesdk.arch.schema.TelemetryType | ||
import io.embrace.android.embracesdk.arch.schema.SchemaType | ||
|
||
/** | ||
* Represents a span event that can be added to the current session span. | ||
* | ||
* @param embType the type of the event. Used to differentiate data from different sources | ||
* @param schemaType the type of the event. Used to differentiate data from different sources | ||
* by the backend. | ||
* @param spanName the name of the span event. | ||
* @param spanStartTimeMs the start time of the span event in milliseconds. | ||
* @param attributes the attributes of the span event. emb-type is automatically added to these. | ||
*/ | ||
internal class SpanEventData( | ||
embType: TelemetryType, | ||
val spanName: String, | ||
val spanStartTimeMs: Long, | ||
attributes: Map<String, String>? = null | ||
val schemaType: SchemaType, | ||
val spanStartTimeMs: Long | ||
) { | ||
val attributes = (attributes ?: emptyMap()).plus(Pair("emb.type", embType.description)) | ||
val attributes = schemaType.attrs.plus(Pair("emb.type", schemaType.telemetryType.description)) | ||
} |
12 changes: 4 additions & 8 deletions
12
...android-sdk/src/main/java/io/embrace/android/embracesdk/arch/destination/StartSpanData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
package io.embrace.android.embracesdk.arch.destination | ||
|
||
import io.embrace.android.embracesdk.arch.schema.TelemetryType | ||
import io.embrace.android.embracesdk.arch.schema.SchemaType | ||
|
||
/** | ||
* Holds the information required to start a span. | ||
* | ||
* @param embType the type of the span. Used to differentiate data from different sources | ||
* @param schemaType the type of the span. Used to differentiate data from different sources | ||
* by the backend. | ||
* @param spanName the name of the span. | ||
* @param spanStartTimeMs the start time of the span event in milliseconds. | ||
* @param attributes the attributes of the span. emb-type is automatically added to these. | ||
*/ | ||
internal class StartSpanData( | ||
embType: TelemetryType, | ||
val spanName: String, | ||
val schemaType: SchemaType, | ||
val spanStartTimeMs: Long, | ||
attributes: Map<String, String>? = null | ||
) { | ||
val attributes = (attributes ?: emptyMap()).plus(Pair("emb.type", embType.description)) | ||
val attributes = schemaType.attrs.plus(Pair("emb.type", schemaType.telemetryType.description)) | ||
} |
51 changes: 51 additions & 0 deletions
51
embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/arch/schema/SchemaType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.embrace.android.embracesdk.arch.schema | ||
|
||
import io.embrace.android.embracesdk.internal.logs.EmbraceLogAttributes | ||
import io.embrace.android.embracesdk.internal.utils.toNonNullMap | ||
import io.embrace.android.embracesdk.payload.AppExitInfoData | ||
|
||
internal sealed class SchemaType( | ||
val telemetryType: TelemetryType, | ||
val name: String, | ||
) { | ||
abstract val attrs: Map<String, String> | ||
|
||
internal class CustomBreadcrumb(message: String) : SchemaType( | ||
EmbType.System.Breadcrumb, | ||
"custom-breadcrumb" | ||
) { | ||
override val attrs = mapOf("message" to message) | ||
} | ||
|
||
internal class ViewBreadcrumb(viewName: String) : SchemaType( | ||
EmbType.Ux.View, | ||
"view-breadcrumb" | ||
) { | ||
override val attrs = mapOf("view.name" to viewName) | ||
} | ||
|
||
internal class AeiLog(message: AppExitInfoData) : SchemaType( | ||
EmbType.System.Exit, | ||
"aei-record" | ||
) { | ||
override val attrs = mapOf( | ||
"session-id" to message.sessionId, | ||
"session-id-error" to message.sessionIdError, | ||
"process-importance" to message.importance.toString(), | ||
"pss" to message.pss.toString(), | ||
"rs" to message.reason.toString(), | ||
"rss" to message.rss.toString(), | ||
"exit-status" to message.status.toString(), | ||
"timestamp" to message.timestamp.toString(), | ||
"description" to message.description, | ||
"trace-status" to message.traceStatus | ||
).toNonNullMap() | ||
} | ||
|
||
internal class Log(attributes: EmbraceLogAttributes) : SchemaType( | ||
EmbType.System.Log, | ||
"emb-log" | ||
) { | ||
override val attrs = attributes.toMap() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.