googleapis / java-spanner

Apache License 2.0
64 stars 114 forks source link

docs: fix tracing sample to exit when completed, and use custom monitored resource for export #3287

Closed rahul2393 closed 1 week ago

rahul2393 commented 2 months ago

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 # ☕️

If you write sample code, please follow the samples format.

rahul2393 commented 2 months ago

TracingSample was not using project_id set via GOOGLE_CLOUD_PROJECT and will use metadata API request to set project on default MetricResource, which causes exception in exporting stats. Reference a) https://github.com/census-instrumentation/opencensus-java/blob/master/exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverExportUtils.java#L495-L497 b) https://github.com/googleapis/sdk-platform-java/blob/main/java-core/google-cloud-core/src/main/java/com/google/cloud/MetadataConfig.java#L42 c) https://github.com/googleapis/sdk-platform-java/blob/main/java-core/google-cloud-core/src/main/java/com/google/cloud/MetadataConfig.java#L71-L82