Skip to content

Commit

Permalink
Merge pull request #1826 from DataDog/nogorodnikov/rum-1308/add-more-…
Browse files Browse the repository at this point in the history
…http-methods-to-rum

RUM-1308: Add more HTTP methods to RUM
  • Loading branch information
0xnm authored Jan 17, 2024
2 parents 1e97c29 + 2284a01 commit 8c57aad
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 15 deletions.
9 changes: 9 additions & 0 deletions features/dd-sdk-android-rum/api/apiSurface
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ enum com.datadog.android.rum.RumResourceMethod
- PUT
- DELETE
- PATCH
- TRACE
- OPTIONS
- CONNECT
interface com.datadog.android.rum.RumSessionListener
fun onSessionStarted(String, Boolean)
class com.datadog.android.rum._RumInternalProxy
Expand Down Expand Up @@ -775,6 +778,9 @@ data class com.datadog.android.rum.model.ErrorEvent
- PUT
- DELETE
- PATCH
- TRACE
- OPTIONS
- CONNECT
fun toJson(): com.google.gson.JsonElement
companion object
fun fromJson(kotlin.String): Method
Expand Down Expand Up @@ -1261,6 +1267,9 @@ data class com.datadog.android.rum.model.ResourceEvent
- PUT
- DELETE
- PATCH
- TRACE
- OPTIONS
- CONNECT
fun toJson(): com.google.gson.JsonElement
companion object
fun fromJson(kotlin.String): Method
Expand Down
9 changes: 9 additions & 0 deletions features/dd-sdk-android-rum/api/dd-sdk-android-rum.api
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,15 @@ public final class com/datadog/android/rum/RumResourceKind$Companion {
}

public final class com/datadog/android/rum/RumResourceMethod : java/lang/Enum {
public static final field CONNECT Lcom/datadog/android/rum/RumResourceMethod;
public static final field DELETE Lcom/datadog/android/rum/RumResourceMethod;
public static final field GET Lcom/datadog/android/rum/RumResourceMethod;
public static final field HEAD Lcom/datadog/android/rum/RumResourceMethod;
public static final field OPTIONS Lcom/datadog/android/rum/RumResourceMethod;
public static final field PATCH Lcom/datadog/android/rum/RumResourceMethod;
public static final field POST Lcom/datadog/android/rum/RumResourceMethod;
public static final field PUT Lcom/datadog/android/rum/RumResourceMethod;
public static final field TRACE Lcom/datadog/android/rum/RumResourceMethod;
public static fun valueOf (Ljava/lang/String;)Lcom/datadog/android/rum/RumResourceMethod;
public static fun values ()[Lcom/datadog/android/rum/RumResourceMethod;
}
Expand Down Expand Up @@ -1715,13 +1718,16 @@ public final class com/datadog/android/rum/model/ErrorEvent$Interface$Companion
}

public final class com/datadog/android/rum/model/ErrorEvent$Method : java/lang/Enum {
public static final field CONNECT Lcom/datadog/android/rum/model/ErrorEvent$Method;
public static final field Companion Lcom/datadog/android/rum/model/ErrorEvent$Method$Companion;
public static final field DELETE Lcom/datadog/android/rum/model/ErrorEvent$Method;
public static final field GET Lcom/datadog/android/rum/model/ErrorEvent$Method;
public static final field HEAD Lcom/datadog/android/rum/model/ErrorEvent$Method;
public static final field OPTIONS Lcom/datadog/android/rum/model/ErrorEvent$Method;
public static final field PATCH Lcom/datadog/android/rum/model/ErrorEvent$Method;
public static final field POST Lcom/datadog/android/rum/model/ErrorEvent$Method;
public static final field PUT Lcom/datadog/android/rum/model/ErrorEvent$Method;
public static final field TRACE Lcom/datadog/android/rum/model/ErrorEvent$Method;
public static final fun fromJson (Ljava/lang/String;)Lcom/datadog/android/rum/model/ErrorEvent$Method;
public final fun toJson ()Lcom/google/gson/JsonElement;
public static fun valueOf (Ljava/lang/String;)Lcom/datadog/android/rum/model/ErrorEvent$Method;
Expand Down Expand Up @@ -3221,13 +3227,16 @@ public final class com/datadog/android/rum/model/ResourceEvent$Interface$Compani
}

