Skip to content

Commit

Permalink
add comments and reorder ops
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul2393 committed Oct 25, 2024
1 parent fb30837 commit 37f88d0
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
* This sample demonstrates how to enable opencensus tracing and stats in cloud spanner client.
*
* @deprecated The OpenCensus project is deprecated. Use OpenTelemetry to enable metrics and stats
* with cloud spanner client.
* with cloud spanner client.
* <p>Note: This sample uses System.exit(0) to ensure clean termination due to OpenCensus
* background threads.
*/
public class TracingSample {

Expand Down Expand Up @@ -95,10 +97,18 @@ public static void main(String[] args) throws Exception {
}
}
} finally {
// Closes the client which will free up the resources used
spanner.close();
StackdriverExporter.unregister();
// First, shutdown the stats/metrics exporters
StackdriverStatsExporter.unregister();

// Shutdown tracing components
StackdriverExporter.unregister();
Tracing.getExportComponent().shutdown();

// Close the spanner client
spanner.close();

// Force immediate exit since this is a sample application and OpenCensus
// background threads might prevent clean shutdown
System.exit(0);
}
}
Expand Down

0 comments on commit 37f88d0

Please sign in to comment.