Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

Commit d8bb7bd

Browse files
authored
Merge branch 'main' into renovate/com.google.cloud-google-cloud-trace-2.x
2 parents 2be00d3 + 0d0ad41 commit d8bb7bd

File tree

10 files changed

+92
-7
lines changed

10 files changed

+92
-7
lines changed

.github/workflows/hermetic_library_generation.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
with:
3838
fetch-depth: 0
3939
token: ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }}
40-
- uses: googleapis/sdk-platform-java/.github/scripts@v2.67.0
40+
- uses: googleapis/sdk-platform-java/.github/scripts@v2.68.0
4141
if: env.SHOULD_RUN == 'true'
4242
with:
4343
base_ref: ${{ github.base_ref }}

.github/workflows/unmanaged_dependency_check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ jobs:
1717
# repository
1818
.kokoro/build.sh
1919
- name: Unmanaged dependency check
20-
uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.57.0
20+
uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.58.0
2121
with:
2222
bom-path: google-cloud-spanner-bom/pom.xml

google-cloud-spanner-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>com.google.cloud</groupId>
1010
<artifactId>sdk-platform-java-config</artifactId>
11-
<version>3.57.0</version>
11+
<version>3.58.0</version>
1212
</parent>
1313

1414
<name>Google Cloud Spanner BOM</name>

