opentelemetry-exporter-google_cloud_trace 0.a → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +21 -0
- data/.yardopts +17 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +27 -0
- data/README.md +38 -8
- data/Rakefile +61 -0
- data/acceptance/sinatra/gcp_trace_exporter_test.rb +99 -0
- data/acceptance/sinatra/sinatra_app.rb +25 -0
- data/acceptance/test_helper.rb +25 -0
- data/lib/opentelemetry/exporter/google_cloud_trace/span_exporter.rb +145 -0
- data/lib/opentelemetry/exporter/google_cloud_trace/translator.rb +239 -0
- data/lib/opentelemetry/exporter/google_cloud_trace/version.rb +6 -3
- data/lib/opentelemetry/exporter/google_cloud_trace.rb +37 -0
- data/lib/opentelemetry-exporter-google_cloud_trace.rb +17 -0
- data/opentelemetry-exporter-google_cloud_trace.gemspec +60 -0
- metadata +252 -17
- data/LICENSE.md +0 -201
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 896a1567355cdf1e2f6daa30f1ca4acfa2e9053862a61f14c1a94c07a02c7993
|
4
|
+
data.tar.gz: e4c54cb48a88a8a2a525dd2bbeef8c716bc20beb91d67b49c367c82b7ba58bd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7336a9662a78da966767d1683019dbe1f804a1bcdf6f5da92e5189d4a4b034c3e30f34d76e52df2fd0e81137c2bbeeb52bf58a22d3b6cd34282ba8dcdb25c7cc
|
7
|
+
data.tar.gz: 586be672dd22def225b4dcf0137ec8e2530fd198fba56e9450471e6f219dcbd40f7c149d672ef0c9bb1f0841edb4a4e145deaf978510facdad7f72fb02f9d02d
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
google-style: google-style.yml
|
3
|
+
|
4
|
+
Metrics/BlockLength:
|
5
|
+
Enabled: true
|
6
|
+
Exclude:
|
7
|
+
- test/**/*
|
8
|
+
- opentelemetry-exporter-google_cloud_trace.gemspec
|
9
|
+
|
10
|
+
Style/PreferredHashMethods:
|
11
|
+
Enabled: true
|
12
|
+
Exclude:
|
13
|
+
- test/**/*
|
14
|
+
|
15
|
+
Metrics/ClassLength:
|
16
|
+
Exclude:
|
17
|
+
- "**/translator.rb"
|
18
|
+
|
19
|
+
Naming/FileName:
|
20
|
+
Exclude:
|
21
|
+
- "lib/opentelemetry-exporter-google_cloud_trace.rb"
|
data/.yardopts
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
--no-private
|
2
|
+
--title=OpenTelemetry Exporter Google Cloud Trace
|
3
|
+
--exclude _pb\.rb$
|
4
|
+
--markup markdown
|
5
|
+
--markup-provider redcarpet
|
6
|
+
--main OVERVIEW.md
|
7
|
+
|
8
|
+
./lib/**/*.rb
|
9
|
+
-
|
10
|
+
OVERVIEW.md
|
11
|
+
AUTHENTICATION.md
|
12
|
+
LOGGING.md
|
13
|
+
CONTRIBUTING.md
|
14
|
+
TROUBLESHOOTING.md
|
15
|
+
CHANGELOG.md
|
16
|
+
CODE_OF_CONDUCT.md
|
17
|
+
LICENSE
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2023 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
|
18
|
+
source "https://rubygems.org"
|
19
|
+
|
20
|
+
# Specify your gem's dependencies in opentelemetry-exporter-google_cloud_trace.gemspec
|
21
|
+
gemspec
|
22
|
+
|
23
|
+
gem "rake", "~> 13.0"
|
24
|
+
|
25
|
+
gem "minitest", "~> 5.0"
|
26
|
+
|
27
|
+
gem "rubocop", "~> 1.21"
|
data/README.md
CHANGED
@@ -1,8 +1,38 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
This is
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
# Opentelemetry Google Cloud Trace exporter
|
2
|
+
|
3
|
+
This library is an exporter for OpenTelemetry instrumentation which will help translate the spans into Google Cloud Trace understandable format and publish it to Trace service.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```sh
|
8
|
+
$ gem install opentelemetry-exporter-google_cloud_trace
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
TODO: Write usage instructions here
|
14
|
+
|
15
|
+
## Contributing
|
16
|
+
|
17
|
+
Contributions to this library are always welcome and highly encouraged.
|
18
|
+
|
19
|
+
See the {file:../docs/CONTRIBUTING.md Contributing Guide}
|
20
|
+
for more information on how to get started.
|
21
|
+
|
22
|
+
Please note that this project is released with a Contributor Code of Conduct. By
|
23
|
+
participating in this project you agree to abide by its terms.
|
24
|
+
See {file:../docs/CODE_OF_CONDUCT.md Code of Conduct}
|
25
|
+
for more information.
|
26
|
+
|
27
|
+
## License
|
28
|
+
|
29
|
+
This library is licensed under Apache 2.0. Full license text is available in
|
30
|
+
[LICENSE](../LICENSE).
|
31
|
+
|
32
|
+
## Support
|
33
|
+
|
34
|
+
Please [report bugs at the project on
|
35
|
+
Github](https://github.com/GoogleCloudPlatform/opentelemetry-operations-ruby/issues). Don't
|
36
|
+
hesitate to [ask
|
37
|
+
questions](http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby)
|
38
|
+
about the client or APIs on [StackOverflow](http://stackoverflow.com).
|
data/Rakefile
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2023 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
|
18
|
+
require "bundler/gem_tasks"
|
19
|
+
require "rake/testtask"
|
20
|
+
|
21
|
+
Rake::TestTask.new :test do |t|
|
22
|
+
t.libs << "test"
|
23
|
+
t.libs << "lib"
|
24
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
25
|
+
end
|
26
|
+
|
27
|
+
require "yard"
|
28
|
+
require "yard/rake/yardoc_task"
|
29
|
+
YARD::Rake::YardocTask.new do |y|
|
30
|
+
# y.options << "--fail-on-warning"
|
31
|
+
end
|
32
|
+
|
33
|
+
task :acceptance, :project, :keyfile do |_t, args|
|
34
|
+
project = args[:project]
|
35
|
+
project ||= ENV["TRACE_EXPORTER_TEST_PROJECT"] || ENV["GCLOUD_TEST_PROJECT"]
|
36
|
+
keyfile = args[:keyfile]
|
37
|
+
keyfile ||= ENV["TRACE_EXPORTER_TEST_KEYFILE"] || ENV["GCLOUD_TEST_KEYFILE"]
|
38
|
+
if keyfile
|
39
|
+
keyfile = File.read keyfile
|
40
|
+
end
|
41
|
+
if project.nil? || keyfile.nil?
|
42
|
+
raise "You must provide a project and keyfile. e.g. rake acceptance[test123, /path/to/keyfile.json] or " \
|
43
|
+
"TRACE_EXPORTER_TEST_PROJECT=test123 TRACE_EXPORTER_TEST_KEYFILE=/path/to/keyfile.json rake acceptance"
|
44
|
+
end
|
45
|
+
|
46
|
+
Rake::Task["acceptance:run"].invoke
|
47
|
+
end
|
48
|
+
|
49
|
+
namespace :acceptance do
|
50
|
+
Rake::TestTask.new :run do |t|
|
51
|
+
t.libs << "acceptance"
|
52
|
+
t.libs << "lib"
|
53
|
+
t.test_files = FileList["acceptance/**/*_test.rb"]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
require "rubocop/rake_task"
|
58
|
+
|
59
|
+
RuboCop::RakeTask.new
|
60
|
+
|
61
|
+
task default: [:test, :rubocop]
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2023 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require "test_helper"
|
18
|
+
require "webrick"
|
19
|
+
require "fileutils"
|
20
|
+
require "google/protobuf/well_known_types"
|
21
|
+
|
22
|
+
# Test the Sinatra server for the Cloud Scheduler sample.
|
23
|
+
describe "Opentelemety exporter for Google Cloud Trace" do
|
24
|
+
before :all do
|
25
|
+
@project_id = ENV["TRACE_EXPORTER_TEST_PROJECT"] || ENV["GCLOUD_TEST_PROJECT"]
|
26
|
+
Google::Cloud.configure do |config|
|
27
|
+
config.project_id = @project_id
|
28
|
+
config.credentials = ENV["TRACE_EXPORTER_TEST_KEYFILE"] || ENV["GCLOUD_TEST_KEYFILE"]
|
29
|
+
end
|
30
|
+
|
31
|
+
@pid = Process.spawn "bundle exec ruby acceptance/sinatra/sinatra_app.rb"
|
32
|
+
|
33
|
+
# wait for server to start
|
34
|
+
sleep 10
|
35
|
+
@trace_client = Google::Cloud::Trace::V1::TraceService::Client.new
|
36
|
+
end
|
37
|
+
|
38
|
+
after :all do
|
39
|
+
Process.kill "KILL", @pid
|
40
|
+
Process.wait2 @pid
|
41
|
+
end
|
42
|
+
|
43
|
+
it "test_returns_hello_world" do
|
44
|
+
uri = URI("http://127.0.0.1:4567")
|
45
|
+
start_time = Google::Protobuf::Timestamp.from_time Time.now
|
46
|
+
res = Net::HTTP.get uri
|
47
|
+
assert_match "Hello !", res
|
48
|
+
sleep 10 # wait for trace to be sent
|
49
|
+
end_time = Google::Protobuf::Timestamp.from_time Time.now
|
50
|
+
|
51
|
+
assert_trace start_time, end_time
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def assert_trace start_time, end_time
|
56
|
+
result = @trace_client.list_traces project_id: @project_id, start_time: start_time, end_time: end_time
|
57
|
+
traces = result.response.traces
|
58
|
+
test_span = nil
|
59
|
+
parent_span = nil
|
60
|
+
|
61
|
+
traces.each do |trace|
|
62
|
+
full_trace = @trace_client.get_trace project_id: @project_id, trace_id: trace.trace_id
|
63
|
+
full_trace.spans.each do |span|
|
64
|
+
if span.name === "test_span"
|
65
|
+
test_span = span
|
66
|
+
break
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
if test_span
|
71
|
+
parent_span = full_trace.spans.find { |span| span.span_id === test_span.parent_span_id }
|
72
|
+
break
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
assert_child_span test_span
|
77
|
+
assert_parent_span parent_span
|
78
|
+
end
|
79
|
+
|
80
|
+
def assert_child_span span
|
81
|
+
refute_nil span
|
82
|
+
assert_equal span.labels["span_attr"], "span_value"
|
83
|
+
end
|
84
|
+
|
85
|
+
def assert_parent_span span
|
86
|
+
refute_nil span
|
87
|
+
assert_equal span.kind, :RPC_SERVER
|
88
|
+
assert_equal span.name, "GET /"
|
89
|
+
assert_equal span.labels["g.co/agent"], "opentelemetry-ruby #{OpenTelemetry::SDK::VERSION};" \
|
90
|
+
"google-cloud-trace-exporter " \
|
91
|
+
"#{OpenTelemetry::Exporter::GoogleCloudTrace::VERSION}"
|
92
|
+
assert_equal span.labels["/http/client_protocol"], "http"
|
93
|
+
assert_equal span.labels["/http/status_code"], "200"
|
94
|
+
assert_equal span.labels["http.target"], "/"
|
95
|
+
assert_equal span.labels["/http/method"], "GET"
|
96
|
+
assert_equal span.labels["/http/host"], "127.0.0.1:4567"
|
97
|
+
assert_equal span.labels["/http/route"], "/"
|
98
|
+
assert_equal span.labels["/http/user_agent"], "Ruby"
|
99
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "sinatra"
|
2
|
+
require "opentelemetry-sdk"
|
3
|
+
require "opentelemetry/instrumentation/sinatra"
|
4
|
+
require "opentelemetry/instrumentation/rack"
|
5
|
+
require "opentelemetry/exporter/google_cloud_trace"
|
6
|
+
|
7
|
+
OpenTelemetry::SDK.configure do |c|
|
8
|
+
c.service_name = "test_app"
|
9
|
+
c.add_span_processor(
|
10
|
+
OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
|
11
|
+
OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter.new
|
12
|
+
)
|
13
|
+
)
|
14
|
+
c.use "OpenTelemetry::Instrumentation::Sinatra"
|
15
|
+
end
|
16
|
+
|
17
|
+
get "/" do
|
18
|
+
test_tracer = OpenTelemetry.tracer_provider.tracer "test_tracer"
|
19
|
+
span_to_link_from = OpenTelemetry::Trace.current_span
|
20
|
+
link = OpenTelemetry::Trace::Link.new(span_to_link_from.context, { "some.attribute" => 12 })
|
21
|
+
test_tracer.in_span "test_span", attributes: { "span_attr" => "span_value" }, links: [link] do |span|
|
22
|
+
span.add_event "Creating test span event!!", attributes: { "event_attr" => "event_value" }
|
23
|
+
end
|
24
|
+
"Hello !"
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2023 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
|
18
|
+
require "minitest/autorun"
|
19
|
+
require "minitest/focus"
|
20
|
+
require "minitest/hooks/default"
|
21
|
+
require "minitest/rg"
|
22
|
+
require "ostruct"
|
23
|
+
require "google/cloud"
|
24
|
+
require "google/cloud/trace/v1"
|
25
|
+
require "opentelemetry/exporter/google_cloud_trace"
|
@@ -0,0 +1,145 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2023 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
|
18
|
+
require "google/cloud/trace/v2/trace_service"
|
19
|
+
require "opentelemetry/exporter/google_cloud_trace/translator"
|
20
|
+
require "google/cloud/env"
|
21
|
+
|
22
|
+
module OpenTelemetry
|
23
|
+
module Exporter
|
24
|
+
module GoogleCloudTrace
|
25
|
+
##
|
26
|
+
# This provides an implementation of span exporter for Google Cloud Trace
|
27
|
+
# It will convert the Opentelemetry span data into Clould Trace spans
|
28
|
+
# and publish them to the Cloud trace service.
|
29
|
+
class SpanExporter
|
30
|
+
SUCCESS = OpenTelemetry::SDK::Trace::Export::SUCCESS
|
31
|
+
FAILURE = OpenTelemetry::SDK::Trace::Export::FAILURE
|
32
|
+
private_constant :SUCCESS, :FAILURE
|
33
|
+
|
34
|
+
|
35
|
+
##
|
36
|
+
# Creates a new object for google cloud trace
|
37
|
+
# opentelemetry span exporter. It creates client for
|
38
|
+
# Google cloud trace service to be used for publihing span.
|
39
|
+
#
|
40
|
+
#
|
41
|
+
# @param [String] project_id Project identifier for the Trace service
|
42
|
+
# you are connecting to. If not present, the default project for the
|
43
|
+
# credentials is used.
|
44
|
+
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
|
45
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
46
|
+
# Google::Auth::Credentials object.
|
47
|
+
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling
|
48
|
+
# the set of resources and operations that the connection can access.
|
49
|
+
# See [Using OAuth 2.0 to Access Google
|
50
|
+
# APIs](https://developers.google.com/identity/protocols/OAuth2).
|
51
|
+
#
|
52
|
+
# The default scope is:
|
53
|
+
#
|
54
|
+
# * `https://www.googleapis.com/auth/trace.append`
|
55
|
+
# @param [Numeric] timeout Default timeout to use in requests. Optional.
|
56
|
+
# @param [String] endpoint Override of the endpoint host name. Optional.
|
57
|
+
# If the param is nil, uses the default endpoint.
|
58
|
+
#
|
59
|
+
# @return [OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter]
|
60
|
+
#
|
61
|
+
# @example
|
62
|
+
# require 'opentelemetry/sdk'
|
63
|
+
# require 'opentelemetry/instrumentation/all'
|
64
|
+
# require 'opentelemetry/exporter/google_cloud_trace'
|
65
|
+
# OpenTelemetry::SDK.configure do |c|
|
66
|
+
# c.service_name = 'test_app'
|
67
|
+
# c.add_span_processor(
|
68
|
+
# OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
|
69
|
+
# OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter.new
|
70
|
+
# )
|
71
|
+
# )
|
72
|
+
# c.use_all() # enables all instrumentation!
|
73
|
+
# end
|
74
|
+
#
|
75
|
+
def initialize project_id: nil,
|
76
|
+
credentials: nil,
|
77
|
+
scope: nil,
|
78
|
+
timeout: nil,
|
79
|
+
endpoint: nil
|
80
|
+
|
81
|
+
@client = ::Google::Cloud::Trace::V2::TraceService::Client.new do |config|
|
82
|
+
config.project_id = project_id if project_id
|
83
|
+
config.credentials = credentials if credentials
|
84
|
+
config.scope = scope if scope
|
85
|
+
config.timeout = timeout if timeout
|
86
|
+
config.endpoint = endpoint if endpoint
|
87
|
+
end
|
88
|
+
@project_id = (project_id || default_project_id || credentials&.project_id)
|
89
|
+
@project_id = @project_id.to_s
|
90
|
+
raise ArgumentError, "project_id is missing" if @project_id.empty?
|
91
|
+
@shutdown = false
|
92
|
+
@translator = Translator.new @project_id
|
93
|
+
end
|
94
|
+
|
95
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
96
|
+
# timeout is needed to match Opentelemetry exporter interface
|
97
|
+
|
98
|
+
# Called to export sampled {OpenTelemetry::SDK::Trace::SpanData} structs.
|
99
|
+
#
|
100
|
+
# @param [Enumerable<OpenTelemetry::SDK::Trace::SpanData>] span_data the
|
101
|
+
# list of recorded {OpenTelemetry::SDK::Trace::SpanData} structs to be
|
102
|
+
# exported.
|
103
|
+
# @return [Integer] the result of the export.
|
104
|
+
def export span_data, timeout: nil
|
105
|
+
return FAILURE if @shutdown
|
106
|
+
|
107
|
+
begin
|
108
|
+
batch_request = @translator.create_batch span_data
|
109
|
+
@client.batch_write_spans batch_request
|
110
|
+
SUCCESS
|
111
|
+
rescue StandardError
|
112
|
+
FAILURE
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Called when {OpenTelemetry::SDK::Trace::TracerProvider#force_flush} is called, if
|
117
|
+
# this exporter is registered to a {OpenTelemetry::SDK::Trace::TracerProvider}
|
118
|
+
# object.
|
119
|
+
def force_flush timeout: nil
|
120
|
+
SUCCESS
|
121
|
+
end
|
122
|
+
|
123
|
+
# Called when {OpenTelemetry::SDK::Trace::TracerProvider#shutdown} is called, if
|
124
|
+
# this exporter is registered to a {OpenTelemetry::SDK::Trace::TracerProvider}
|
125
|
+
# object.
|
126
|
+
def shutdown timeout: nil
|
127
|
+
@shutdown = true
|
128
|
+
SUCCESS
|
129
|
+
end
|
130
|
+
|
131
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
def default_project_id
|
136
|
+
Google::Cloud.env.project_id
|
137
|
+
end
|
138
|
+
|
139
|
+
def shutdown?
|
140
|
+
@shutdown
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|