Add new target attribute to attempts and operation attributes#2260
Add new target attribute to attempts and operation attributes#2260meeral-k wants to merge 19 commits intogoogleapis:mainfrom
Conversation
…ptor pulls target from GRPC response header.
|
@igorbernstein2 PTAL! |
| import com.google.common.math.IntMath; | ||
| import io.grpc.CallOptions; | ||
| import io.opentelemetry.api.common.Attributes; | ||
| import io.opentelemetry.api.internal.StringUtils; |
There was a problem hiding this comment.
please dont use internals of other apis
You probably want:
https://guava.dev/releases/20.0/api/docs/com/google/common/base/Strings.html#isNullOrEmpty-java.lang.String-
|
|
||
| import com.google.api.gax.tracing.ApiTracer; | ||
| import com.google.common.collect.ImmutableList; | ||
| import io.opentelemetry.api.internal.StringUtils; |
There was a problem hiding this comment.
did you forget to push? its still present
| // Record gfe metrics | ||
| tracer.recordGfeMetadata(latency, throwable); | ||
| if (responseMetadata.getMetadata() != null) { | ||
| Metadata.Key<String> remoteAddressKey = |
There was a problem hiding this comment.
who sets this metadata?
|
Addressed all comments, changed implementation to use interceptor with injected api tracer to add target directly. |
|
|
||
| managedChannelBuilder.intercept(errorCountPerConnectionMetricTracker.getInterceptor()); | ||
|
|
||
| if(settings.getIsDirectpath()) { |
There was a problem hiding this comment.
why only directpath?
|
|
||
| featureFlags = | ||
| FeatureFlags.newBuilder().setReverseScans(true).setLastScannedRowResponses(true); | ||
| isDirectpath = Boolean.parseBoolean(System.getenv(CBT_ENABLE_DIRECTPATH)); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
do you really want to log for every RPC?
| if(bigtableTracer instanceof BuiltinMetricsTracer) { | ||
| ((BuiltinMetricsTracer)bigtableTracer).addTarget(String.valueOf(remoteAddr)); | ||
| } | ||
| } catch (Throwable t) { |
There was a problem hiding this comment.
java java interrupted exceptions require special handling
| } | ||
| } catch (Throwable t) { | ||
| LOG.log( | ||
| Level.WARNING, "Unexpected error while updating target label", t); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
This is pretty brittle and will fail on ipv6 machines that run tests
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:
Fixes #<issue_number_goes_here> ☕️
If you write sample code, please follow the samples format.