Skip to content

Commit 01108a5

Browse files
chore(core): deprecate OpenCensus support (#16448)
1 parent 4b333e9 commit 01108a5

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,32 @@ Modern clients are produced by a modern code generator, combined with hand-craft
7171

7272
The documentation for the particular Google service you are working with, may provide guidance regarding the preferred client library to use.
7373

74+
## Tracing
75+
76+
OpenCensus support with gems is now deprecated. Please migrate to using [OpenTelemetry](https://opentelemetry.io/docs/instrumentation/ruby/automatic/) instead. Currently instrumented span data from core gem can be got by enabling Http and HttpClient auto-instrumentation of OpenTelemetry. To enable instrumentation for HTTP and HttpClient, and export it to [Cloud Trace](https://cloud.google.com/trace) configure OpenTelemetry like below,
77+
78+
```ruby
79+
gem "opentelemetry-sdk"
80+
gem "opentelemetry-exporter-google_cloud_trace"
81+
gem "opentelemetry-instrumentation-http"
82+
gem "opentelemetry-instrumentation-http_client"
83+
84+
require "opentelemetry-sdk"
85+
require "opentelemetry/instrumentation/http_client"
86+
require "opentelemetry/instrumentation/http"
87+
require "opentelemetry/exporter/google_cloud_trace"
88+
OpenTelemetry::SDK.configure do |c|
89+
c.service_name = "ServiceName"
90+
c.add_span_processor(
91+
OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
92+
OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter.new
93+
)
94+
)
95+
c.use "OpenTelemetry::Instrumentation::Http"
96+
c.use "OpenTelemetry::Instrumentation::HttpClient"
97+
end
98+
```
99+
74100
## Samples
75101

76102
See the [samples](https://github.com/google/google-api-ruby-client/tree/main/samples) for examples on how to use the client library for various

google-apis-core/lib/google/apis/core/http_command.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ def initialize(method, url, body: nil)
8787
self.query = {}
8888
self.params = {}
8989
@opencensus_span = nil
90+
if OPENCENSUS_AVAILABLE
91+
logger.warn 'OpenCensus support is now deprecated. ' +
92+
'Please refer https://github.com/googleapis/google-api-ruby-client#tracing for migrating to use OpenTelemetry.'
93+
94+
end
9095
end
9196

9297
# Execute the command, retrying as necessary

0 commit comments

Comments
 (0)