All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.newrelic.telemetry.micrometer.transform.AttributesMaker Maven / Gradle / Ivy

The newest version!
/*
 * ---------------------------------------------------------------------------------------------
 *  Copyright (c) 2019 New Relic Corporation. All rights reserved.
 *  Licensed under the Apache 2.0 License. See LICENSE in the project root directory for license information.
 * --------------------------------------------------------------------------------------------
 */

package com.newrelic.telemetry.micrometer.transform;

import com.newrelic.telemetry.Attributes;
import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.Tag;
import java.util.List;

public class AttributesMaker {

  Attributes make(Meter.Id id, String sourceType) {
    List tags = id.getTags();
    String baseUnit = id.getBaseUnit();
    String description = id.getDescription();

    Attributes attributes = new Attributes();

    if (description != null) {
      attributes.put("description", description);
    }
    if (baseUnit != null) {
      attributes.put("baseUnit", baseUnit);
    }
    tags.forEach(tag -> attributes.put(tag.getKey(), tag.getValue()));

    return attributes;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy