Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into jspecify_annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
suztomo committed Sep 16, 2024
2 parents efd84ea + 1a988df commit d7c31f2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .github/scripts/hermetic_library_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ docker run \
rm -rdf output googleapis "${baseline_generation_config}"
git add --all -- ':!pr_description.txt' ':!hermetic_library_generation.sh'
changed_files=$(git diff --cached --name-only)
if [[ "${changed_files}" == "" ]]; then
echo "There is no generated code change."
echo "Skip committing to the pull request."
exit 0
if [[ "${changed_files}" != "" ]]; then
echo "Commit changes..."
git commit -m "${message}"
git push
else
echo "There is no generated code change, skip commit."
fi

git commit -m "${message}"
git push
# set pr body if pr_description.txt is generated.
if [[ -f "pr_description.txt" ]]; then
pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,15 @@ public void addAttributes(String key, String value) {
attributes.put(key, value);
};

/**
* Add attributes that will be attached to all metrics. This is expected to be called by
* handwritten client teams to add additional attributes that are not supposed be collected by
* Gax.
*/
public void addAttributes(Map<String, String> attributes) {
this.attributes.putAll(attributes);
};

@VisibleForTesting
Map<String, String> getAttributes() {
return attributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.google.api.gax.rpc.StatusCode.Code;
import com.google.api.gax.rpc.testing.FakeStatusCode;
import com.google.common.collect.ImmutableMap;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -228,6 +229,16 @@ void testAddAttributes_recordsAttributes() {
assertThat(metricsTracer.getAttributes().get("FakeTableId")).isEqualTo("12345");
}

@Test
void testAddAttributes_recordsAttributesWithMap() {
Map<String, String> attributes = new HashMap<>();
attributes.put("FakeTableId", "12345");
attributes.put("FakeInstanceId", "67890");
metricsTracer.addAttributes(attributes);
assertThat(metricsTracer.getAttributes().get("FakeTableId")).isEqualTo("12345");
assertThat(metricsTracer.getAttributes().get("FakeInstanceId")).isEqualTo("67890");
}

@Test
void testExtractStatus_errorConversion_apiExceptions() {
ApiException error =
Expand Down

0 comments on commit d7c31f2

Please sign in to comment.