-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
couple of fixes following advice from andrea
- mutualize method between client and streams - fix code that would not have been inlined - add class cast check just to be sure
- Loading branch information
Showing
4 changed files
with
32 additions
and
35 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
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
19 changes: 19 additions & 0 deletions
19
...n/kafka-clients-0.11/src/main/java/datadog/trace/instrumentation/kafka_clients/Utils.java
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,19 @@ | ||
package datadog.trace.instrumentation.kafka_clients; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
import org.apache.kafka.common.header.Header; | ||
import org.apache.kafka.common.header.Headers; | ||
|
||
public class Utils { | ||
// this method is used in kafka-clients and kafka-streams instrumentations | ||
public static long computePayloadSizeBytes(ConsumerRecord<?, ?> val) { | ||
long headersSize = 0; | ||
Headers headers = val.headers(); | ||
if (headers != null) | ||
for (Header h : headers) { | ||
headersSize += h.value().length + h.key().getBytes(StandardCharsets.UTF_8).length; | ||
} | ||
return headersSize + val.serializedKeySize() + val.serializedValueSize(); | ||
} | ||
} |
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