-
Notifications
You must be signed in to change notification settings - Fork 75
impl(o11y): introduce gcp.client.version #4140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
diegomarquezp
wants to merge
28
commits into
main
Choose a base branch
from
observability/tracing-attr/gcp.client.version-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+625
−32
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
debafec
impl(o11y): introduce gcp.client.version
diegomarquezp ab32cc6
test: update goldens
diegomarquezp 21647c7
chore: regenerate showcase
diegomarquezp 8e9336f
test: add region tags for showcase test
diegomarquezp 9b63214
chore: format
diegomarquezp b892bb9
test: add test for ApiTracerContextTest
diegomarquezp 73c81b0
chore: update goldens
diegomarquezp bc8ce53
build: update release please config
diegomarquezp e90158d
test: update bazel goldens
diegomarquezp 7c5d731
chore: lint generator
diegomarquezp 16eac3a
test: restore test case
diegomarquezp 18da4eb
build: ignore Version.java changes by generator
diegomarquezp 6028a0d
Merge branch 'main' into observability/tracing-attr/gcp.client.version-2
diegomarquezp baf4332
Merge branch 'observability/tracing-attr/gcp.client.version-2' of htt…
diegomarquezp 954826d
fix: generate Version.java as package private
diegomarquezp 1317237
fix: revert unnecessary changes
diegomarquezp 61f383d
docs: do not use snapshot version in javadoc
diegomarquezp a47349d
Merge remote-tracking branch 'origin/main' into observability/tracing…
diegomarquezp 5056ffb
fix: use setVersion instead of setLibraryVersion
diegomarquezp 151cda2
chore: update showcase
diegomarquezp 2ebbc44
test: do not test version in showcase
diegomarquezp 4cffbfe
build: update owlbot yaml template
diegomarquezp e1dd69f
build: update rlease please config
diegomarquezp 78545ff
test: update bazel goldens
diegomarquezp 529d91c
chore: regenerate showcase
diegomarquezp 400f7df
fix: use stub package for vesion
diegomarquezp 6bf6efb
test: update it goldens
diegomarquezp abb8dde
Merge remote-tracking branch 'origin/main' into observability/tracing…
diegomarquezp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
95 changes: 95 additions & 0 deletions
95
...va/src/main/java/com/google/api/generator/gapic/composer/LibraryVersionClassComposer.java
This file contains hidden or 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,95 @@ | ||
| // Copyright 2026 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.api.generator.gapic.composer; | ||
|
|
||
| import com.google.api.generator.engine.ast.AnnotationNode; | ||
| import com.google.api.generator.engine.ast.AssignmentExpr; | ||
| import com.google.api.generator.engine.ast.ClassDefinition; | ||
| import com.google.api.generator.engine.ast.CommentStatement; | ||
| import com.google.api.generator.engine.ast.ConcreteReference; | ||
| import com.google.api.generator.engine.ast.ExprStatement; | ||
| import com.google.api.generator.engine.ast.LineComment; | ||
| import com.google.api.generator.engine.ast.ScopeNode; | ||
| import com.google.api.generator.engine.ast.StringObjectValue; | ||
| import com.google.api.generator.engine.ast.TypeNode; | ||
| import com.google.api.generator.engine.ast.ValueExpr; | ||
| import com.google.api.generator.engine.ast.Variable; | ||
| import com.google.api.generator.engine.ast.VariableExpr; | ||
| import com.google.api.generator.gapic.model.GapicClass; | ||
| import com.google.api.generator.gapic.model.GapicContext; | ||
| import com.google.api.generator.gapic.model.Service; | ||
| import java.util.Arrays; | ||
|
|
||
| public class LibraryVersionClassComposer { | ||
| private static final LibraryVersionClassComposer INSTANCE = new LibraryVersionClassComposer(); | ||
|
|
||
| private LibraryVersionClassComposer() {} | ||
|
|
||
| public static LibraryVersionClassComposer instance() { | ||
| return INSTANCE; | ||
| } | ||
|
|
||
| public GapicClass generate(GapicContext context, Service service) { | ||
| String packageName = service.pakkage() + ".stub"; | ||
| String className = "Version"; | ||
|
|
||
| String artifact = context.artifact(); | ||
| String artifactId = artifact; | ||
| if (artifact != null && artifact.contains(":")) { | ||
| artifactId = artifact.split(":")[1]; | ||
| } | ||
|
|
||
| VariableExpr versionVarExpr = | ||
| VariableExpr.withVariable( | ||
| Variable.builder().setType(TypeNode.STRING).setName("VERSION").build()); | ||
| AssignmentExpr versionAssignmentExpr = | ||
| AssignmentExpr.builder() | ||
| .setVariableExpr( | ||
| versionVarExpr.toBuilder() | ||
| .setIsDecl(true) | ||
| .setScope(ScopeNode.PUBLIC) | ||
| .setIsStatic(true) | ||
| .setIsFinal(true) | ||
| .build()) | ||
| .setValueExpr(ValueExpr.withValue(StringObjectValue.withValue("0.0.0-SNAPSHOT"))) | ||
| .build(); | ||
|
|
||
| ClassDefinition classDef = | ||
| ClassDefinition.builder() | ||
| .setPackageString(packageName) | ||
| .setAnnotations( | ||
| Arrays.asList( | ||
| AnnotationNode.builder() | ||
| .setType( | ||
| TypeNode.withReference( | ||
| ConcreteReference.withClazz(com.google.api.core.InternalApi.class))) | ||
| .setDescription("For internal use only") | ||
| .build())) | ||
| .setScope(ScopeNode.LOCAL) | ||
| .setIsFinal(true) | ||
| .setName(className) | ||
| .setStatements( | ||
| Arrays.asList( | ||
| CommentStatement.withComment( | ||
| LineComment.withComment( | ||
| String.format("{x-version-update-start:%s:current}", artifactId))), | ||
| ExprStatement.withExpr(versionAssignmentExpr), | ||
| CommentStatement.withComment( | ||
| LineComment.withComment("{x-version-update-end}")))) | ||
| .build(); | ||
|
|
||
| return GapicClass.create(GapicClass.Kind.MAIN, classDef); | ||
| } | ||
| } |
This file contains hidden or 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
34 changes: 34 additions & 0 deletions
34
...rc/test/java/com/google/api/generator/gapic/composer/LibraryVersionClassComposerTest.java
This file contains hidden or 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,34 @@ | ||
| // Copyright 2026 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.api.generator.gapic.composer; | ||
|
|
||
| import com.google.api.generator.gapic.model.GapicClass; | ||
| import com.google.api.generator.gapic.model.GapicContext; | ||
| import com.google.api.generator.gapic.model.Service; | ||
| import com.google.api.generator.test.framework.Assert; | ||
| import com.google.api.generator.test.protoloader.GrpcTestProtoLoader; | ||
| import org.junit.Test; | ||
|
|
||
| public class LibraryVersionClassComposerTest { | ||
|
|
||
| @Test | ||
| public void generateVersionClasses() { | ||
| GapicContext context = GrpcTestProtoLoader.instance().parseShowcaseEcho(); | ||
| Service service = context.services().get(0); | ||
| GapicClass clazz = LibraryVersionClassComposer.instance().generate(context, service); | ||
|
|
||
| Assert.assertGoldenClass(this.getClass(), clazz, "EchoVersion.golden"); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
...tor-java/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoVersion.golden
This file contains hidden or 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,11 @@ | ||
| package com.google.showcase.v1beta1.stub; | ||
|
|
||
| import com.google.api.core.InternalApi; | ||
|
|
||
| @InternalApi("For internal use only") | ||
| final class Version { | ||
| // {x-version-update-start:gapic-showcase:current} | ||
| public static final String VERSION = "0.0.0-SNAPSHOT"; | ||
| // {x-version-update-end} | ||
|
|
||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.