Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
releaseType: java-yoshi
bumpMinorPreMajor: true
bumpMinorPreMajor: true
extraFiles:
- google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/Version.java
10 changes: 0 additions & 10 deletions google-cloud-bigtable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,6 @@
</profiles>

<build>
<resources>
<resource>
<directory>src/main/templates</directory>
<includes>
<include>**/*.java</include>
</includes>
<filtering>true</filtering>
<targetPath>${project.build.directory}/generated-sources/java</targetPath>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 Google LLC
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@

@InternalApi("For internal use only")
public final class Version {
// The released version, populated by maven.
public static String VERSION = "${java-bigtable.version}";
// {x-version-update-start:google-cloud-bigtable:current}
public static String VERSION = "1.22.0-sp.1-SNAPSHOT";
// {x-version-update-end}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.api.gax.batching.BatcherImpl;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.api.gax.core.GaxProperties;
import com.google.api.gax.grpc.GaxGrpcProperties;
import com.google.api.gax.grpc.GrpcCallSettings;
import com.google.api.gax.grpc.GrpcRawCallableFactory;
Expand Down Expand Up @@ -54,6 +53,7 @@
import com.google.bigtable.v2.ReadRowsResponse;
import com.google.bigtable.v2.SampleRowKeysRequest;
import com.google.bigtable.v2.SampleRowKeysResponse;
import com.google.cloud.bigtable.Version;
import com.google.cloud.bigtable.data.v2.internal.RequestContext;
import com.google.cloud.bigtable.data.v2.models.BulkMutation;
import com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation;
Expand Down Expand Up @@ -194,9 +194,7 @@ public static EnhancedBigtableStubSettings finalizeSettings(
// Also annotate traces with library versions
.put("gax", GaxGrpcProperties.getGaxGrpcVersion())
.put("grpc", GaxGrpcProperties.getGrpcVersion())
.put(
"gapic",
GaxProperties.getLibraryVersion(EnhancedBigtableStubSettings.class))
.put("gapic", Version.VERSION)
.build()),
// Add OpenCensus Metrics
MetricsTracerFactory.create(tagger, stats, attributes),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2021 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
*
* https://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.bigtable;

import static com.google.common.truth.Truth.assertThat;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Smoke test to ensure that release tooling doesn't accidentally corrupt the version */
@RunWith(JUnit4.class)
public class VersionTest {
@Test
public void testVersion() {
assertThat(Version.VERSION).matches("\\d+\\.\\d+\\.\\d(?:-sp.\\d+)(?:-SNAPSHOT)?");

assertThat(Version.VERSION).isGreaterThan("1.22.0");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
import static com.google.common.truth.Truth.assertThat;

import com.google.api.gax.core.NoCredentialsProvider;
import com.google.api.gax.grpc.GaxGrpcProperties;
import com.google.api.gax.rpc.ServerStreamingCallable;
import com.google.bigtable.v2.BigtableGrpc;
import com.google.bigtable.v2.ReadRowsRequest;
import com.google.bigtable.v2.ReadRowsResponse;
import com.google.bigtable.v2.RowSet;
import com.google.cloud.bigtable.Version;
import com.google.cloud.bigtable.admin.v2.internal.NameUtil;
import com.google.cloud.bigtable.data.v2.BigtableDataSettings;
import com.google.cloud.bigtable.data.v2.FakeServiceHelper;
Expand All @@ -39,8 +41,17 @@
import io.grpc.ServerCall.Listener;
import io.grpc.ServerCallHandler;
import io.grpc.ServerInterceptor;
import io.grpc.internal.GrpcUtil;
import io.grpc.stub.StreamObserver;
import io.opencensus.common.Scope;
import io.opencensus.trace.AttributeValue;
import io.opencensus.trace.Tracing;
import io.opencensus.trace.export.SpanData;
import io.opencensus.trace.export.SpanExporter.Handler;
import io.opencensus.trace.samplers.Samplers;
import java.io.IOException;
import java.util.Collection;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import org.junit.After;
Expand Down Expand Up @@ -152,6 +163,61 @@ public void testUserAgent() throws InterruptedException {
.containsMatch("bigtable-java/\\d+\\.\\d+\\.\\d+(?:-SNAPSHOT)?");
}

@Test
public void testSpanAttributes() throws InterruptedException {
final BlockingQueue<SpanData> spans = new ArrayBlockingQueue<>(100);

// inject a temporary trace exporter
String handlerName = "stub-test-exporter";

Tracing.getExportComponent()
.getSpanExporter()
.registerHandler(
handlerName,
new Handler() {
@Override
public void export(Collection<SpanData> collection) {
spans.addAll(collection);
}
});

SpanData foundSpanData = null;
// Issue the rpc and grab the span
try {
try (Scope ignored =
Tracing.getTracer()
.spanBuilder("fake-parent-span")
.setSampler(Samplers.alwaysSample())
.startScopedSpan()) {
enhancedBigtableStub.readRowCallable().call(Query.create("table-id").rowKey("row-key"));
}

for (int i = 0; i < 100; i++) {
SpanData spanData = spans.poll(10, TimeUnit.SECONDS);
if ("Bigtable.ReadRow".equals(spanData.getName())) {
foundSpanData = spanData;
break;
}
}
} finally {
// cleanup
Tracing.getExportComponent().getSpanExporter().unregisterHandler(handlerName);
}

// Examine the caught span
assertThat(foundSpanData).isNotNull();
assertThat(foundSpanData.getAttributes().getAttributeMap())
.containsEntry("gapic", AttributeValue.stringAttributeValue(Version.VERSION));
assertThat(foundSpanData.getAttributes().getAttributeMap())
.containsEntry(
"grpc",
AttributeValue.stringAttributeValue(
GrpcUtil.getGrpcBuildVersion().getImplementationVersion()));
assertThat(foundSpanData.getAttributes().getAttributeMap())
.containsEntry(
"gax", AttributeValue.stringAttributeValue(GaxGrpcProperties.getGaxGrpcVersion()));
}

private static class MetadataInterceptor implements ServerInterceptor {
final BlockingQueue<Metadata> headers = Queues.newLinkedBlockingDeque();

Expand Down
4 changes: 4 additions & 0 deletions synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def main():
# todo remove once template is updated
'.github/ISSUE_TEMPLATE/bug_report.md',
'CONTRIBUTING.md',
# exclude autogen
'codecov.yaml'
# needed for extraFiles
'.github/release-please.yml',
])

def generate_data_api(gapic):
Expand Down