org.apache.gobblin.metrics.Tag.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中org.apache.gobblin.metrics.Tag.<init>()方法的一些代码示例,展示了Tag.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag.<init>()方法的具体详情如下:
包路径:org.apache.gobblin.metrics.Tag
类名称:Tag
方法名:<init>

Tag.<init>介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-gobblin

@Override
public List<Tag<?>> getTags() {
 ImmutableList.Builder<Tag<?>> builder = ImmutableList.builder();
 for (Map.Entry<String, Object> entry : this.tags.entrySet()) {
  builder.add(new Tag<Object>(entry.getKey(), entry.getValue()));
 }
 return builder.build();
}

代码示例来源:origin: apache/incubator-gobblin

private static List<Tag<?>> tagsForContainer(State containerState, String applicationName, String taskRunnerId) {
  ImmutableList.Builder<Tag<?>> tags = new ImmutableList.Builder<>();
  tags.add(new Tag<>(GobblinClusterMetricTagNames.APPLICATION_NAME, applicationName));
  tags.add(new Tag<>(GobblinClusterMetricTagNames.TASK_RUNNER_ID, taskRunnerId));
  tags.addAll(getCustomTagsFromState(containerState));
  return tags.build();
 }
}

代码示例来源:origin: apache/incubator-gobblin

/**
 * @return Tags to be applied to the {@link MetricContext} in this object. Called once in {@link #startUp()}.
 * Subclasses should override this method to add additional tags.
 */
protected List<Tag<?>> getTagsForMetrics() {
 List<Tag<?>> tags = Lists.newArrayList();
 tags.add(new Tag<>(RuntimeMetrics.TOPIC, this.topic));
 tags.add(new Tag<>(RuntimeMetrics.GROUP_ID, this.consumerConfig.groupId()));
 return tags;
}

代码示例来源:origin: apache/incubator-gobblin

/**
 * Creates a {@link List} of {@link Tag}s for a {@link Fork} instance. The {@link Tag}s are purely based on the
 * index and the branch name.
 */
private static List<Tag<?>> getForkMetricsTags(State state, int index) {
 return ImmutableList.<Tag<?>>of(new Tag<>(FORK_METRICS_BRANCH_NAME_KEY, getForkMetricsId(state, index)));
}

代码示例来源:origin: apache/incubator-gobblin

@Override
 public List<Tag<?>> generateTags(State state) {
  ImmutableList.Builder<Tag<?>> tags = ImmutableList.<Tag<?>> builder().addAll(super.generateTags(state));
  tags.add(new Tag<>(PARTITION, this.partition));
  for (Schema.Field field : this.partition.getSchema().getFields()) {
   tags.add(new Tag<>(field.name(), this.partition.get(field.name())));
  }
  return tags.build();
 }
}

代码示例来源:origin: apache/incubator-gobblin

protected static List<Tag<?>> tagsForTask(TaskState taskState) {
 List<Tag<?>> tags = Lists.newArrayList();
 tags.add(new Tag<>(TaskEvent.METADATA_TASK_ID, taskState.getTaskId()));
 tags.add(new Tag<>(TaskEvent.METADATA_TASK_ATTEMPT_ID, taskState.getTaskAttemptId().or("")));
 tags.add(new Tag<>(ConfigurationKeys.DATASET_URN_KEY,
   taskState.getProp(ConfigurationKeys.DATASET_URN_KEY, ConfigurationKeys.DEFAULT_DATASET_URN)));
 tags.addAll(getCustomTagsFromState(taskState));
 return tags;
}

代码示例来源:origin: apache/incubator-gobblin

private GobblinMetrics buildGobblinMetrics() {
 // Create tags list
 ImmutableList.Builder<Tag<?>> tags = new ImmutableList.Builder<>();
 tags.add(new Tag<>(GobblinClusterMetricTagNames.APPLICATION_ID, this.applicationId));
 tags.add(new Tag<>(GobblinClusterMetricTagNames.APPLICATION_NAME, this.applicationName));
 // Intialize Gobblin metrics and start reporters
 GobblinMetrics gobblinMetrics = GobblinMetrics.get(this.applicationId, null, tags.build());
 gobblinMetrics.startMetricReporting(ConfigUtils.configToProperties(config));
 return gobblinMetrics;
}

代码示例来源:origin: apache/incubator-gobblin

private static List<Tag<?>> tagsForJob(JobState jobState) {
 List<Tag<?>> tags = Lists.newArrayList();
 tags.add(new Tag<>(JobEvent.METADATA_JOB_NAME, jobState.getJobName() == null ? "" : jobState.getJobName()));
 tags.add(new Tag<>(JobEvent.METADATA_JOB_ID, jobState.getJobId()));
 tags.addAll(getCustomTagsFromState(jobState));
 return tags;
}

代码示例来源:origin: apache/incubator-gobblin

@Override
public List<Tag<?>> generateTags(State state) {
 List<Tag<?>> tags = super.generateTags(state);
 tags.add(new Tag<>("kafkaTopic", KafkaUtils.getTopicName(state)));
 return tags;
}

代码示例来源:origin: apache/incubator-gobblin

