public ReporterExampleBase(ContextAwareScheduledReporter.Builder reporterBuilder, int tasks, long totalRecords) { this.executor = Executors.newFixedThreadPool(10); this.context = MetricContext.builder("Job") .addTag(new Tag<String>(JobEvent.METADATA_JOB_NAME, "ExampleJob")) .addTag(new Tag<String>(JobEvent.METADATA_JOB_ID, JOB_NAME + "_" + System.currentTimeMillis())) .build(); this.reporterBuilder = reporterBuilder; this.tasks = tasks; this.totalRecords = totalRecords; }
private void addTask(int taskIndex, CountDownLatch countDownLatch) { // Build the context of this task, which is a child of the job's context. // Tags of the job (parent) context will be inherited automatically. MetricContext taskContext = this.context.childBuilder("Task" + taskIndex) .addTag(new Tag<String>(TASK_ID_KEY, TASK_ID_PREFIX + taskIndex)) .build(); Task task = new Task(taskContext, taskIndex, this.totalRecords, countDownLatch); this.executor.execute(task); }
builder.addTag(new Tag<>(entry.getKey(), entry.getValue())); builder.addTag(new Tag<>(config.getScope().name(), broker.getScope(config.getScope()).getScopeId())); for (Map.Entry<String, ConfigValue> entry : ConfigUtils.getConfigOrEmpty(config.getConfig(), TAG_KEY).entrySet()) { builder.addTag(new Tag<>(entry.getKey(), entry.getValue().unwrapped()));