Skip to content

Commit

Permalink
example-orca: fix lost streamTracerFactor (#9411)
Browse files Browse the repository at this point in the history
  • Loading branch information
YifeiZhuang committed Jul 28, 2022
1 parent c7f0965 commit 80dc067
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Expand Up @@ -124,16 +124,24 @@ public LoadBalancer.PickResult pickSubchannel(LoadBalancer.PickSubchannelArgs ar
return result;
}
// Installs ORCA per-query metrics reporting listener.
return LoadBalancer.PickResult.withSubchannel(
result.getSubchannel(),
OrcaPerRequestUtil.getInstance().newOrcaClientStreamTracerFactory(
new OrcaPerRequestUtil.OrcaPerRequestReportListener() {
@Override
public void onLoadReport(MetricReport orcaLoadReport) {
System.out.println("Example load balancer received per-rpc metrics report:\n"
+ orcaLoadReport);
}
}));
final OrcaPerRequestUtil.OrcaPerRequestReportListener orcaListener =
new OrcaPerRequestUtil.OrcaPerRequestReportListener() {
@Override
public void onLoadReport(MetricReport orcaLoadReport) {
System.out.println("Example load balancer received per-rpc metrics report:\n"
+ orcaLoadReport);
}
};
if (result.getStreamTracerFactory() == null) {
return LoadBalancer.PickResult.withSubchannel(
result.getSubchannel(),
OrcaPerRequestUtil.getInstance().newOrcaClientStreamTracerFactory(orcaListener));
} else {
return LoadBalancer.PickResult.withSubchannel(
result.getSubchannel(),
OrcaPerRequestUtil.getInstance().newOrcaClientStreamTracerFactory(
result.getStreamTracerFactory(), orcaListener));
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions services/BUILD.bazel
Expand Up @@ -43,6 +43,7 @@ java_library(
"//api",
"//context",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_errorprone_error_prone_annotations//jar",
"@com_google_guava_guava//jar",
],
)
Expand Down

0 comments on commit 80dc067

Please sign in to comment.