Skip to content

Commit 0efdfa4

Browse files
committed
remove logs
1 parent d865a41 commit 0efdfa4

File tree

3 files changed

+5
-40
lines changed

3 files changed

+5
-40
lines changed

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.util.Map;
3131
import java.util.Set;
3232
import java.util.stream.Collectors;
33-
import java.util.stream.Stream;
3433

3534
@InternalApi
3635
public class BuiltInMetricsConstant {
@@ -54,18 +53,6 @@ public class BuiltInMetricsConstant {
5453
"grpc.xds_client.server_failure",
5554
"grpc.xds_client.resource_updates_invalid");
5655

57-
public static final Set<String> SPANNER_METRICS =
58-
Stream.concat(
59-
Stream.of(
60-
OPERATION_LATENCIES_NAME,
61-
ATTEMPT_LATENCIES_NAME,
62-
OPERATION_COUNT_NAME,
63-
ATTEMPT_COUNT_NAME,
64-
GFE_LATENCIES_NAME),
65-
GRPC_METRICS_TO_ENABLE.stream())
66-
.map(m -> METER_NAME + '/' + m)
67-
.collect(Collectors.toSet());
68-
6956
public static final String SPANNER_RESOURCE_TYPE = "spanner_instance_client";
7057

7158
public static final AttributeKey<String> PROJECT_ID_KEY = AttributeKey.stringKey("project_id");

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

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,6 @@ static SpannerCloudMonitoringExporter create(
103103

104104
@Override
105105
public CompletableResultCode export(@Nonnull Collection<MetricData> collection) {
106-
// TODO: Remove
107-
collection.stream()
108-
.filter(md -> "grpc-java".equals(md.getInstrumentationScopeInfo().getName()))
109-
.forEach(
110-
md -> {
111-
System.out.println("Name: " + md.getName()); // Print the name
112-
113-
md.getData()
114-
.getPoints()
115-
.forEach(
116-
point -> {
117-
System.out.println(
118-
"Attributes: "
119-
+ point.getAttributes()); // Print attributes for each point
120-
});
121-
122-
System.out.println("----------------------"); // Separator for readability
123-
});
124-
125106
if (client.isShutdown()) {
126107
logger.log(Level.WARNING, "Exporter is shut down");
127108
return CompletableResultCode.ofFailure();
@@ -133,10 +114,7 @@ public CompletableResultCode export(@Nonnull Collection<MetricData> collection)
133114
/** Export client built in metrics */
134115
private CompletableResultCode exportSpannerClientMetrics(Collection<MetricData> collection) {
135116
// Filter spanner metrics. Only include metrics that contain a project and instance ID.
136-
List<MetricData> spannerMetricData =
137-
collection.stream()
138-
// .filter(md -> SPANNER_METRICS.contains(md.getName()))
139-
.collect(Collectors.toList());
117+
List<MetricData> spannerMetricData = collection.stream().collect(Collectors.toList());
140118

141119
// Log warnings for metrics that will be skipped.
142120
boolean mustFilter = false;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,11 @@ static List<TimeSeries> convertToSpannerTimeSeries(List<MetricData> collection)
7878
List<TimeSeries> allTimeSeries = new ArrayList<>();
7979

8080
for (MetricData metricData : collection) {
81-
// Get metrics data from GAX library and Spanner library
81+
// Get metrics data from GAX library, GRPC library and Spanner library
8282
if (!(metricData.getInstrumentationScopeInfo().getName().equals(GAX_METER_NAME)
8383
|| metricData.getInstrumentationScopeInfo().getName().equals(SPANNER_METER_NAME)
8484
|| metricData.getInstrumentationScopeInfo().getName().equals(GRPC_METER_NAME))) {
8585
// Filter out metric data for instruments that are not part of the spanner metrics list
86-
System.out.println(
87-
"Skipped some data" + metricData.getInstrumentationScopeInfo().getName().toString());
8886
continue;
8987
}
9088

@@ -115,7 +113,6 @@ private static TimeSeries convertPointToSpannerTimeSeries(
115113
TimeSeries.newBuilder()
116114
.setMetricKind(convertMetricKind(metricData))
117115
.setValueType(convertValueType(metricData.getType()));
118-
System.out.println("convertPointToSpannerTimeSeries Metric name " + metricData.getName());
119116
Metric.Builder metricBuilder = Metric.newBuilder().setType(metricData.getName());
120117

121118
Attributes attributes = pointData.getAttributes();
@@ -124,11 +121,14 @@ private static TimeSeries convertPointToSpannerTimeSeries(
124121
if (SPANNER_PROMOTED_RESOURCE_LABELS.contains(key)) {
125122
monitoredResourceBuilder.putLabels(key.getKey(), String.valueOf(attributes.get(key)));
126123
} else {
124+
// Replace metric label names by converting "." to "_" since Cloud Monitoring does not
125+
// support labels containing "."
127126
metricBuilder.putLabels(
128127
key.getKey().replace(".", "_"), String.valueOf(attributes.get(key)));
129128
}
130129
}
131130

131+
// Add common labels like "client_name" and "client_uid" for all the exported metrics.
132132
metricBuilder.putAllLabels(BuiltInMetricsProvider.INSTANCE.createClientAttributes());
133133

134134
builder.setResource(monitoredResourceBuilder.build());

0 commit comments

Comments
 (0)