Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new target attribute to attempts and operation attributes #2260

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

meeral-k
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Rollback plan is reviewed and LGTMed
  • All new data plane features have a completed end to end testing plan

Fixes #<issue_number_goes_here> ☕️

If you write sample code, please follow the samples format.

@meeral-k
Copy link
Contributor Author

@igorbernstein2 PTAL!

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.internal.StringUtils;
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -17,6 +17,7 @@

import com.google.api.gax.tracing.ApiTracer;
import com.google.common.collect.ImmutableList;
import io.opentelemetry.api.internal.StringUtils;
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

Copy link
Contributor

Choose a reason for hiding this comment

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

did you forget to push? its still present

// Record gfe metrics
tracer.recordGfeMetadata(latency, throwable);
if (responseMetadata.getMetadata() != null) {
Metadata.Key<String> remoteAddressKey =
Copy link
Contributor

Choose a reason for hiding this comment

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

who sets this metadata?

@product-auto-label product-auto-label bot added the api: bigtable Issues related to the googleapis/java-bigtable API. label Jun 14, 2024
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Jun 20, 2024
@meeral-k
Copy link
Contributor Author

Addressed all comments, changed implementation to use interceptor with injected api tracer to add target directly.

@@ -275,7 +276,9 @@ public static ClientContext createClientContext(EnhancedBigtableStubSettings set
}

managedChannelBuilder.intercept(errorCountPerConnectionMetricTracker.getInterceptor());

if(settings.getIsDirectpath()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why only directpath?

@@ -777,6 +794,7 @@ private Builder() {

featureFlags =
FeatureFlags.newBuilder().setReverseScans(true).setLastScannedRowResponses(true);
isDirectpath = Boolean.parseBoolean(System.getenv(CBT_ENABLE_DIRECTPATH));
Copy link
Contributor

Choose a reason for hiding this comment

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

please dont access env vars from multiple places...there should be one place converts the env var into an instance variables in settings and then everything should reference the instance var/getter

@@ -175,6 +179,12 @@ public void attemptSucceeded() {
recordAttemptCompletion(null);
}

public void addTarget(String target) {
Copy link
Contributor

Choose a reason for hiding this comment

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

setAttemptTarget - there should only be a single target per attempt ... add implies there are multiple targets

@@ -85,6 +87,8 @@ class BuiltinMetricsTracer extends BigtableTracer {

private Long serverLatencies = null;

private String target_endpoint = "unspecified";
Copy link
Contributor

Choose a reason for hiding this comment

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

does this need to be volatile? please check that the thread that sets the target is the same as the thread that reads it

attemptLatenciesHistogram.record(
convertToMs(attemptTimer.elapsed(TimeUnit.NANOSECONDS)), attributes);
convertToMs(attemptTimer.elapsed(TimeUnit.NANOSECONDS)), attributes.toBuilder().put(TARGET_KEY,target_endpoint).build());
Copy link
Contributor

Choose a reason for hiding this comment

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

please reformat this line to make it easier to see that you are modifying the attribtues. Ideally split it up into 2 statements the first having a comment that attempt latency metrics differ from others to include the destination

((BuiltinMetricsTracer)bigtableTracer).addTarget(String.valueOf(remoteAddr));
}
} catch (Throwable t) {
LOG.log(
Copy link
Contributor

Choose a reason for hiding this comment

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

do you really want to log for every RPC?

if(bigtableTracer instanceof BuiltinMetricsTracer) {
((BuiltinMetricsTracer)bigtableTracer).addTarget(String.valueOf(remoteAddr));
}
} catch (Throwable t) {
Copy link
Contributor

Choose a reason for hiding this comment

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

java java interrupted exceptions require special handling

}
} catch (Throwable t) {
LOG.log(
Level.WARNING, "Unexpected error while updating target label", t);
Copy link
Contributor

Choose a reason for hiding this comment

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

customers will be the ones to see this message and the will have no idea what it means. PLease udpate the message so someone else can understand what it means, what its implications are

@@ -31,6 +31,7 @@ public class FakeServiceBuilder {
private final List<BindableService> services = new ArrayList<>();
private final List<ServerTransportFilter> transportFilters = new ArrayList<>();

private int serverPort = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

you can already get this from the returned server?

@@ -129,6 +131,7 @@ public class BuiltinMetricsTracerTest {
private static final long SERVER_LATENCY = 100;
private static final long APPLICATION_LATENCY = 200;
private static final long SLEEP_VARIABILITY = 15;
private static final String TARGET_ENDPOINT_VALUE_FORMAT = "localhost/127.0.0.1:%s";
Copy link
Contributor

Choose a reason for hiding this comment

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

This is pretty brittle and will fail on ipv6 machines that run tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the googleapis/java-bigtable API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants