Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example recording time from trigger timestamp to grab before successf… #217

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
import com.transferwise.tasks.domain.TaskStatus;
import com.transferwise.tasks.handler.interfaces.StuckDetectionSource;
import com.transferwise.tasks.processing.TasksProcessingService.ProcessTaskResponse;
import com.transferwise.tasks.processing.TasksProcessingService.ProcessTaskResponse.Result;
import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.ImmutableTag;
import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.Tags;
import io.micrometer.core.instrument.binder.kafka.KafkaClientMetrics;
import java.time.Duration;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -179,11 +181,15 @@
}

@Override
public void registerTaskGrabbingResponse(String bucketId, String taskType, int priority, ProcessTaskResponse processTaskResponse) {
public void registerTaskGrabbingResponse(String bucketId, String taskType, int priority, Duration timeTillGrab, ProcessTaskResponse processTaskResponse) {

Check warning on line 184 in tw-tasks-core/src/main/java/com/transferwise/tasks/helpers/CoreMetricsTemplate.java

View workflow job for this annotation

GitHub Actions / Checkstyle Report-(3.4.0)

com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck

Line is longer than 150 characters (found 156).

Check warning on line 184 in tw-tasks-core/src/main/java/com/transferwise/tasks/helpers/CoreMetricsTemplate.java

View workflow job for this annotation

GitHub Actions / Checkstyle Report-(3.3.1)

com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck

Line is longer than 150 characters (found 156).
meterCache.counter(METRIC_TASKS_TASK_GRABBING, TagsSet.of(TAG_TASK_TYPE, taskType,
TAG_BUCKET_ID, bucketId, TAG_PRIORITY, String.valueOf(priority), TAG_GRABBING_RESPONSE, processTaskResponse.getResult().name(),
TAG_GRABBING_CODE, processTaskResponse.getCode() == null ? "UNKNOWN" : processTaskResponse.getCode().name()))
.increment();

if (processTaskResponse.getResult() == Result.OK) {
meterCache.timer("...", TagsSet.empty()).record(timeTillGrab);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.transferwise.tasks.domain.TaskStatus;
import com.transferwise.tasks.handler.interfaces.StuckDetectionSource;
import com.transferwise.tasks.processing.TasksProcessingService.ProcessTaskResponse;
import java.time.Duration;
import java.time.ZonedDateTime;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -49,7 +50,7 @@ public interface ICoreMetricsTemplate {

void registerFailedNextEventTimeChange(String taskType, ZonedDateTime fromNextEventTime, ZonedDateTime toNextEventTime);

void registerTaskGrabbingResponse(String bucketId, String type, int priority, ProcessTaskResponse processTaskResponse);
void registerTaskGrabbingResponse(String bucketId, String type, int priority, Duration timeTillGrab, ProcessTaskResponse processTaskResponse);

void debugPriorityQueueCheck(String bucketId, int priority);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,12 @@
mdcService.with(() -> {
mdcService.put(task);
try {

Instant timeNow = Instant.now();

ProcessTaskResponse processTaskResponse = grabTaskForProcessing(bucketId, task);

coreMetricsTemplate.registerTaskGrabbingResponse(bucketId, type, priority, processTaskResponse);
coreMetricsTemplate.registerTaskGrabbingResponse(bucketId, type, priority, Duration.between(taskTriggering.getTriggerAt(), timeNow), processTaskResponse);

Check warning on line 220 in tw-tasks-core/src/main/java/com/transferwise/tasks/processing/TasksProcessingService.java

View workflow job for this annotation

GitHub Actions / Checkstyle Report-(3.4.0)

com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck

Line is longer than 150 characters (found 166).

Check warning on line 220 in tw-tasks-core/src/main/java/com/transferwise/tasks/processing/TasksProcessingService.java

View workflow job for this annotation

GitHub Actions / Checkstyle Report-(3.3.1)

com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck

Line is longer than 150 characters (found 166).

if (processTaskResponse.getResult() == ProcessTaskResponse.Result.NO_SPACE) {
noRoomMap.put(type, Boolean.TRUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.transferwise.tasks.utils.WaitUtils;
import com.vdurmont.semver4j.Semver;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
Expand Down Expand Up @@ -284,7 +285,11 @@ public void poll(String bucketId) {
mdcService.with(() -> {
mdcService.put(task);

TaskTriggering taskTriggering = new TaskTriggering().setTask(task).setBucketId(bucketId).setOffset(offset)
TaskTriggering taskTriggering = new TaskTriggering()
.setTask(task)
.setBucketId(bucketId)
.setOffset(offset)
.setTriggerAt(Instant.ofEpochSecond(consumerRecord.timestamp()))
.setTopicPartition(topicPartition);

coreMetricsTemplate.registerKafkaTasksExecutionTriggererTriggersReceive(bucketId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.kafka.common.TopicPartition;
import java.time.Instant;

Check warning on line 7 in tw-tasks-core/src/main/java/com/transferwise/tasks/triggering/TaskTriggering.java

View workflow job for this annotation

GitHub Actions / Checkstyle Report-(3.4.0)

com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck

Wrong lexicographical order for 'java.time.Instant' import. Should be before 'org.apache.kafka.common.TopicPartition'.

Check warning on line 7 in tw-tasks-core/src/main/java/com/transferwise/tasks/triggering/TaskTriggering.java

View workflow job for this annotation

GitHub Actions / Checkstyle Report-(3.3.1)

com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck

Wrong lexicographical order for 'java.time.Instant' import. Should be before 'org.apache.kafka.common.TopicPartition'.

@Data
@Accessors(chain = true)
public class TaskTriggering {

private BaseTask task;
private long offset;
private Instant triggerAt;
private long sequence;
private TopicPartition topicPartition;
private String bucketId;
Expand Down
Loading