Tabnine Logo
Tag
Code IndexAdd Tabnine to your IDE (free)

How to use
Tag
in
org.ballerinalang.util.metrics

Best Java code snippets using org.ballerinalang.util.metrics.Tag (Showing top 20 results out of 315)

origin: org.ballerinalang/ballerina-core

static Tag of(String key, String value) {
  return new Tag(key, value);
}
origin: org.ballerinalang/ballerina-micrometer-extension

public MicrometerGauge(MeterRegistry meterRegistry, MetricId id) {
  super(id);
  io.micrometer.core.instrument.Gauge.builder(id.getName(), value, DoubleAdder::sum)
      .description(id.getDescription())
      .tags(id.getTags().stream().map(tag -> Tag.of(tag.getKey(), tag.getValue()))
          .collect(Collectors.toList())).register(meterRegistry);
}
origin: org.ballerinalang/ballerina-core

/**
 * Populate tags from a key/value pair.
 *
 * @param tags  An existing set of {@link Tag Tags}.
 * @param key   The tag key.
 * @param value The tag value.
 */
public static void tag(Set<Tag> tags, String key, String value) {
  tags.add(Tag.of(key, value));
}
origin: org.ballerinalang/ballerina-micrometer-extension

public MicrometerCounter(MeterRegistry meterRegistry, MetricId id) {
  super(id);
  counter = io.micrometer.core.instrument.Counter.builder(id.getName())
      .description(id.getDescription())
      .tags(id.getTags().stream().map(tag -> Tag.of(tag.getKey(), tag.getValue()))
          .collect(Collectors.toList())).register(meterRegistry);
}
origin: org.ballerinalang/ballerina-metrics

  @Override
  public void execute(Context context) {
    BStruct gaugeStruct = (BStruct) context.getRefArgument(0);
    String name = gaugeStruct.getStringField(0);
    String description = gaugeStruct.getStringField(1);
    BMap tagsMap = (BMap) gaugeStruct.getRefField(0);

    if (!tagsMap.isEmpty()) {
      List<Tag> tags = new ArrayList<>();
      for (Object key : tagsMap.keySet()) {
        tags.add(new Tag(key.toString(), tagsMap.get(key).stringValue()));
      }
      Gauge.builder(name).description(description).tags(tags).register().increment();
    } else {
      Gauge.builder(name).description(description).register().increment();
    }
  }
}
origin: org.ballerinalang/ballerina-core

  /**
   * Populate tags from a map of key/value pairs.
   *
   * @param tags    An existing set of {@link Tag Tags}.
   * @param tagsMap A map of key value pairs to be used as tags
   */
  public static void tags(Set<Tag> tags, Map<String, String> tagsMap) {
    tagsMap.forEach((key, value) -> tags.add(Tag.of(key, value)));
  }
}
origin: org.ballerinalang/ballerina-micrometer-extension

public <T> MicrometerCallbackGauge(MeterRegistry meterRegistry, MetricId id, T obj,
                  ToDoubleFunction<T> toDoubleFunction) {
  super(id);
  gauge = io.micrometer.core.instrument.Gauge.builder(id.getName(), obj, toDoubleFunction)
      .description(id.getDescription())
      .tags(id.getTags().stream().map(tag -> Tag.of(tag.getKey(), tag.getValue()))
          .collect(Collectors.toList())).register(meterRegistry);
}
origin: org.ballerinalang/ballerina-metrics

  @Override
  public void execute(Context context) {
    BStruct counterStruct = (BStruct) context.getRefArgument(0);
    String name = counterStruct.getStringField(0);
    String description = counterStruct.getStringField(1);
    BMap tagsMap = (BMap) counterStruct.getRefField(0);

    if (!tagsMap.isEmpty()) {
      List<Tag> tags = new ArrayList<>();
      for (Object key : tagsMap.keySet()) {
        tags.add(new Tag(key.toString(), tagsMap.get(key).stringValue()));
      }
      Counter.builder(name).description(description).tags(tags).register().increment();
    } else {
      Counter.builder(name).description(description).register().increment();
    }
  }
}
origin: org.ballerinalang/ballerina-core

/**
 * Populate tags from key/value pairs.
 *
 * @param tags      An existing set of {@link Tag Tags}.
 * @param keyValues Must be an even number of arguments representing key/value pairs of tags.
 */
