Skip to content

Add new target attribute to attempts and operation attributes#2260

Closed
meeral-k wants to merge 19 commits intogoogleapis:mainfrom
meeral-k:b333386278
Closed

Add new target attribute to attempts and operation attributes#2260
meeral-k wants to merge 19 commits intogoogleapis:mainfrom
meeral-k:b333386278

Conversation

@meeral-k
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

@igorbernstein2 PTAL!

import com.google.common.math.IntMath;
import io.grpc.CallOptions;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.internal.StringUtils;
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.


import com.google.api.gax.tracing.ApiTracer;
import com.google.common.collect.ImmutableList;
import io.opentelemetry.api.internal.StringUtils;
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.

same as above

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.

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
Copy Markdown
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
Copy Markdown
Contributor Author

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


managedChannelBuilder.intercept(errorCountPerConnectionMetricTracker.getInterceptor());

if(settings.getIsDirectpath()) {
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.

why only directpath?


featureFlags =
FeatureFlags.newBuilder().setReverseScans(true).setLastScannedRowResponses(true);
isDirectpath = Boolean.parseBoolean(System.getenv(CBT_ENABLE_DIRECTPATH));
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.

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

recordAttemptCompletion(null);
}

public void addTarget(String target) {
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.

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


private Long serverLatencies = null;

private String target_endpoint = "unspecified";
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.

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

private final List<BindableService> services = new ArrayList<>();
private final List<ServerTransportFilter> transportFilters = new ArrayList<>();

private int serverPort = 0;
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.

you can already get this from the returned server?

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
Copy Markdown
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