Skip to content

Commit 93ec993

Browse files
authored
Merge pull request #207004 from griffinbird/cdb-cassandra-api-1
Updated to find the request charge using GOCQL client
2 parents ecc815e + 97f51c9 commit 93ec993

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

articles/cosmos-db/cassandra/find-request-unit-charge-cassandra.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ ms.service: cosmos-db
77
ms.subservice: cosmosdb-cassandra
88
ms.topic: how-to
99
ms.date: 10/14/2020
10-
ms.devlang: csharp, java
11-
ms.custom: devx-track-csharp, devx-track-java
10+
ms.devlang: csharp, java, golang
11+
ms.custom: devx-track-csharp, devx-track-java, devx-track-golang
1212
---
1313
# Find the request unit charge for operations executed in Azure Cosmos DB Cassandra API
1414
[!INCLUDE[appliesto-cassandra-api](../includes/appliesto-cassandra-api.md)]
@@ -21,7 +21,9 @@ This article presents the different ways you can find the [request unit](../requ
2121

2222
When you perform operations against the Azure Cosmos DB Cassandra API, the RU charge is returned in the incoming payload as a field named `RequestCharge`. You have multiple options for retrieving the RU charge.
2323

24-
## Use the .NET SDK
24+
## Use a Cassandra Driver
25+
26+
### [.NET Driver](#tab/dotnet-driver)
2527

2628
When you use the [.NET SDK](https://www.nuget.org/packages/CassandraCSharpDriver/), you can retrieve the incoming payload under the `Info` property of a `RowSet` object:
2729

@@ -32,7 +34,7 @@ double requestCharge = BitConverter.ToDouble(rowSet.Info.IncomingPayload["Reques
3234

3335
For more information, see [Quickstart: Build a Cassandra app by using the .NET SDK and Azure Cosmos DB](manage-data-dotnet.md).
3436

35-
## Use the Java SDK
37+
### [Java Driver](#tab/java-driver)
3638

3739
When you use the [Java SDK](https://mvnrepository.com/artifact/com.datastax.cassandra/cassandra-driver-core), you can retrieve the incoming payload by calling the `getExecutionInfo()` method on a `ResultSet` object:
3840

@@ -43,6 +45,22 @@ Double requestCharge = resultSet.getExecutionInfo().getIncomingPayload().get("Re
4345

4446
For more information, see [Quickstart: Build a Cassandra app by using the Java SDK and Azure Cosmos DB](manage-data-java.md).
4547

48+
### [GOCQL Driver](#tab/gocql-driver)
49+
50+
When you use the [GOCQL driver](https://github.com/gocql/gocql), you can retrieve the incoming payload by calling the `GetCustomPayload()` method on a [`Iter`](https://pkg.go.dev/github.com/gocql/gocql#Iter) type:
51+
52+
```go
53+
query := session.Query(fmt.Sprintf("SELECT * FROM <keyspace.table> where <value> = ?", keyspace, table)).Bind(<value>)
54+
iter := query.Iter()
55+
requestCharge := iter.GetCustomPayload()["RequestCharge"]
56+
requestChargeBits := binary.BigEndian.Uint64(requestCharge)
57+
requestChargeValue := math.Float64frombits(requestChargeBits)
58+
fmt.Printf("%v\n", requestChargeValue)
59+
```
60+
61+
For more information, see [Quickstart: Build a Cassandra app by using GOCQL and Azure Cosmos DB](manage-data-go.md).
62+
63+
---
4664
## Next steps
4765

4866
To learn about optimizing your RU consumption, see these articles:

0 commit comments

Comments
 (0)