FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(bigtable): add handling for gauge metrics by sushanb · Pull Request #2719 · googleapis/java-bigtable · GitHub

This repository was archived by the owner on May 8, 2026. It is now read-only.
/ java-bigtable Public archive
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cfg  (3) .java  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion .kokoro/presubmit/graalvm-native-a.cfg
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
Expand Up @@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.53.0" # {x-version-update:google-cloud-shared-dependencies:current}
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.54.1" # {x-version-update:google-cloud-shared-dependencies:current}
}

env_vars: {
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/presubmit/graalvm-native-b.cfg
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
Expand Up @@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.53.0" # {x-version-update:google-cloud-shared-dependencies:current}
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.54.1" # {x-version-update:google-cloud-shared-dependencies:current}
}

env_vars: {
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/presubmit/graalvm-native-c.cfg
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
Expand Up @@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_c:3.53.0" # {x-version-update:google-cloud-shared-dependencies:current}
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_c:3.54.1" # {x-version-update:google-cloud-shared-dependencies:current}
}

env_vars: {
Expand Down
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
Expand Up @@ -54,6 +54,7 @@
import com.google.monitoring.v3.TimeInterval;
import com.google.monitoring.v3.TimeSeries;
import com.google.monitoring.v3.TypedValue;
import com.google.protobuf.Timestamp;
import com.google.protobuf.util.Timestamps;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
Expand Down Expand Up @@ -281,11 +282,19 @@ private static TimeSeries convertPointToBigtableTimeSeries(
metricBuilder.putLabels(CLIENT_UID_KEY.getKey(), taskId);
builder.setMetric(metricBuilder.build());

MetricKind kind = convertMetricKind(metricData);

Timestamp endTimestamp = Timestamps.fromNanos(pointData.getEpochNanos());
Timestamp startTimestamp;

if (kind == GAUGE) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

nit: can we extract this to a helper method? handleGaugeMetric() or somehing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

FYI, this won't remain very long in 2 versions as we will move all metrics to cloud.BigtableClient schema. so let's put it here for now temporarily.

// GAUGE metrics must have start_time equal to end_time.
startTimestamp = endTimestamp;
} else {
startTimestamp = Timestamps.fromNanos(pointData.getStartEpochNanos());
}
TimeInterval timeInterval =
TimeInterval.newBuilder()
.setStartTime(Timestamps.fromNanos(pointData.getStartEpochNanos()))
.setEndTime(Timestamps.fromNanos(pointData.getEpochNanos()))
.build();
TimeInterval.newBuilder().setStartTime(startTimestamp).setEndTime(endTimestamp).build();

builder.addPoints(createPoint(metricData.getType(), pointData, timeInterval));

Expand All @@ -294,9 +303,10 @@ private static TimeSeries convertPointToBigtableTimeSeries(

private static Optional<TimeSeries> createInternalMetricsTimeSeries(
MetricData metricData, PointData pointData, MonitoredResource applicationResource) {
MetricKind kind = convertMetricKind(metricData);
TimeSeries.Builder builder =
TimeSeries.newBuilder()
.setMetricKind(convertMetricKind(metricData))
.setMetricKind(kind)
.setValueType(convertValueType(metricData.getType()))
.setResource(applicationResource);

Expand All @@ -318,11 +328,15 @@ private static Optional<TimeSeries> createInternalMetricsTimeSeries(

builder.setMetric(metricBuilder.build());

Timestamp endTimestamp = Timestamps.fromNanos(pointData.getEpochNanos());
Timestamp startTimestamp;
if (kind == GAUGE) {
startTimestamp = endTimestamp;
} else {
startTimestamp = Timestamps.fromNanos(pointData.getStartEpochNanos());
}
TimeInterval timeInterval =
TimeInterval.newBuilder()
.setStartTime(Timestamps.fromNanos(pointData.getStartEpochNanos()))
.setEndTime(Timestamps.fromNanos(pointData.getEpochNanos()))
.build();
TimeInterval.newBuilder().setStartTime(startTimestamp).setEndTime(endTimestamp).build();

builder.addPoints(createPoint(metricData.getType(), pointData, timeInterval));
return Optional.of(builder.build());
Expand Down
Loading

Back | FazBrowse Home | New Git URL