-
Notifications
You must be signed in to change notification settings - Fork 72
chore: tracing implementation in GAPICs POC #4094
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
base: main
Are you sure you want to change the base?
Changes from all commits
e01ca06
d3f61d1
cf98e86
523c301
d9534bd
196d591
ea075d3
2997153
2c26971
1a76c29
8a0f855
dc3ed42
5287f82
ce2d85b
d6341cc
a9c70ab
69a7fa4
a6716b4
99bfd5b
7b5709b
6259b86
61c1671
069bc77
f5f94d8
64685b5
7869ed9
5218acb
7686f7f
af882ca
7575f5c
7d98fcc
24f7fc5
cee4ad5
7aa0ea5
7f90d28
d0b2eb3
ce9df43
b063a8d
5da1d58
8ffb32a
e3b2cda
92d56e7
5082240
e8d98b0
87a3f8c
20461c1
40b74bd
d1967f7
f626d4b
e9fe905
09d1539
a240c29
2334254
3b8b665
974ea10
502ef29
9461fd1
d786485
33f346f
90fdcc5
990af89
5a11e8a
e42b2a0
bed4a65
17743d1
1801667
3dc0f7a
bfd68be
b501f2a
421abc9
fc22be3
7fc007c
ab19aab
a9db790
d969089
d59a108
339fa92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ | |
| import com.google.api.gax.rpc.internal.QuotaProjectIdHidingCredentials; | ||
| import com.google.api.gax.tracing.ApiTracerFactory; | ||
| import com.google.api.gax.tracing.BaseApiTracerFactory; | ||
| import com.google.api.gax.tracing.OpenTelemetryTracingTracer; | ||
| import com.google.auth.ApiKeyCredentials; | ||
| import com.google.auth.CredentialTypeForMetrics; | ||
| import com.google.auth.Credentials; | ||
|
|
@@ -270,6 +271,25 @@ public static ClientContext create(StubSettings settings) throws IOException { | |
| backgroundResources.add(watchdog); | ||
| } | ||
|
|
||
| ApiTracerFactory tracerFactory = settings.getTracerFactory(); | ||
| if (tracerFactory != null) { | ||
| String rpcSystem = ""; | ||
| if ("grpc".equals(transportChannel.getTransportName())) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic would likely be better in the tracer factory constructor. |
||
| rpcSystem = "grpc"; | ||
| } else if ("httpjson".equals(transportChannel.getTransportName())) { | ||
| rpcSystem = "http"; | ||
| } | ||
|
|
||
| tracerFactory = | ||
| tracerFactory.withAttributes( | ||
| ImmutableMap.of(), | ||
| ImmutableMap.of( | ||
| OpenTelemetryTracingTracer.SERVER_ADDRESS_ATTRIBUTE, settings.getServerAddress(), | ||
| OpenTelemetryTracingTracer.SERVICE_NAME_ATTRIBUTE, settings.getServiceName(), | ||
| OpenTelemetryTracingTracer.PORT_ATTRIBUTE, String.valueOf(settings.getPort()), | ||
| OpenTelemetryTracingTracer.RPC_SYSTEM_ATTRIBUTE, rpcSystem)); | ||
| } | ||
|
|
||
| return newBuilder() | ||
| .setBackgroundResources(backgroundResources.build()) | ||
| .setExecutor(backgroundExecutor) | ||
|
|
@@ -284,7 +304,7 @@ public static ClientContext create(StubSettings settings) throws IOException { | |
| .setQuotaProjectId(settings.getQuotaProjectId()) | ||
| .setStreamWatchdog(watchdog) | ||
| .setStreamWatchdogCheckIntervalDuration(settings.getStreamWatchdogCheckIntervalDuration()) | ||
| .setTracerFactory(settings.getTracerFactory()) | ||
| .setTracerFactory(tracerFactory) | ||
| .setEndpointContext(endpointContext) | ||
| .build(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,6 +105,13 @@ public final String getEndpoint() { | |
| return stubSettings.getEndpoint(); | ||
| } | ||
|
|
||
| /** | ||
| * @return the fully resolved port used by the client | ||
| */ | ||
| public final int getPort() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great if we can get these without exposing new public methods, but we can think about it later. |
||
| return stubSettings.getPort(); | ||
| } | ||
|
|
||
| public final String getQuotaProjectId() { | ||
| return stubSettings.getQuotaProjectId(); | ||
| } | ||
|
|
||
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.
I decided to enforce this input.