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

io.openlineage.client.metrics.CompositeMeterRegistryFactory Maven / Gradle / Ivy

There is a newer version: 1.26.0
Show newest version
/*
/* Copyright 2018-2024 contributors to the OpenLineage project
/* SPDX-License-Identifier: Apache-2.0
*/

package io.openlineage.client.metrics;

import io.micrometer.core.instrument.composite.CompositeMeterRegistry;
import java.util.List;
import java.util.Map;

/**
 * A builder class that provides implementations to build composite meter registries. This class
 * implements the MetricsBuilder interface with CompositeMeterRegistry as its type.
 *
 * 

CompositeMeterRegistry is a type of MeterRegistry, that encapsulates two or more meter * registries into one, and manages unified functionalities across all registries. */ public class CompositeMeterRegistryFactory implements MeterRegistryFactory { /** * Constructs a CompositeMeterRegistry from a given map of configuration options. The "registries" * key in the map is expected to provide a list of meter registry configurations. Each * configuration is parsed and, if parsed successfully, added to the CompositeMeterRegistry. * * @param config The map containing the configurations for composite meter registry. * @return A CompositeMeterRegistry built from the provided configuration. An empty * CompositeMeterRegistry is returned if the the map doesn't contain a list of configurations * extended by registries. */ @Override public CompositeMeterRegistry registry(Map config) { CompositeMeterRegistry meterRegistry = new CompositeMeterRegistry(); Object registries = config.get("registries"); if (!(registries instanceof List) || ((List) registries).isEmpty()) { return meterRegistry; } for (Object registryConfig : (List) registries) { if (registryConfig instanceof Map || !((Map) registryConfig).isEmpty()) { MicrometerProvider.parseMeterRegistryConfig((Map) registryConfig) .ifPresent(meterRegistry::add); } } return meterRegistry; } @Override public String type() { return "composite"; } }