public static void tags(Set<Tag> tags, String... keyValues) {
  if (keyValues == null || keyValues.length == 0) {
    return;
  }
  if (keyValues.length % 2 == 1) {
    throw new IllegalArgumentException("size must be even, it is a set of key=value pairs");
  }
  for (int i = 0; i < keyValues.length; i += 2) {
    tags.add(Tag.of(keyValues[i], keyValues[i + 1]));
  }
}
origin: org.ballerinalang/ballerina-micrometer-extension

public MicrometerSummary(MeterRegistry meterRegistry, MetricId id) {
  super(id);
  summary = io.micrometer.core.instrument.DistributionSummary.builder(id.getName())
      .description(id.getDescription())
      .tags(id.getTags().stream().map(tag -> Tag.of(tag.getKey(), tag.getValue()))
          .collect(Collectors.toList()))
      .publishPercentiles(0.5, 0.75, 0.98, 0.99, 0.999)
      .register(meterRegistry);
}
origin: org.ballerinalang/ballerina-metrics

  @Override
  public void execute(Context context) {
    BStruct gaugeStruct = (BStruct) context.getRefArgument(0);
    String name = gaugeStruct.getStringField(0);
    String description = gaugeStruct.getStringField(1);
    BMap tagsMap = (BMap) gaugeStruct.getRefField(0);

    if (!tagsMap.isEmpty()) {
      List<Tag> tags = new ArrayList<>();
      for (Object key : tagsMap.keySet()) {
        tags.add(new Tag(key.toString(), tagsMap.get(key).stringValue()));
      }
      Gauge.builder(name).description(description).tags(tags).register().decrement();
    } else {
      Gauge.builder(name).description(description).register().decrement();
    }
  }
}
origin: org.ballerinalang/ballerina-micrometer-extension

public MicrometerTimer(MeterRegistry meterRegistry, MetricId id) {
  super(id);
  timer = io.micrometer.core.instrument.Timer.builder(id.getName())
      .description(id.getDescription())
      .tags(id.getTags().stream().map(tag -> Tag.of(tag.getKey(), tag.getValue()))
          .collect(Collectors.toList()))
      .publishPercentiles(0.5, 0.75, 0.98, 0.99, 0.999)
      .register(meterRegistry);
}
origin: org.ballerinalang/ballerina-metrics

  @Override
  public void execute(Context context) {
    BStruct counterStruct = (BStruct) context.getRefArgument(0);
    String name = counterStruct.getStringField(0);
    String description = counterStruct.getStringField(1);
    BMap tagsMap = (BMap) counterStruct.getRefField(0);
    float amount = (float) context.getFloatArgument(0);

    if (!tagsMap.isEmpty()) {
      List<Tag> tags = new ArrayList<>();
      for (Object key : tagsMap.keySet()) {
        tags.add(new Tag(key.toString(), tagsMap.get(key).stringValue()));
      }
      Counter.builder(name).description(description).tags(tags).register().increment(amount);
    } else {
      Counter.builder(name).description(description).register().increment(amount);
    }
  }
}
origin: org.ballerinalang/ballerina-observability

  private BMap<String, BString> getTags(MetricId metricId) {
    BMap<String, BString> bTags = new BMap<>(new BMapType(BTypes.typeString));
    Set<Tag> tags = metricId.getTags();
    for (Tag tag : tags) {
      bTags.put(tag.getKey(), new BString(tag.getValue()));
    }
    return bTags;
  }
}
origin: org.ballerinalang/ballerina-metrics

  @Override
  public void execute(Context context) {
    BStruct gaugeStruct = (BStruct) context.getRefArgument(0);
    String name = gaugeStruct.getStringField(0);
    String description = gaugeStruct.getStringField(1);
    BMap tagsMap = (BMap) gaugeStruct.getRefField(0);
    float amount = (float) context.getFloatArgument(0);

    if (!tagsMap.isEmpty()) {
      List<Tag> tags = new ArrayList<>();
      for (Object key : tagsMap.keySet()) {
        tags.add(new Tag(key.toString(), tagsMap.get(key).stringValue()));
      }
      Gauge.builder(name).description(description).tags(tags).register().decrement(amount);
    } else {
      Gauge.builder(name).description(description).register().decrement(amount);
    }
  }
}
origin: org.ballerinalang/ballerina-observability

  private BMap<String, BString> getTags(MetricId metricId) {
    BMap<String, BString> bTags = new BMap<>(new BMapType(BTypes.typeString));
    Set<Tag> tags = metricId.getTags();
    for (Tag tag : tags) {
      bTags.put(tag.getKey(), new BString(tag.getValue()));
    }
    return bTags;
  }
}
origin: org.ballerinalang/ballerina-metrics

  @Override
  public void execute(Context context) {
    BStruct gaugeStruct = (BStruct) context.getRefArgument(0);
    String name = gaugeStruct.getStringField(0);
    String description = gaugeStruct.getStringField(1);
    BMap tagsMap = (BMap) gaugeStruct.getRefField(0);
    float value = (float) context.getFloatArgument(0);

    if (!tagsMap.isEmpty()) {
      List<Tag> tags = new ArrayList<>();
      for (Object key : tagsMap.keySet()) {
        tags.add(new Tag(key.toString(), tagsMap.get(key).stringValue()));
      }
      Gauge.builder(name).description(description).tags(tags).register().set(value);
    } else {
      Gauge.builder(name).description(description).register().set(value);
    }
  }
}
origin: org.ballerinalang/ballerina-metrics

  @Override
  public void execute(Context context) {
    BStruct summaryStruct = (BStruct) context.getRefArgument(0);
    String name = summaryStruct.getStringField(0);
    String description = summaryStruct.getStringField(1);
    float amount = (float) context.getFloatArgument(0);
    BMap tagsMap = (BMap) summaryStruct.getRefField(0);

    if (!tagsMap.isEmpty()) {
      List<Tag> tags = new ArrayList<>();
      for (Object key : tagsMap.keySet()) {
        tags.add(new Tag(key.toString(), tagsMap.get(key).stringValue()));
      }
      Summary.builder(name).description(description).tags(tags).register().record(amount);
    } else {
      Summary.builder(name).description(description).register().record(amount);
    }
  }
}
origin: org.ballerinalang/ballerina-metrics

  @Override
  public void execute(Context context) {
    BStruct gaugeStruct = (BStruct) context.getRefArgument(0);
    String name = gaugeStruct.getStringField(0);
    String description = gaugeStruct.getStringField(1);
    BMap tagsMap = (BMap) gaugeStruct.getRefField(0);
    float amount = (float) context.getFloatArgument(0);

    if (!tagsMap.isEmpty()) {
      List<Tag> tags = new ArrayList<>();
      for (Object key : tagsMap.keySet()) {
        tags.add(new Tag(key.toString(), tagsMap.get(key).stringValue()));
      }
      Gauge.builder(name).description(description).tags(tags).register().increment(amount);
    } else {
      Gauge.builder(name).description(description).register().increment(amount);
    }
  }
}
origin: org.ballerinalang/ballerina-metrics

  @Override
  public void execute(Context context) {
    BStruct timerStruct = (BStruct) context.getRefArgument(0);
    String name = timerStruct.getStringField(0);
    String description = timerStruct.getStringField(1);
    BMap tagsMap = (BMap) timerStruct.getRefField(0);
    long amount = context.getIntArgument(0);
    BEnumerator timeUnitEnum = (BEnumerator) context.getRefArgument(1);

    TimeUnit timeUnit = TimeUnitExtractor.getTimeUnit(timeUnitEnum);

    if (!tagsMap.isEmpty()) {
      List<Tag> tags = new ArrayList<>();
      for (Object key : tagsMap.keySet()) {
        tags.add(new Tag(key.toString(), tagsMap.get(key).stringValue()));
      }
      Timer.builder(name).description(description).tags(tags).register().record(amount, timeUnit);
    } else {
      Timer.builder(name).description(description).register().record(amount, timeUnit);
    }
  }
}
org.ballerinalang.util.metricsTag

Javadoc

Tag representing key/value pair.

Most used methods

  • <init>
  • getKey
  • getValue
  • of

Popular in Java

  • Running tasks concurrently on multiple threads
  • scheduleAtFixedRate (ScheduledExecutorService)
  • setScale (BigDecimal)
  • getApplicationContext (Context)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • JCheckBox (javax.swing)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now