Skip to content

Commit c524465

Browse files
committed
RUM-12635: post-review fixes
1 parent 0817c4d commit c524465

File tree

43 files changed

+1500
-946
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1500
-946
lines changed

dd-sdk-android-core/api/apiSurface

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,21 @@ interface com.datadog.android.api.feature.FeatureSdkCore : com.datadog.android.a
147147
interface com.datadog.android.api.feature.StorageBackedFeature : Feature
148148
val requestFactory: com.datadog.android.api.net.RequestFactory
149149
val storageConfiguration: com.datadog.android.api.storage.FeatureStorageConfiguration
150-
interface com.datadog.android.api.instrumentation.network.RequestInfo
150+
interface com.datadog.android.api.instrumentation.network.ExtendedRequestInfo
151+
fun <T> tag(Class<T>): T?
152+
fun <T> HttpRequestInfo.tag(Class<T>): T?
153+
interface com.datadog.android.api.instrumentation.network.HttpRequestInfo
151154
val url: String
152155
val headers: Map<String, List<String>>
153156
val contentType: String?
154157
val method: String
155-
fun <T> tag(Class<T>): T?
156158
fun contentLength(): Long?
157-
interface com.datadog.android.api.instrumentation.network.ResponseInfo
159+
interface com.datadog.android.api.instrumentation.network.HttpResponseInfo
158160
val url: String
159161
val statusCode: Int
160162
val headers: Map<String, List<String>>
161163
val contentType: String?
162-
fun computeContentLength(com.datadog.android.api.InternalLogger): Long?
164+
val contentLength: Long?
163165
data class com.datadog.android.api.net.Request
164166
constructor(String, String, String, Map<String, String>, ByteArray, String? = null)
165167
data class com.datadog.android.api.net.RequestExecutionContext

dd-sdk-android-core/api/dd-sdk-android-core.api

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,17 +443,24 @@ public abstract interface class com/datadog/android/api/feature/StorageBackedFea
443443
public abstract fun getStorageConfiguration ()Lcom/datadog/android/api/storage/FeatureStorageConfiguration;
444444
}
445445

