Skip to content

Commit

Permalink
feat: add silent option
Browse files Browse the repository at this point in the history
  • Loading branch information
jigarkhwar committed Apr 30, 2024
1 parent 3fd1c37 commit 5686e70
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.galaxio.gatling.kafka.request.builder.KafkaAttributes

class KafkaRequestAction[K, V](
val producer: KafkaProducer[K, V],
val attr: KafkaAttributes[K, V],
val attributes: KafkaAttributes[K, V],
val coreComponents: CoreComponents,
val kafkaProtocol: KafkaProtocol,
val throttled: Boolean,
Expand All @@ -27,9 +27,9 @@ class KafkaRequestAction[K, V](

override def execute(session: Session): Unit = recover(session) {

attr requestName session flatMap { requestName =>
attributes requestName session flatMap { requestName =>
val outcome =
sendRequest(requestName, producer, attr, throttled, session)
sendRequest(requestName, producer, attributes, throttled, session)

outcome.onFailure(errorMessage =>
statsEngine.reportUnbuildableRequest(session.scenario, session.groups, requestName, errorMessage),
Expand Down Expand Up @@ -58,6 +58,8 @@ class KafkaRequestAction[K, V](
.map(h => h(session).toOption.get)
.orNull

val silent: Boolean = kafkaAttributes.silent.getOrElse(false)

val record = new ProducerRecord[K, V](
kafkaProtocol.producerTopic,
null,
Expand All @@ -74,16 +76,17 @@ class KafkaRequestAction[K, V](

val requestEndDate = clock.nowMillis

statsEngine.logResponse(
session.scenario,
session.groups,
requestName,
startTimestamp = requestStartDate,
endTimestamp = requestEndDate,
if (e == null) OK else KO,
None,
if (e == null) None else Some(e.getMessage),
)
if (!silent)
statsEngine.logResponse(
session.scenario,
session.groups,
requestName,
startTimestamp = requestStartDate,
endTimestamp = requestEndDate,
if (e == null) OK else KO,
None,
if (e == null) None else Some(e.getMessage),
)

coreComponents.throttler match {
case Some(th) if throttled => th.throttle(session.scenario, () => next ! session)
Expand Down

0 comments on commit 5686e70

Please sign in to comment.