-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metrics: implement java/spark metrics
Signed-off-by: Maciej Obuchowski <obuchowski.maciej@gmail.com>
- Loading branch information
1 parent
a10759e
commit f673013
Showing
77 changed files
with
988 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
client/java/src/main/java/io/openlineage/client/metrics/CompositeMetricsBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
/* 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. | ||
* | ||
* <p>CompositeMeterRegistry is a type of MeterRegistry, that encapsulates two or more meter | ||
* registries into one, and manages unified functionalities across all registries. | ||
*/ | ||
public class CompositeMetricsBuilder implements MetricsBuilder<CompositeMeterRegistry> { | ||
|
||
/** | ||
* 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<String, Object> config) { | ||
CompositeMeterRegistry meterRegistry = new CompositeMeterRegistry(); | ||
Object registries = config.get("registries"); | ||
if (!(registries instanceof List) || ((List<?>) registries).isEmpty()) { | ||
return meterRegistry; | ||
} | ||
for (Object registryConfig : (List<Object>) registries) { | ||
if (registryConfig instanceof Map || !((Map<?, ?>) registryConfig).isEmpty()) { | ||
MetricsResolver.parseMeterRegistryConfig((Map<String, Object>) registryConfig) | ||
.ifPresent(meterRegistry::add); | ||
} | ||
} | ||
return meterRegistry; | ||
} | ||
|
||
@Override | ||
public String type() { | ||
return "composite"; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
client/java/src/main/java/io/openlineage/client/metrics/MetricsBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
/* Copyright 2018-2024 contributors to the OpenLineage project | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.openlineage.client.metrics; | ||
|
||
import io.micrometer.core.instrument.MeterRegistry; | ||
import java.util.Map; | ||
|
||
/** | ||
* MetricsBuilder is an interface that defines methods to build different types of meter registries | ||
* from OpenLineage config. | ||
*/ | ||
public interface MetricsBuilder<T extends MeterRegistry> { | ||
T registry(Map<String, Object> config); | ||
|
||
String type(); | ||
} |
Oops, something went wrong.