Skip to content

Commit 362e5ee

Browse files
Merge pull request #2409 from embrace-io/bump-dep
Bump opentelemetry-kotlin to 0.2.4
2 parents 591e1ba + 6404bbc commit 362e5ee

File tree

13 files changed

+74
-81
lines changed

13 files changed

+74
-81
lines changed

embrace-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/arch/destination/LogWriterImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class LogWriterImpl(
2727

2828
override fun addLog(
2929
schemaType: SchemaType,
30-
severity: io.embrace.android.embracesdk.Severity,
30+
severity: Severity,
3131
message: String,
3232
isPrivate: Boolean,
3333
addCurrentSessionInfo: Boolean,
@@ -43,7 +43,7 @@ class LogWriterImpl(
4343
body = message,
4444
severityNumber = severityNumber,
4545
severityText = getSeverityText(severityNumber),
46-
timestampNs = TimeUnit.MILLISECONDS.toNanos(logTimeMs)
46+
timestamp = TimeUnit.MILLISECONDS.toNanos(logTimeMs)
4747
) {
4848
setStringAttribute(LogIncubatingAttributes.LOG_RECORD_UID.key, Uuid.getEmbUuid())
4949

embrace-android-core/src/test/java/io/embrace/android/embracesdk/internal/arch/destination/LogWriterImplTest.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ internal class LogWriterImplTest {
6161
with(logger.logs.single()) {
6262
assertEquals("test", body)
6363
assertEquals(Severity.ERROR.name, severityNumber?.name)
64-
assertEquals("fake-session-id", attributes()[SessionIncubatingAttributes.SESSION_ID.key])
65-
assertNotNull(attributes()[embState.name])
66-
assertNotNull(attributes()[LogIncubatingAttributes.LOG_RECORD_UID.key])
67-
assertTrue(attributes()[PrivateSpan.key.name] != null)
64+
assertEquals("fake-session-id", attributes[SessionIncubatingAttributes.SESSION_ID.key])
65+
assertNotNull(attributes[embState.name])
66+
assertNotNull(attributes[LogIncubatingAttributes.LOG_RECORD_UID.key])
67+
assertTrue(attributes[PrivateSpan.key.name] != null)
6868
assertEquals(clock.now().millisToNanos(), timestamp)
6969
assertNull(observedTimestamp)
7070
}
@@ -79,7 +79,7 @@ internal class LogWriterImplTest {
7979
isPrivate = true
8080
)
8181
with(logger.logs.single()) {
82-
assertTrue(attributes()[PrivateSpan.key.name] != null)
82+
assertTrue(attributes[PrivateSpan.key.name] != null)
8383
}
8484
logWriterImpl.addLog(
8585
schemaType = SchemaType.Log(TelemetryAttributes()),
@@ -88,7 +88,7 @@ internal class LogWriterImplTest {
8888
isPrivate = false
8989
)
9090
with(logger.logs.last()) {
91-
assertFalse(attributes()[PrivateSpan.key.name] != null)
91+
assertFalse(attributes[PrivateSpan.key.name] != null)
9292
}
9393
}
9494

@@ -105,9 +105,9 @@ internal class LogWriterImplTest {
105105
with(logger.logs.last()) {
106106
assertEquals(
107107
"foreground-session",
108-
attributes()[SessionIncubatingAttributes.SESSION_ID.key]
108+
attributes[SessionIncubatingAttributes.SESSION_ID.key]
109109
)
110-
assertEquals("foreground", attributes()[embState.name])
110+
assertEquals("foreground", attributes[embState.name])
111111
}
112112
}
113113

@@ -122,8 +122,8 @@ internal class LogWriterImplTest {
122122
)
123123

124124
with(logger.logs.last()) {
125-
assertNull(attributes()[SessionIncubatingAttributes.SESSION_ID.key])
126-
assertEquals("background", attributes()[embState.name])
125+
assertNull(attributes[SessionIncubatingAttributes.SESSION_ID.key])
126+
assertEquals("background", attributes[embState.name])
127127
}
128128
}
129129

@@ -154,8 +154,8 @@ internal class LogWriterImplTest {
154154
)
155155

156156
with(logger.logs.last()) {
157-
assertNull(attributes()[SessionIncubatingAttributes.SESSION_ID.key])
158-
assertNull(attributes()[embState.name])
157+
assertNull(attributes[SessionIncubatingAttributes.SESSION_ID.key])
158+
assertNull(attributes[embState.name])
159159
}
160160
}
161161

@@ -169,8 +169,8 @@ internal class LogWriterImplTest {
169169
)
170170

171171
with(logger.logs.last()) {
172-
assertNull(attributes()[SessionIncubatingAttributes.SESSION_ID.key])
173-
assertEquals("background", attributes()[embState.name])
172+
assertNull(attributes[SessionIncubatingAttributes.SESSION_ID.key])
173+
assertEquals("background", attributes[embState.name])
174174
}
175175
}
176176
}

embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/ndk/NativeCrashDataSourceImplTest.kt

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,19 @@ internal class NativeCrashDataSourceImplTest {
9292
with(otelLogger.logs.single()) {
9393
assertEquals(testNativeCrashData.timestamp, timestamp?.nanosToMillis())
9494
assertNull(observedTimestamp?.nanosToMillis())
95-
assertTrue(attributes()[EmbType.System.NativeCrash.key.name] != null)
96-
assertEquals("value", attributes()["prop".toSessionPropertyAttributeName()])
97-
assertEquals("background", attributes()[embState.name])
98-
assertNotNull(attributes()[LogIncubatingAttributes.LOG_RECORD_UID.key])
99-
assertEquals(testNativeCrashData.sessionId, attributes()[SessionIncubatingAttributes.SESSION_ID.key])
100-
assertEquals("1", attributes()[embCrashNumber.name])
101-
assertEquals(testNativeCrashData.crash, attributes()[embNativeCrashException.name])
95+
assertTrue(attributes[EmbType.System.NativeCrash.key.name] != null)
96+
assertEquals("value", attributes["prop".toSessionPropertyAttributeName()])
97+
assertEquals("background", attributes[embState.name])
98+
assertNotNull(attributes[LogIncubatingAttributes.LOG_RECORD_UID.key])
99+
assertEquals(
100+
testNativeCrashData.sessionId,
101+
attributes[SessionIncubatingAttributes.SESSION_ID.key]
102+
)
103+
assertEquals("1", attributes[embCrashNumber.name])
104+
assertEquals(testNativeCrashData.crash, attributes[embNativeCrashException.name])
102105
assertEquals(
103106
serializer.toJson(testNativeCrashData.symbols, Map::class.java).toByteArray().toUTF8String(),
104-
attributes()[embNativeCrashSymbols.name]
107+
attributes[embNativeCrashSymbols.name]
105108
)
106109
}
107110
}
@@ -121,12 +124,12 @@ internal class NativeCrashDataSourceImplTest {
121124
)
122125

123126
with(otelLogger.logs.single()) {
124-
assertTrue(attributes()[EmbType.System.NativeCrash.key.name] != null)
125-
assertNotNull(attributes()[LogIncubatingAttributes.LOG_RECORD_UID.key])
126-
assertNull(attributes()[SessionIncubatingAttributes.SESSION_ID.key])
127-
assertEquals("1", attributes()[embCrashNumber.name])
128-
assertNull(attributes()[embNativeCrashException.name])
129-
assertNull(attributes()[embNativeCrashSymbols.name])
127+
assertTrue(attributes[EmbType.System.NativeCrash.key.name] != null)
128+
assertNotNull(attributes[LogIncubatingAttributes.LOG_RECORD_UID.key])
129+
assertNull(attributes[SessionIncubatingAttributes.SESSION_ID.key])
130+
assertEquals("1", attributes[embCrashNumber.name])
131+
assertNull(attributes[embNativeCrashException.name])
132+
assertNull(attributes[embNativeCrashSymbols.name])
130133
}
131134
}
132135

@@ -145,13 +148,13 @@ internal class NativeCrashDataSourceImplTest {
145148
)
146149

147150
with(otelLogger.logs.single()) {
148-
assertTrue(attributes()[EmbType.System.NativeCrash.key.name] != null)
149-
assertNotNull(attributes()[LogIncubatingAttributes.LOG_RECORD_UID.key])
150-
assertNull(attributes()[SessionIncubatingAttributes.SESSION_ID.key])
151-
assertEquals("1", attributes()[embCrashNumber.name])
152-
assertNull(attributes()[embState.name])
153-
assertNull(attributes()[embNativeCrashException.name])
154-
assertNull(attributes()[embNativeCrashSymbols.name])
151+
assertTrue(attributes[EmbType.System.NativeCrash.key.name] != null)
152+
assertNotNull(attributes[LogIncubatingAttributes.LOG_RECORD_UID.key])
153+
assertNull(attributes[SessionIncubatingAttributes.SESSION_ID.key])
154+
assertEquals("1", attributes[embCrashNumber.name])
155+
assertNull(attributes[embState.name])
156+
assertNull(attributes[embNativeCrashException.name])
157+
assertNull(attributes[embNativeCrashSymbols.name])
155158
}
156159
}
157160
}

embrace-android-otel/src/main/kotlin/io/embrace/android/embracesdk/internal/otel/impl/EmbInvalidSpan.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ internal class EmbInvalidSpan : Span {
2020
override fun attributes(): Map<String, Any> = emptyMap()
2121

2222
override var name: String = ""
23-
override val parent: SpanContext? = null
23+
override val parent: SpanContext = SpanContextAdapter(OtelJavaSpanContext.getInvalid())
2424
override val spanContext: SpanContext = SpanContextAdapter(OtelJavaSpanContext.getInvalid())
2525
override val spanKind: SpanKind = SpanKind.INTERNAL
2626
override val startTimestamp: Long = 0
2727
override var status: StatusCode = StatusCode.Unset
2828

29-
override fun addEvent(name: String, timestamp: Long?, action: AttributeContainer.() -> Unit) {
29+
override fun addEvent(name: String, timestamp: Long?, attributes: AttributeContainer.() -> Unit) {
3030
}
3131

32-
override fun addLink(spanContext: SpanContext, action: AttributeContainer.() -> Unit) {
32+
override fun addLink(spanContext: SpanContext, attributes: AttributeContainer.() -> Unit) {
3333
}
3434

3535
override fun end() {

embrace-android-otel/src/main/kotlin/io/embrace/android/embracesdk/internal/otel/impl/EmbSpan.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ class EmbSpan(
7373

7474
override fun isRecording(): Boolean = impl.isRecording
7575

76-
override fun addEvent(name: String, timestamp: Long?, action: AttributeContainer.() -> Unit) {
77-
val attrs = EmbAttributeContainer().apply(action).attributes()
76+
override fun addEvent(name: String, timestamp: Long?, attributes: AttributeContainer.() -> Unit) {
77+
val attrs = EmbAttributeContainer().apply(attributes).attributes()
7878
impl.addEvent(name, timestamp, attrs)
7979
}
8080

81-
override fun addLink(spanContext: SpanContext, action: AttributeContainer.() -> Unit) {
82-
val attrs = EmbAttributeContainer().apply(action).attributes()
81+
override fun addLink(spanContext: SpanContext, attributes: AttributeContainer.() -> Unit) {
82+
val attrs = EmbAttributeContainer().apply(attributes).attributes()
8383
impl.addLink(spanContext.convertToOtelJava(), attrs)
8484
}
8585

@@ -93,8 +93,8 @@ class EmbSpan(
9393
impl.updateName(value)
9494
}
9595

96-
override val parent: SpanContext?
97-
get() = impl.parent?.spanContext?.let(::SpanContextAdapter)
96+
override val parent: SpanContext
97+
get() = (impl.parent?.spanContext ?: OtelJavaSpanContext.getInvalid()).let(::SpanContextAdapter)
9898

9999
override val spanKind: SpanKind
100100
get() = impl.spanKind

embrace-android-otel/src/main/kotlin/io/embrace/android/embracesdk/internal/otel/sdk/OtelExt.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private fun OtelJavaEventData.toEmbracePayload(): EmbraceSpanEvent? {
9494
fun ReadableSpan.toEmbracePayload(): EmbraceSpanData = EmbraceSpanData(
9595
traceId = spanContext.traceId,
9696
spanId = spanContext.spanId,
97-
parentSpanId = parent?.spanId,
97+
parentSpanId = parent.spanId,
9898
name = name,
9999
startTimeNanos = startTimestamp,
100100
endTimeNanos = endTimestamp ?: 0,

embrace-test-fakes/src/main/kotlin/io/embrace/android/embracesdk/fakes/FakeKotlinSpan.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import io.embrace.opentelemetry.kotlin.tracing.model.SpanKind
1212
@ExperimentalApi
1313
class FakeKotlinSpan(
1414
override var name: String,
15-
override var parent: SpanContext?,
15+
override var parent: SpanContext,
1616
override val spanKind: SpanKind,
1717
override val startTimestamp: Long,
1818
) : Span {
@@ -25,10 +25,10 @@ class FakeKotlinSpan(
2525

2626
override var status: StatusCode = StatusCode.Unset
2727

28-
override fun addEvent(name: String, timestamp: Long?, action: AttributeContainer.() -> Unit) {
28+
override fun addEvent(name: String, timestamp: Long?, attributes: AttributeContainer.() -> Unit) {
2929
}
3030

31-
override fun addLink(spanContext: SpanContext, action: AttributeContainer.() -> Unit) {
31+
override fun addLink(spanContext: SpanContext, attributes: AttributeContainer.() -> Unit) {
3232
}
3333

3434
override fun end() {

embrace-test-fakes/src/main/kotlin/io/embrace/android/embracesdk/fakes/FakeKotlinTracer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class FakeKotlinTracer : Tracer {
1818
action: SpanRelationships.() -> Unit,
1919
): Span = FakeKotlinSpan(
2020
name,
21-
parent,
21+
parent ?: FakeSpanContext(),
2222
spanKind,
2323
startTimestamp ?: -1,
2424
)
Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
package io.embrace.android.embracesdk.fakes
22

33
import io.embrace.opentelemetry.kotlin.ExperimentalApi
4-
import io.embrace.opentelemetry.kotlin.logging.model.LogRecord
4+
import io.embrace.opentelemetry.kotlin.context.Context
55
import io.embrace.opentelemetry.kotlin.logging.model.SeverityNumber
66

77
@OptIn(ExperimentalApi::class)
88
class FakeLogRecord(
9-
override val observedTimestamp: Long?,
10-
override val severityNumber: SeverityNumber?,
11-
override val timestamp: Long?,
12-
override val body: String?,
13-
override val context: io.embrace.opentelemetry.kotlin.context.Context?,
14-
override val severityText: String?,
15-
private val attrs: Map<String, Any>,
16-
) : LogRecord {
17-
override fun attributes(): Map<String, Any> = attrs
18-
override fun setBooleanAttribute(key: String, value: Boolean) = throw UnsupportedOperationException()
19-
override fun setBooleanListAttribute(key: String, value: List<Boolean>) = throw UnsupportedOperationException()
20-
override fun setDoubleAttribute(key: String, value: Double) = throw UnsupportedOperationException()
21-
override fun setDoubleListAttribute(key: String, value: List<Double>) = throw UnsupportedOperationException()
22-
override fun setLongAttribute(key: String, value: Long) = throw UnsupportedOperationException()
23-
override fun setLongListAttribute(key: String, value: List<Long>) = throw UnsupportedOperationException()
24-
override fun setStringAttribute(key: String, value: String) = throw UnsupportedOperationException()
25-
override fun setStringListAttribute(key: String, value: List<String>) = throw UnsupportedOperationException()
26-
}
9+
val observedTimestamp: Long?,
10+
val severityNumber: SeverityNumber?,
11+
val timestamp: Long?,
12+
val body: String?,
13+
val context: Context?,
14+
val severityText: String?,
15+
val attributes: Map<String, Any>,
16+
)

embrace-test-fakes/src/main/kotlin/io/embrace/android/embracesdk/fakes/FakeOpenTelemetryLogger.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class FakeOpenTelemetryLogger : Logger {
1313

1414
override fun log(
1515
body: String?,
16-
timestampNs: Long?,
17-
observedTimestampNs: Long?,
16+
timestamp: Long?,
17+
observedTimestamp: Long?,
1818
context: Context?,
1919
severityNumber: SeverityNumber?,
2020
severityText: String?,
@@ -25,12 +25,12 @@ class FakeOpenTelemetryLogger : Logger {
2525
logs.add(
2626
FakeLogRecord(
2727
body = body,
28-
timestamp = timestampNs,
29-
observedTimestamp = observedTimestampNs,
28+
timestamp = timestamp,
29+
observedTimestamp = observedTimestamp,
3030
context = context,
3131
severityNumber = severityNumber,
3232
severityText = severityText,
33-
attrs = container.attributes()
33+
attributes = container.attributes()
3434
)
3535
)
3636
}

0 commit comments

Comments
 (0)