google-cloud-spanner/src/main/java/com/google/cloud/spanner/BuiltInMetricsConstant.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class BuiltInMetricsConstant {
4141

4242
public static final String METER_NAME = "spanner.googleapis.com/internal/client";
4343
public static final String GAX_METER_NAME = OpenTelemetryMetricsRecorder.GAX_METER_NAME;
44+
public static final String GRPC_GCP_METER_NAME = "grpc-gcp";
4445
static final String SPANNER_METER_NAME = "spanner-java";
4546
static final String GRPC_METER_NAME = "grpc-java";
4647
static final String GFE_LATENCIES_NAME = "gfe_latencies";
@@ -53,6 +54,8 @@ public class BuiltInMetricsConstant {
5354
static final String ATTEMPT_LATENCY_NAME = "attempt_latency";
5455
static final String OPERATION_COUNT_NAME = "operation_count";
5556
static final String ATTEMPT_COUNT_NAME = "attempt_count";
57+
static final String EEF_FALLBACK_COUNT_NAME = "eef.fallback_count";
58+
static final String EEF_CALL_STATUS_NAME = "eef.call_status";
5659

5760
public static final Set<String> SPANNER_METRICS =
5861
ImmutableSet.of(
@@ -117,6 +120,29 @@ public class BuiltInMetricsConstant {
117120
"grpc.xds_client.resource_updates_invalid",
118121
"grpc.xds_client.resource_updates_valid");
119122

123+
public static final AttributeKey<String> CHANNEL_NAME_KEY =
124+
AttributeKey.stringKey("channel_name");
125+
public static final AttributeKey<String> FROM_CHANNEL_NAME_KEY =
126+
AttributeKey.stringKey("from_channel_name");
127+
public static final AttributeKey<String> TO_CHANNEL_NAME_KEY =
128+
AttributeKey.stringKey("to_channel_name");
129+
public static final AttributeKey<String> STATUS_CODE_KEY = AttributeKey.stringKey("status_code");
130+
131+
static final Set<String> GRPC_GCP_EEF_FALLBACK_COUNT_ATTRIBUTES =
132+
ImmutableSet.of(FROM_CHANNEL_NAME_KEY.getKey(), TO_CHANNEL_NAME_KEY.getKey());
133+
134+
static final Set<String> GRPC_GCP_EEF_CALL_STATUS_ATTRIBUTES =
135+
ImmutableSet.of(CHANNEL_NAME_KEY.getKey(), STATUS_CODE_KEY.getKey());
136+
137+
static final Map<String, Set<String>> GRPC_GCP_METRIC_ADDITIONAL_ATTRIBUTES =
138+
ImmutableMap.<String, Set<String>>builder()
139+
.put(EEF_FALLBACK_COUNT_NAME, GRPC_GCP_EEF_FALLBACK_COUNT_ATTRIBUTES)
140+
.put(EEF_CALL_STATUS_NAME, GRPC_GCP_EEF_CALL_STATUS_ATTRIBUTES)
141+
.build();
142+
143+
static final Collection<String> GRPC_GCP_METRICS_TO_ENABLE =
144+
ImmutableList.of(EEF_FALLBACK_COUNT_NAME, EEF_CALL_STATUS_NAME);
145+
120146
public static final String SPANNER_RESOURCE_TYPE = "spanner_instance_client";
121147

122148
public static final AttributeKey<String> PROJECT_ID_KEY = AttributeKey.stringKey("project_id");
@@ -215,6 +241,7 @@ static Map<InstrumentSelector, View> getAllViews() {
215241
"1");
216242
defineSpannerView(views);
217243
defineGRPCView(views);
244+
defineGrpcGcpView(views);
218245
return views.build();
219246
}
220247

@@ -281,4 +308,31 @@ private static void defineGRPCView(ImmutableMap.Builder<InstrumentSelector, View
281308
viewMap.put(selector, view);
282309
}
283310
}
311+
312+
private static void defineGrpcGcpView(ImmutableMap.Builder<InstrumentSelector, View> viewMap) {
313+
for (String metric : GRPC_GCP_METRICS_TO_ENABLE) {
314+
InstrumentSelector selector =
315+
InstrumentSelector.builder()
316+
.setName(metric)
317+
.setMeterName(BuiltInMetricsConstant.GRPC_GCP_METER_NAME)
318+
.build();
319+
320+
Set<String> attributesFilter =
321+
BuiltInMetricsConstant.COMMON_ATTRIBUTES.stream()
322+
.map(AttributeKey::getKey)
323+
.collect(Collectors.toSet());
324+
325+
attributesFilter.addAll(
326+
GRPC_GCP_METRIC_ADDITIONAL_ATTRIBUTES.getOrDefault(metric, ImmutableSet.of()));
327+
328+
View view =
329+
View.builder()
330+
.setName(BuiltInMetricsConstant.METER_NAME + '/' + metric.replace(".", "/"))
331+
.setAggregation(Aggregation.sum())
332+
.setAttributeFilter(attributesFilter)
333+
.build();
334+
335+
viewMap.put(selector, view);
336+
}
337+
}
284338
}

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerCloudMonitoringExporterUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static com.google.api.MetricDescriptor.ValueType.INT64;
2525
import static com.google.cloud.spanner.BuiltInMetricsConstant.ALLOWED_EXEMPLARS_ATTRIBUTES;
2626
import static com.google.cloud.spanner.BuiltInMetricsConstant.GAX_METER_NAME;
27+
import static com.google.cloud.spanner.BuiltInMetricsConstant.GRPC_GCP_METER_NAME;
2728
import static com.google.cloud.spanner.BuiltInMetricsConstant.GRPC_METER_NAME;
2829
import static com.google.cloud.spanner.BuiltInMetricsConstant.PROJECT_ID_KEY;
2930
import static com.google.cloud.spanner.BuiltInMetricsConstant.SPANNER_METER_NAME;
@@ -86,7 +87,8 @@ static List<TimeSeries> convertToSpannerTimeSeries(
8687
// Get metrics data from GAX library, GRPC library and Spanner library
8788
if (!(metricData.getInstrumentationScopeInfo().getName().equals(GAX_METER_NAME)
8889
|| metricData.getInstrumentationScopeInfo().getName().equals(SPANNER_METER_NAME)
89-
|| metricData.getInstrumentationScopeInfo().getName().equals(GRPC_METER_NAME))) {
90+
|| metricData.getInstrumentationScopeInfo().getName().equals(GRPC_METER_NAME)
91+
|| metricData.getInstrumentationScopeInfo().getName().equals(GRPC_GCP_METER_NAME))) {
9092
// Filter out metric data for instruments that are not part of the spanner metrics list
9193
continue;
9294
}

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,6 +2380,13 @@ public ApiTracerFactory getApiTracerFactory() {
23802380
return createApiTracerFactory(false, false);
23812381
}
23822382