446-
public abstract interface class com/datadog/android/api/instrumentation/network/RequestInfo {
446+
public abstract interface class com/datadog/android/api/instrumentation/network/ExtendedRequestInfo {
447+
public abstract fun tag (Ljava/lang/Class;)Ljava/lang/Object;
448+
}
449+
450+
public final class com/datadog/android/api/instrumentation/network/ExtendedRequestInfoKt {
451+
public static final fun tag (Lcom/datadog/android/api/instrumentation/network/HttpRequestInfo;Ljava/lang/Class;)Ljava/lang/Object;
452+
}
453+
454+
public abstract interface class com/datadog/android/api/instrumentation/network/HttpRequestInfo {
447455
public abstract fun contentLength ()Ljava/lang/Long;
448456
public abstract fun getContentType ()Ljava/lang/String;
449457
public abstract fun getHeaders ()Ljava/util/Map;
450458
public abstract fun getMethod ()Ljava/lang/String;
451459
public abstract fun getUrl ()Ljava/lang/String;
452-
public abstract fun tag (Ljava/lang/Class;)Ljava/lang/Object;
453460
}
454461

455-
public abstract interface class com/datadog/android/api/instrumentation/network/ResponseInfo {
456-
public abstract fun computeContentLength (Lcom/datadog/android/api/InternalLogger;)Ljava/lang/Long;
462+
public abstract interface class com/datadog/android/api/instrumentation/network/HttpResponseInfo {
463+
public abstract fun getContentLength ()Ljava/lang/Long;
457464
public abstract fun getContentType ()Ljava/lang/String;
458465
public abstract fun getHeaders ()Ljava/util/Map;
459466
public abstract fun getStatusCode ()I
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2016-Present Datadog, Inc.
5+
*/
6+
package com.datadog.android.api.instrumentation.network
7+
8+
/**
9+
* This interface indicates that the request supports non HTTP-specified methods.
10+
*/
11+
interface ExtendedRequestInfo {
12+
13+
/**
14+
* Returns the tag attached with type as a key, or null if no tag is attached with that key.
15+
*/
16+
fun <T> tag(type: Class<out T>): T?
17+
}
18+
19+
/**
20+
* Returns the tag attached with type as a key, or null if no tag is attached with that key.
21+
*/
22+
fun <T> HttpRequestInfo.tag(type: Class<out T>): T? = if (this is ExtendedRequestInfo) this.tag(type) else null

dd-sdk-android-core/src/main/kotlin/com/datadog/android/api/instrumentation/network/RequestInfo.kt renamed to dd-sdk-android-core/src/main/kotlin/com/datadog/android/api/instrumentation/network/HttpRequestInfo.kt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
*/
66
package com.datadog.android.api.instrumentation.network
77

8-
import java.io.IOException
9-
108
/**
119
* Represents information about an HTTP request.
12-
* Isolates specific library's details from the Datadog SDK.
1310
*/
14-
interface RequestInfo {
11+
interface HttpRequestInfo {
1512
/**
1613
* The URL associated with the HTTP request.
1714
*/
@@ -25,8 +22,6 @@ interface RequestInfo {
2522
/**
2623
* The MIME type of the payload associated with the HTTP request or response, represented
2724
* as a string. Can be null if the content type is unspecified.
28-
*
29-
* The existence of this value depends on the specific implementation and may be null.
3025
*/
3126
val contentType: String?
3227

@@ -35,17 +30,10 @@ interface RequestInfo {
3530
*/
3631
val method: String
3732

38-
/**
39-
* Returns the tag attached with type as a key, or null if no tag is attached with that key.
40-
*/
41-
fun <T> tag(type: Class<out T>): T?
42-
4333
/**
4434
* Retrieves the content length of the HTTP request.
4535
*
4636
* @return the length of the content in bytes, or null if the content length is unavailable.
47-
* @throws IOException if an error occurs while calculating the content length.
4837
*/
49-
@Throws(IOException::class)
5038
fun contentLength(): Long?
5139
}

dd-sdk-android-core/src/main/kotlin/com/datadog/android/api/instrumentation/network/ResponseInfo.kt renamed to dd-sdk-android-core/src/main/kotlin/com/datadog/android/api/instrumentation/network/HttpResponseInfo.kt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
*/
66
package com.datadog.android.api.instrumentation.network
77

8-
import com.datadog.android.api.InternalLogger
9-
108
/**
119
* Represents information about an HTTP response.
12-
* Isolates specific library's details from the Datadog SDK.
1310
*/
14-
interface ResponseInfo {
11+
interface HttpResponseInfo {
1512
/**
1613
* Represents the URL associated with an HTTP response.
1714
*/
@@ -29,16 +26,13 @@ interface ResponseInfo {
2926

3027
/**
3128
* Represents the MIME type of the payload associated with an HTTP response.
32-
*
33-
* The existence of this value depends on the specific implementation and may be null.
3429
*/
3530
val contentType: String?
3631

3732
/**
38-
* Calculates and retrieves the content length from the response information.
33+
* Retrieves the content length from the response information.
3934
*
40-
* @param internalLogger the logger used for reporting internal messages or errors during computation.
4135
* @return the content length as a Long if available, or null if it cannot be determined.
4236
*/
43-
fun computeContentLength(internalLogger: InternalLogger): Long?
37+
val contentLength: Long?
4438
}

dd-sdk-android-core/src/testFixtures/kotlin/com/datadog/android/api/instrumentation/network/RequestInfoAssert.kt

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,42 @@
77
package com.datadog.android.api.instrumentation.network
88

99
import org.assertj.core.api.AbstractObjectAssert
10-
import org.assertj.core.api.Assertions
10+
import org.assertj.core.api.Assertions.assertThat
1111

12-
class RequestInfoAssert private constructor(actual: RequestInfo) :
13-
AbstractObjectAssert<RequestInfoAssert, RequestInfo>(actual, RequestInfoAssert::class.java) {
12+
class RequestInfoAssert private constructor(actual: HttpRequestInfo) :
13+
AbstractObjectAssert<RequestInfoAssert, HttpRequestInfo>(actual, RequestInfoAssert::class.java) {
1414

1515
fun hasUrl(url: String) = apply {
16-
Assertions.assertThat(actual.url).isEqualTo(url)
16+
assertThat(actual.url)
17+
.overridingErrorMessage("Expected URL $url but was ${actual.url}")
18+
.isEqualTo(url)
1719
}
1820

1921
fun hasMethod(method: String) = apply {
20-
Assertions.assertThat(actual.method).isEqualTo(method)
22+
assertThat(actual.method)
23+
.overridingErrorMessage("Expected method $method but was ${actual.method}")
24+
.isEqualTo(method)
2125
}
2226

2327
fun hasHeader(key: String, value: String) = apply {
24-
Assertions.assertThat(actual.headers.getValue(key).first()).isEqualTo(value)
28+
assertThat(actual.headers.getValue(key))
29+
.overridingErrorMessage("Expected header $key=$value but was ${actual.headers}")
30+
.isEqualTo(listOf(value))
2531
}
2632

2733
fun hasContentType(contentType: String) = apply {
28-
Assertions.assertThat(actual.contentType).isEqualTo(contentType)
34+
assertThat(actual.contentType)
35+
.overridingErrorMessage("Expected content type $contentType but was ${actual.contentType}")
36+
.isEqualTo(contentType)
2937
}
3038

3139
fun <T> hasTag(type: Class<T>, tag: T) = apply {
32-
Assertions.assertThat(actual.tag(type)).isEqualTo(tag)
40+
assertThat(actual.tag(type))
41+
.overridingErrorMessage("Expected tag $tag but was ${actual.tag(type)}")
42+
.isEqualTo(tag)
3343
}
3444

3545
companion object Companion {
36-
fun assertThat(info: RequestInfo) = RequestInfoAssert(info)
46+
fun assertThat(info: HttpRequestInfo) = RequestInfoAssert(info)
3747
}
3848
}

dd-sdk-android-core/src/testFixtures/kotlin/com/datadog/android/tests/elmyr/RequestInfoForgeryFactory.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66

77
package com.datadog.android.tests.elmyr
88

9-
import com.datadog.android.api.instrumentation.network.RequestInfo
9+
import com.datadog.android.api.instrumentation.network.ExtendedRequestInfo
10+
import com.datadog.android.api.instrumentation.network.HttpRequestInfo
1011
import com.datadog.android.core.internal.net.HttpSpec
1112
import fr.xgouchet.elmyr.Forge
1213
import fr.xgouchet.elmyr.ForgeryFactory
1314

14-
class RequestInfoForgeryFactory : ForgeryFactory<RequestInfo> {
15-
override fun getForgery(forge: Forge): RequestInfo {
15+
class RequestInfoForgeryFactory : ForgeryFactory<HttpRequestInfo> {
16+
override fun getForgery(forge: Forge): HttpRequestInfo {
1617
return StubRequestInfo(
1718
url = forge.aStringMatching("https://[a-z0-9]+\\.com"),
1819
headers = forge.aMap { aString() to aList { aString() } },
@@ -30,7 +31,7 @@ class RequestInfoForgeryFactory : ForgeryFactory<RequestInfo> {
3031
override val method: String,
3132
private val contentLength: Long?,
3233
private val tags: Map<Any, Any?>
33-
) : RequestInfo {
34+
) : HttpRequestInfo, ExtendedRequestInfo {
3435

3536
@Suppress("UNCHECKED_CAST")
3637
override fun <T> tag(type: Class<out T>): T? = tags[type] as? T

features/dd-sdk-android-rum/api/apiSurface

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ enum com.datadog.android.rum.RumPerformanceMetric
130130
- JS_FRAME_TIME
131131
interface com.datadog.android.rum.RumResourceAttributesProvider
132132
DEPRECATED fun onProvideAttributes(okhttp3.Request, okhttp3.Response?, Throwable?): Map<String, Any?>
133-
fun onProvideAttributes(com.datadog.android.api.instrumentation.network.RequestInfo, com.datadog.android.api.instrumentation.network.ResponseInfo?, Throwable?): Map<String, Any?>
133+
fun onProvideAttributes(com.datadog.android.api.instrumentation.network.HttpRequestInfo, com.datadog.android.api.instrumentation.network.HttpResponseInfo?, Throwable?): Map<String, Any?>
134134
enum com.datadog.android.rum.RumResourceKind
135135
constructor(String)
136136
- BEACON
@@ -204,13 +204,14 @@ interface com.datadog.android.rum.internal.monitor.AdvancedNetworkRumMonitor : c
204204
fun stopResourceWithError(com.datadog.android.rum.resource.ResourceId, Int?, String, com.datadog.android.rum.RumErrorSource, String, String?, Map<String, Any?> = emptyMap())
205205
class com.datadog.android.rum.internal.net.RumResourceInstrumentation
206206
constructor(String?, String, com.datadog.android.rum.RumResourceAttributesProvider)
207-
fun sendWaitForResourceTimingEvent(com.datadog.android.api.instrumentation.network.RequestInfo)
208-
fun sendTiming(com.datadog.android.api.instrumentation.network.RequestInfo, com.datadog.android.rum.internal.domain.event.ResourceTiming)
209-
fun startResource(com.datadog.android.api.instrumentation.network.RequestInfo)
210-
fun stopResource(com.datadog.android.api.instrumentation.network.RequestInfo, com.datadog.android.api.instrumentation.network.ResponseInfo)
211-
fun stopResourceWithError(com.datadog.android.api.instrumentation.network.RequestInfo, Throwable)
207+
fun sendWaitForResourceTimingEvent(com.datadog.android.api.instrumentation.network.HttpRequestInfo)
208+
fun sendTiming(com.datadog.android.api.instrumentation.network.HttpRequestInfo, com.datadog.android.rum.internal.domain.event.ResourceTiming)
209+
fun startResource(com.datadog.android.api.instrumentation.network.HttpRequestInfo)
210+
fun stopResource(com.datadog.android.api.instrumentation.network.HttpRequestInfo, com.datadog.android.api.instrumentation.network.HttpResponseInfo)
211+
fun stopResourceWithError(com.datadog.android.api.instrumentation.network.HttpRequestInfo, Throwable)
212212
fun reportInstrumentationError(String)
213213
companion object
214+
fun buildResourceId(com.datadog.android.api.instrumentation.network.HttpRequestInfo, Boolean): com.datadog.android.rum.resource.ResourceId
214215
interface com.datadog.android.rum.metric.interactiontonextview.LastInteractionIdentifier
215216
fun validate(PreviousViewLastInteractionContext): Boolean
216217
data class com.datadog.android.rum.metric.interactiontonextview.PreviousViewLastInteractionContext
@@ -234,8 +235,6 @@ class com.datadog.android.rum.metric.networksettled.TimeBasedInitialResourceIden
234235
fun android.content.Context.getAssetAsRumResource(String, Int = AssetManager.ACCESS_STREAMING, com.datadog.android.api.SdkCore = Datadog.getInstance()): java.io.InputStream
235236
fun android.content.Context.getRawResAsRumResource(Int, com.datadog.android.api.SdkCore = Datadog.getInstance()): java.io.InputStream
236237
fun java.io.InputStream.asRumResource(String, com.datadog.android.api.SdkCore = Datadog.getInstance()): java.io.InputStream
237-
fun com.datadog.android.api.instrumentation.network.RequestInfo.buildResourceId(Boolean): ResourceId
238-
fun identifyRequest(com.datadog.android.api.instrumentation.network.RequestInfo): String
239238
class com.datadog.android.rum.resource.ResourceId
240239
constructor(String, String?)
241240
override fun equals(Any?): Boolean

features/dd-sdk-android-rum/api/dd-sdk-android-rum.api

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public final class com/datadog/android/rum/GlobalRumMonitor {
1818

1919
public final class com/datadog/android/rum/NoOpRumResourceAttributesProvider : com/datadog/android/rum/RumResourceAttributesProvider {
2020
public fun <init> ()V
21-
public fun onProvideAttributes (Lcom/datadog/android/api/instrumentation/network/RequestInfo;Lcom/datadog/android/api/instrumentation/network/ResponseInfo;Ljava/lang/Throwable;)Ljava/util/Map;
21+
public fun onProvideAttributes (Lcom/datadog/android/api/instrumentation/network/HttpRequestInfo;Lcom/datadog/android/api/instrumentation/network/HttpResponseInfo;Ljava/lang/Throwable;)Ljava/util/Map;
2222
public fun onProvideAttributes (Lokhttp3/Request;Lokhttp3/Response;Ljava/lang/Throwable;)Ljava/util/Map;
2323
}
2424

@@ -202,12 +202,12 @@ public final class com/datadog/android/rum/RumPerformanceMetric : java/lang/Enum
202202
}
203203

204204
public abstract interface class com/datadog/android/rum/RumResourceAttributesProvider {
205-
public abstract fun onProvideAttributes (Lcom/datadog/android/api/instrumentation/network/RequestInfo;Lcom/datadog/android/api/instrumentation/network/ResponseInfo;Ljava/lang/Throwable;)Ljava/util/Map;
205+
public abstract fun onProvideAttributes (Lcom/datadog/android/api/instrumentation/network/HttpRequestInfo;Lcom/datadog/android/api/instrumentation/network/HttpResponseInfo;Ljava/lang/Throwable;)Ljava/util/Map;
206206
public abstract fun onProvideAttributes (Lokhttp3/Request;Lokhttp3/Response;Ljava/lang/Throwable;)Ljava/util/Map;
207207
}
208208

209209
public final class com/datadog/android/rum/RumResourceAttributesProvider$DefaultImpls {
210-
public static fun onProvideAttributes (Lcom/datadog/android/rum/RumResourceAttributesProvider;Lcom/datadog/android/api/instrumentation/network/RequestInfo;Lcom/datadog/android/api/instrumentation/network/ResponseInfo;Ljava/lang/Throwable;)Ljava/util/Map;
210+
public static fun onProvideAttributes (Lcom/datadog/android/rum/RumResourceAttributesProvider;Lcom/datadog/android/api/instrumentation/network/HttpRequestInfo;Lcom/datadog/android/api/instrumentation/network/HttpResponseInfo;Ljava/lang/Throwable;)Ljava/util/Map;
211211
}
212212

213213
public final class com/datadog/android/rum/RumResourceKind : java/lang/Enum {
@@ -400,14 +400,15 @@ public final class com/datadog/android/rum/internal/net/RumResourceInstrumentati
400400
public static final field Companion Lcom/datadog/android/rum/internal/net/RumResourceInstrumentation$Companion;
401401
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lcom/datadog/android/rum/RumResourceAttributesProvider;)V
402402
public final fun reportInstrumentationError (Ljava/lang/String;)V
403-
public final fun sendTiming (Lcom/datadog/android/api/instrumentation/network/RequestInfo;Lcom/datadog/android/rum/internal/domain/event/ResourceTiming;)V
404-
public final fun sendWaitForResourceTimingEvent (Lcom/datadog/android/api/instrumentation/network/RequestInfo;)V
405-
public final fun startResource (Lcom/datadog/android/api/instrumentation/network/RequestInfo;)V
406-
public final fun stopResource (Lcom/datadog/android/api/instrumentation/network/RequestInfo;Lcom/datadog/android/api/instrumentation/network/ResponseInfo;)V
407-
public final fun stopResourceWithError (Lcom/datadog/android/api/instrumentation/network/RequestInfo;Ljava/lang/Throwable;)V
403+
public final fun sendTiming (Lcom/datadog/android/api/instrumentation/network/HttpRequestInfo;Lcom/datadog/android/rum/internal/domain/event/ResourceTiming;)V
404+
public final fun sendWaitForResourceTimingEvent (Lcom/datadog/android/api/instrumentation/network/HttpRequestInfo;)V
405+
public final fun startResource (Lcom/datadog/android/api/instrumentation/network/HttpRequestInfo;)V
406+
public final fun stopResource (Lcom/datadog/android/api/instrumentation/network/HttpRequestInfo;Lcom/datadog/android/api/instrumentation/network/HttpResponseInfo;)V
407+
public final fun stopResourceWithError (Lcom/datadog/android/api/instrumentation/network/HttpRequestInfo;Ljava/lang/Throwable;)V
408408
}
409409

410410
public final class com/datadog/android/rum/internal/net/RumResourceInstrumentation$Companion {
411+
public final fun buildResourceId (Lcom/datadog/android/api/instrumentation/network/HttpRequestInfo;Z)Lcom/datadog/android/rum/resource/ResourceId;
411412
}
412413

413414
public abstract interface class com/datadog/android/rum/metric/interactiontonextview/LastInteractionIdentifier {
@@ -7767,11 +7768,6 @@ public final class com/datadog/android/rum/resource/InputStreamExtKt {
77677768
public static synthetic fun asRumResource$default (Ljava/io/InputStream;Ljava/lang/String;Lcom/datadog/android/api/SdkCore;ILjava/lang/Object;)Ljava/io/InputStream;
77687769
}
77697770

7770-
public final class com/datadog/android/rum/resource/RequestExtKt {
7771-
public static final fun buildResourceId (Lcom/datadog/android/api/instrumentation/network/RequestInfo;Z)Lcom/datadog/android/rum/resource/ResourceId;
7772-
public static final fun identifyRequest (Lcom/datadog/android/api/instrumentation/network/RequestInfo;)Ljava/lang/String;
7773-
}
7774-
77757771
public final class com/datadog/android/rum/resource/ResourceId {
77767772
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
77777773
public fun equals (Ljava/lang/Object;)Z

0 commit comments

Comments
 (0)