@@ -49,6 +49,7 @@ import (
4949const (
5050 builtInMetricsMeterName = "gax-go"
5151 grpcMetricMeterName = "grpc-go"
52+ grpcGcpMetricMeterName = "grpc-gcp-go"
5253
5354 nativeMetricsPrefix = "spanner.googleapis.com/internal/client/"
5455
@@ -73,6 +74,10 @@ const (
7374 metricLabelKeyGRPCLBLocality = "grpc.lb.locality"
7475 metricLabelKeyGRPCLBBackendService = "grpc.lb.backend_service"
7576 metricLabelKeyGRPCDisconnectError = "grpc.disconnect_error"
77+ metricLabelKeyFromChannelName = "from_channel_name"
78+ metricLabelKeyToChannelName = "to_channel_name"
79+ metricLabelKeyChannelName = "channel_name"
80+ metricLabelKeyStatusCode = "status_code"
7681
7782 // Metric names
7883 metricNameOperationLatencies = "operation_latencies"
@@ -83,6 +88,8 @@ const (
8388 metricNameGFELatencies = "gfe_latencies"
8489 metricNameGFEConnectivityErrorCount = "gfe_connectivity_error_count"
8590 metricNameAFEConnectivityErrorCount = "afe_connectivity_error_count"
91+ metricNameEEFFallbackCount = "eef.fallback_count"
92+ metricNameEEFCallStatus = "eef.call_status"
8693
8794 // Metric units
8895 metricUnitMS = "ms"
@@ -273,6 +280,8 @@ type builtinMetricsTracerFactory struct {
273280 afeErrorCount metric.Int64Counter // Counter for the number of requests that failed to reach the Spanner API Frontend.
274281 operationCount metric.Int64Counter // Counter for the number of operations.
275282 attemptCount metric.Int64Counter // Counter for the number of attempts.
283+
284+ meterProvider metric.MeterProvider
276285}
277286
278287func newBuiltinMetricsTracerFactory (ctx context.Context , dbpath , compression string , isAFEBuiltInMetricEnabled , isEnableGRPCBuiltInMetrics bool , metricsProvider metric.MeterProvider , opts ... option.ClientOption ) (* builtinMetricsTracerFactory , error ) {
@@ -311,6 +320,7 @@ func newBuiltinMetricsTracerFactory(ctx context.Context, dbpath, compression str
311320 return tracerFactory , err
312321 }
313322 meterProvider = sdkmetric .NewMeterProvider (mpOptions ... )
323+ tracerFactory .meterProvider = meterProvider
314324
315325 if isEnableGRPCBuiltInMetrics {
316326 mo := opentelemetry.MetricsOptions {
@@ -373,6 +383,36 @@ func builtInMeterProviderOptions(project, compression string, clientAttributes [
373383 },
374384 ))
375385 }
386+ skippedEEFMetrics := []string {
387+ "eef.probe_result" ,
388+ "eef.error_ratio" ,
389+ "eef.current_channel" ,
390+ "eef.channel_downtime" ,
391+ }
392+ for _ , m := range skippedEEFMetrics {
393+ views = append (views , sdkmetric .NewView (
394+ sdkmetric.Instrument {Name : m },
395+ sdkmetric.Stream {Aggregation : sdkmetric.AggregationDrop {}},
396+ ))
397+ }
398+ eefMetricsToEnable := []string {
399+ metricNameEEFFallbackCount ,
400+ metricNameEEFCallStatus ,
401+ }
402+ for _ , m := range eefMetricsToEnable {
403+ views = append (views , sdkmetric .NewView (
404+ sdkmetric.Instrument {Name : m },
405+ sdkmetric.Stream {
406+ Aggregation : sdkmetric.AggregationSum {},
407+ AttributeFilter : func (kv attribute.KeyValue ) bool {
408+ if _ , ok := allowedEEFMetricLabels [string (kv .Key )]; ok {
409+ return true
410+ }
411+ return false
412+ },
413+ },
414+ ))
415+ }
376416 return []sdkmetric.Option {sdkmetric .WithReader (
377417 sdkmetric .NewPeriodicReader (
378418 defaultExporter ,
0 commit comments