2383+
/** Returns the internal OpenTelemetry instance used for built-in metrics. */
2384+
@InternalApi
2385+
public OpenTelemetry getBuiltInOpenTelemetry() {
2386+
return this.builtInMetricsProvider.getOrCreateOpenTelemetry(
2387+
this.getProjectId(), getCredentials(), this.monitoringHost, getUniverseDomain());
2388+
}
2389+
23832390
public void enablegRPCMetrics(InstantiatingGrpcChannelProvider.Builder channelProviderBuilder) {
23842391
if (SpannerOptions.environment.isEnableGRPCBuiltInMetrics()) {
23852392
this.builtInMetricsProvider.enableGrpcMetrics(

google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
import io.grpc.ManagedChannelBuilder;
202202
import io.grpc.MethodDescriptor;
203203
import io.grpc.auth.MoreCallCredentials;
204+
import io.opentelemetry.api.OpenTelemetry;
204205
import java.io.IOException;
205206
import java.io.UnsupportedEncodingException;
206207
import java.net.URLDecoder;
@@ -567,6 +568,17 @@ GcpFallbackChannelOptions createFallbackChannelOptions(
567568
.build();
568569
}
569570

571+
@VisibleForTesting
572+
OpenTelemetry getFallbackOpenTelemetry(SpannerOptions options) {
573+
if (options.isEnableBuiltInMetrics()) {
574+
OpenTelemetry builtInOtel = options.getBuiltInOpenTelemetry();
575+
if (builtInOtel != null) {
576+
return builtInOtel;
577+
}
578+
}
579+
return OpenTelemetry.noop();
580+
}
581+
570582
private static KeyAwareChannel extractKeyAwareChannel(TransportChannel transportChannel) {
571583
if (transportChannel instanceof GrpcTransportChannel) {
572584
Channel channel = ((GrpcTransportChannel) transportChannel).getChannel();
@@ -671,7 +683,7 @@ public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
671683

672684
GcpFallbackOpenTelemetry fallbackTelemetry =
673685
GcpFallbackOpenTelemetry.newBuilder()
674-
.withSdk(options.getOpenTelemetry())
686+
.withSdk(getFallbackOpenTelemetry(options))
675687
.disableAllMetrics()
676688
.enableMetrics(Arrays.asList("fallback_count", "call_status"))
677689
.build();

google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpcTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,11 @@ public TestableGapicSpannerRpc(SpannerOptions options) {
11361136
super(options);
11371137
}
11381138

1139+
@Override
1140+
OpenTelemetry getFallbackOpenTelemetry(SpannerOptions options) {
1141+
return options.getOpenTelemetry();
1142+
}
1143+
11391144
@Override
11401145
GcpFallbackChannelOptions createFallbackChannelOptions(
11411146
GcpFallbackOpenTelemetry fallbackTelemetry, int minFailedCalls) {
@@ -1222,6 +1227,11 @@ public TestableGapicSpannerRpcWithLowerMinFailedCalls(SpannerOptions options) {
12221227
super(options);
12231228
}
12241229

1230+
@Override
1231+
OpenTelemetry getFallbackOpenTelemetry(SpannerOptions options) {
1232+
return options.getOpenTelemetry();
1233+
}
1234+
12251235
@Override
12261236
GcpFallbackChannelOptions createFallbackChannelOptions(
12271237
GcpFallbackOpenTelemetry fallbackTelemetry, int minFailedCalls) {

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>com.google.cloud</groupId>
1616
<artifactId>sdk-platform-java-config</artifactId>
17-
<version>3.57.0</version>
17+
<version>3.58.0</version>
1818
</parent>
1919

2020
<developers>

samples/snippets/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<dependency>
3535
<groupId>com.google.cloud</groupId>
3636
<artifactId>libraries-bom</artifactId>
37-
<version>26.76.0</version>
37+
<version>26.78.0</version>
3838
<type>pom</type>
3939
<scope>import</scope>
4040
</dependency>

0 commit comments

Comments
 (0)