-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for custom MR mappings (#346)
* Add support for custom MR mappings * Add missing Javadoc for MonitoredResourceMapping * Add unit tests for custom MR mappings * Update platform metric mapping logic and rename MonitoredResourceDescription * fix values in unit test * Add unit test for no labels * refactor: convert to unmodifieable set in constructor * Add unit test for empty resource attributes * remove redundant reference to this * update formatting; add missing Javadoc * Add warning message for MR type mismatch * Update label name in test to avoid confusion * rename DEFAULT_MONITORED_RESOURCE_DESCRIPTION -> EMPTY_MONITORED_RESOURCE_DESCRIPTION * Set MR labels only if found
- Loading branch information
Showing
8 changed files
with
532 additions
and
11 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
59 changes: 59 additions & 0 deletions
59
...ics/src/main/java/com/google/cloud/opentelemetry/metric/MonitoredResourceDescription.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,59 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.cloud.opentelemetry.metric; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
import javax.annotation.concurrent.Immutable; | ||
|
||
/** | ||
* This class holds the mapping between Google Cloud's monitored resource type and the labels for | ||
* identifying the given monitored resource type. | ||
*/ | ||
@Immutable | ||
public final class MonitoredResourceDescription { | ||
private final String mrType; | ||
private final Set<String> mrLabels; | ||
|
||
/** | ||
* Public constructor. | ||
* | ||
* @param mrType The monitored resource type for which the mapping is being specified. | ||
* @param mrLabels A set of labels which uniquely identify a given monitored resource. | ||
*/ | ||
public MonitoredResourceDescription(String mrType, Set<String> mrLabels) { | ||
this.mrType = mrType; | ||
this.mrLabels = Collections.unmodifiableSet(mrLabels); | ||
} | ||
|
||
/** | ||
* Returns the set of labels used to identify the monitored resource represented in this mapping. | ||
* | ||
* @return Immutable set of labels that map to the specified monitored resource type. | ||
*/ | ||
public Set<String> getMonitoredResourceLabels() { | ||
return mrLabels; | ||
} | ||
|
||
/** | ||
* The type of the monitored resource for which mapping is defined. | ||
* | ||
* @return The type of the monitored resource. | ||
*/ | ||
public String getMonitoredResourceType() { | ||
return mrType; | ||
} | ||
} |
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
Oops, something went wrong.