public final class com/datadog/android/rum/model/ResourceEvent$Method : java/lang/Enum {
public static final field CONNECT Lcom/datadog/android/rum/model/ResourceEvent$Method;
public static final field Companion Lcom/datadog/android/rum/model/ResourceEvent$Method$Companion;
public static final field DELETE Lcom/datadog/android/rum/model/ResourceEvent$Method;
public static final field GET Lcom/datadog/android/rum/model/ResourceEvent$Method;
public static final field HEAD Lcom/datadog/android/rum/model/ResourceEvent$Method;
public static final field OPTIONS Lcom/datadog/android/rum/model/ResourceEvent$Method;
public static final field PATCH Lcom/datadog/android/rum/model/ResourceEvent$Method;
public static final field POST Lcom/datadog/android/rum/model/ResourceEvent$Method;
public static final field PUT Lcom/datadog/android/rum/model/ResourceEvent$Method;
public static final field TRACE Lcom/datadog/android/rum/model/ResourceEvent$Method;
public static final fun fromJson (Ljava/lang/String;)Lcom/datadog/android/rum/model/ResourceEvent$Method;
public final fun toJson ()Lcom/google/gson/JsonElement;
public static fun valueOf (Ljava/lang/String;)Lcom/datadog/android/rum/model/ResourceEvent$Method;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"method": {
"type": "string",
"description": "HTTP method of the resource",
"enum": ["POST", "GET", "HEAD", "PUT", "DELETE", "PATCH"],
"enum": ["POST", "GET", "HEAD", "PUT", "DELETE", "PATCH", "TRACE", "OPTIONS", "CONNECT"],
"readOnly": true
},
"status_code": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"method": {
"type": "string",
"description": "HTTP method of the resource",
"enum": ["POST", "GET", "HEAD", "PUT", "DELETE", "PATCH"],
"enum": ["POST", "GET", "HEAD", "PUT", "DELETE", "PATCH", "TRACE", "OPTIONS", "CONNECT"],
"readOnly": true
},
"url": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,20 @@ enum class RumResourceMethod {
/**
* PATCH Method.
*/
PATCH
PATCH,

/**
* TRACE Method.
*/
TRACE,

/**
* OPTIONS Method.
*/
OPTIONS,

/**
* CONNECT Method.
*/
CONNECT
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ internal fun RumResourceMethod.toResourceMethod(): ResourceEvent.Method {
RumResourceMethod.PUT -> ResourceEvent.Method.PUT
RumResourceMethod.DELETE -> ResourceEvent.Method.DELETE
RumResourceMethod.PATCH -> ResourceEvent.Method.PATCH
RumResourceMethod.TRACE -> ResourceEvent.Method.TRACE
RumResourceMethod.OPTIONS -> ResourceEvent.Method.OPTIONS
RumResourceMethod.CONNECT -> ResourceEvent.Method.CONNECT
}
}

Expand All @@ -44,6 +47,9 @@ internal fun RumResourceMethod.toErrorMethod(): ErrorEvent.Method {
RumResourceMethod.PUT -> ErrorEvent.Method.PUT
RumResourceMethod.DELETE -> ErrorEvent.Method.DELETE
RumResourceMethod.PATCH -> ErrorEvent.Method.PATCH
RumResourceMethod.TRACE -> ErrorEvent.Method.TRACE
RumResourceMethod.OPTIONS -> ErrorEvent.Method.OPTIONS
RumResourceMethod.CONNECT -> ErrorEvent.Method.CONNECT
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ internal class DatadogRumMonitor(
"PUT" -> RumResourceMethod.PUT
"DELETE" -> RumResourceMethod.DELETE
"PATCH" -> RumResourceMethod.PATCH
"CONNECT" -> RumResourceMethod.CONNECT
"TRACE" -> RumResourceMethod.TRACE
"OPTIONS" -> RumResourceMethod.OPTIONS
else -> {
sdkCore.internalLogger.log(
InternalLogger.Level.WARN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,10 @@ internal class DatadogRumMonitorTest {
"pUt",
"HeAd",
"DeLeTe",
"pAtCh"
"pAtCh",
"cOnnEct",
"TrAcE",
"oPtIoNs"
)
@Suppress("DEPRECATION")
testedMonitor.startResource(key, method, url, fakeAttributes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ internal constructor(
"HEAD" -> RumResourceMethod.HEAD
"DELETE" -> RumResourceMethod.DELETE
"POST" -> RumResourceMethod.POST
"TRACE" -> RumResourceMethod.TRACE
"OPTIONS" -> RumResourceMethod.OPTIONS
"CONNECT" -> RumResourceMethod.CONNECT
else -> {
internalLogger.log(
InternalLogger.Level.WARN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,10 @@ internal class DatadogInterceptorWithoutTracesTest {
fakeMethod = forge.anElementFrom(
RumResourceMethod.GET,
RumResourceMethod.HEAD,
RumResourceMethod.DELETE
RumResourceMethod.DELETE,
RumResourceMethod.CONNECT,
RumResourceMethod.TRACE,
RumResourceMethod.OPTIONS
)
fakeBody = null
builder.method(fakeMethod.name, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1274,11 +1274,21 @@ internal open class TracingInterceptorNonDdTracerNotSendingSpanTest {
): Request {
val builder = Request.Builder().url(fakeUrl)
if (forge.aBool()) {
fakeMethod = "POST"
fakeMethod = forge.anElementFrom("POST", "PUT", "PATCH")
fakeBody = forge.anAlphabeticalString()
builder.post(fakeBody!!.toByteArray().toRequestBody(null))
with(builder) {
val body = fakeBody!!.toByteArray().toRequestBody(null)
when (fakeMethod) {
"POST" -> post(body)
"PUT" -> put(body)
"PATCH" -> patch(body)
else -> {
throw IllegalArgumentException("Unknown method value: $fakeMethod")
}
}
}
} else {
fakeMethod = forge.anElementFrom("GET", "HEAD", "DELETE")
fakeMethod = forge.anElementFrom("GET", "HEAD", "DELETE", "CONNECT", "TRACE", "OPTIONS")
fakeBody = null
builder.method(fakeMethod, null)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1391,11 +1391,21 @@ internal open class TracingInterceptorNonDdTracerTest {
): Request {
val builder = Request.Builder().url(url)
if (forge.aBool()) {
fakeMethod = "POST"
fakeMethod = forge.anElementFrom("POST", "PUT", "PATCH")
fakeBody = forge.anAlphabeticalString()
builder.post(fakeBody!!.toByteArray().toRequestBody(null))
with(builder) {
val body = fakeBody!!.toByteArray().toRequestBody(null)
when (fakeMethod) {
"POST" -> post(body)
"PUT" -> put(body)
"PATCH" -> patch(body)
else -> {
throw IllegalArgumentException("Unknown method value: $fakeMethod")
}
}
}
} else {
fakeMethod = forge.anElementFrom("GET", "HEAD", "DELETE")
fakeMethod = forge.anElementFrom("GET", "HEAD", "DELETE", "CONNECT", "TRACE", "OPTIONS")
fakeBody = null
builder.method(fakeMethod, null)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,10 @@ internal open class TracingInterceptorNotSendingSpanTest {
fakeMethod = forge.anElementFrom(
RumResourceMethod.GET,
RumResourceMethod.HEAD,
RumResourceMethod.DELETE
RumResourceMethod.DELETE,
RumResourceMethod.CONNECT,
RumResourceMethod.TRACE,
RumResourceMethod.OPTIONS
)
fakeBody = null
builder.method(fakeMethod.name, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1523,11 +1523,21 @@ internal open class TracingInterceptorTest {
): Request {
val builder = Request.Builder().url(url)
if (forge.aBool()) {
fakeMethod = "POST"
fakeMethod = forge.anElementFrom("POST", "PUT", "PATCH")
fakeBody = forge.anAlphabeticalString()
builder.post(fakeBody!!.toByteArray().toRequestBody(null))
with(builder) {
val body = fakeBody!!.toByteArray().toRequestBody(null)
when (fakeMethod) {
"POST" -> post(body)
"PUT" -> put(body)
"PATCH" -> patch(body)
else -> {
throw IllegalArgumentException("Unknown method value: $fakeMethod")
}
}
}
} else {
fakeMethod = forge.anElementFrom("GET", "HEAD", "DELETE")
fakeMethod = forge.anElementFrom("GET", "HEAD", "DELETE", "CONNECT", "TRACE", "OPTIONS")
fakeBody = null
builder.method(fakeMethod, null)
}
Expand Down

0 comments on commit 8c57aad

Please sign in to comment.