-
Notifications
You must be signed in to change notification settings - Fork 88
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
base: main
Are you sure you want to change the base?
Conversation
…ptor pulls target from GRPC response header.
@igorbernstein2 PTAL! |
...table/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettings.java
Show resolved
Hide resolved
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.internal.StringUtils; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-
...table/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracer.java
Outdated
Show resolved
Hide resolved
@@ -17,6 +17,7 @@ | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
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
google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/Util.java
Outdated
Show resolved
Hide resolved
// Record gfe metrics | ||
tracer.recordGfeMetadata(latency, throwable); | ||
if (responseMetadata.getMetadata() != null) { | ||
Metadata.Key<String> remoteAddressKey = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
who sets this metadata?
...le/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTestUtils.java
Outdated
Show resolved
Hide resolved
...table/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracer.java
Outdated
Show resolved
Hide resolved
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()) { |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
Line 61 in 7247c32
BigtableDataSettings.newBuilderForEmulator(server.getPort()) |
@@ -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"; |
There was a problem hiding this comment.
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
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.