@Override
protected List<Tag<?>> getTagsForMetrics() {
 List<Tag<?>> tags = super.getTagsForMetrics();
 tags.add(new Tag<>(RuntimeMetrics.SCHEMA, this.schema.getName()));
 return tags;
}

代码示例来源:origin: apache/incubator-gobblin

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;
}

代码示例来源:origin: apache/incubator-gobblin

/**
 * Converts a wildcard {@link Tag} to a {@link String} {@link Tag}. This method uses the {@link Object#toString()}
 * method to convert the wildcard type to a {@link String}.
 *
 * @param tag a {@link Tag} that should be converted to a {@link Tag} with value of type {@link String}
 *
 * @return a {@link Tag} with a {@link String} value
 */
public static Tag<String> tagValueToString(Tag<?> tag) {
 return new Tag<>(tag.getKey(), tag.getValue().toString());
}

代码示例来源:origin: apache/incubator-gobblin

@Override
public List<Tag<?>> generateTags(State state) {
 List<Tag<?>> tags = super.generateTags(state);
 tags.add(new Tag<>("kafkaTopic", state.getProp(KafkaSimpleStreamingSource.TOPIC_WHITELIST)));
 return tags;
}

代码示例来源:origin: apache/incubator-gobblin

private void switchMetricContextToCurrentPartition() {
 if (this.currentPartitionIdx >= this.partitions.size()) {
  return;
 }
 int currentPartitionId = this.getCurrentPartition().getId();
 switchMetricContext(Lists.<Tag<?>> newArrayList(new Tag<>("kafka_partition", currentPartitionId)));
}

代码示例来源:origin: apache/incubator-gobblin

public MetricContext getDefaultMetricContext() {
 org.apache.gobblin.configuration.State fakeState =
   new org.apache.gobblin.configuration.State(getSysConfig().getConfigAsProperties());
 List<Tag<?>> tags = new ArrayList<>();
 tags.add(new Tag<>(StandardMetrics.INSTANCE_NAME_TAG, getInstanceName()));
 MetricContext res = Instrumented.getMetricContext(fakeState,
   StandardGobblinInstanceDriver.class, tags);
 return res;
}

代码示例来源:origin: apache/incubator-gobblin

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);
}

代码示例来源:origin: apache/incubator-gobblin

@Test
public void testAddTags() {
 this.tagged.addTag(new Tag<String>(JOB_ID_KEY, JOB_ID));
 this.tagged.addTag(new Tag<Integer>(PROJECT_VERSION_KEY, PROJECT_VERSION));
}

代码示例来源:origin: apache/incubator-gobblin

@Test
 public void testTags() {
  Tag<String> jobIdTag = new Tag<String>(JOB_ID_KEY, JOB_ID);
  Assert.assertEquals(jobIdTag.getKey(), JOB_ID_KEY);
  Assert.assertEquals(jobIdTag.getValue(), JOB_ID);

  Tag<Integer> projectVersionTag = new Tag<Integer>(PROJECT_VERSION_KEY, PROJECT_VERSION);
  Assert.assertEquals(projectVersionTag.getKey(), PROJECT_VERSION_KEY);
  Assert.assertEquals(projectVersionTag.getValue().intValue(), PROJECT_VERSION);
 }
}

代码示例来源:origin: apache/incubator-gobblin

@Test
public void testCustomTags() {
 Properties testProperties = new Properties();
 Tag<String> expectedPropertyTag = new Tag<>("key1", "value1");
 GobblinMetrics.addCustomTagToProperties(testProperties, expectedPropertyTag);
 State testState = new State(testProperties);
 List<Tag<?>> tags = GobblinMetrics.getCustomTagsFromState(testState);
 Assert.assertEquals(Iterables.getFirst(tags, null), expectedPropertyTag);
 Tag<String> expectedStateTag = new Tag<>("key2", "value2");
 GobblinMetrics.addCustomTagToState(testState, expectedStateTag);
 tags = GobblinMetrics.getCustomTagsFromState(testState);
 Assert.assertTrue(tags.containsAll(ImmutableList.of(expectedPropertyTag, expectedStateTag)));
}

代码示例来源:origin: apache/incubator-gobblin

@BeforeClass
public void setUp() {
 String contextName = CONTEXT_NAME + "_" + UUID.randomUUID().toString();
 this.context = MetricContext.builder(contextName)
   .addTag(new Tag<String>(JOB_ID_KEY, JOB_ID_PREFIX + 0))
   .build();
 Assert.assertEquals(this.context.getName(), contextName);
 Assert.assertTrue(this.context.getParent().isPresent());
 Assert.assertEquals(this.context.getParent().get(), RootMetricContext.get());
 Assert.assertEquals(this.context.getTags().size(), 3); // uuid and name tag gets added automatically
 Assert.assertEquals(this.context.getTags().get(0).getKey(), JOB_ID_KEY);
 Assert.assertEquals(this.context.getTags().get(0).getValue(), JOB_ID_PREFIX + 0);
 // Second tag should be uuid
 Assert.assertTrue(this.context.getTags().get(1).getValue().toString()
   .matches("[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}"));
}

相关文章