Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge stackdriver-core-dependencies feature branch to master #1162

Merged
merged 21 commits into from
Dec 21, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
bee7781
Update google-cloud-logging to use trace context tracking from core
dazuma Dec 2, 2016
ab50c20
Trace instrumentation
dazuma Oct 26, 2016
6a75b24
Frontload require of version.rb so the trace gem will load without th…
dazuma Dec 14, 2016
bbf3345
Restore (but deprecate) earlier logger API for now.
dazuma Dec 14, 2016
26ce73d
Restore doctest notice for google-cloud-trace
dazuma Dec 14, 2016
ffcf821
Basic acceptance tests for google-cloud-trace
dazuma Dec 15, 2016
d5af77d
Logger object understands all attributes supported by the stdlib Logger
dazuma Dec 15, 2016
ff10785
Cloud Logger supports all remaining stdlib Logger methods.
dazuma Dec 15, 2016
6bc5fc7
Ensure AsyncWriter threads finish on VM exit
dazuma Dec 15, 2016
5f47636
Improve Logging::Railtie activation warning messages
hxiong388 Dec 16, 2016
b1da405
Update and clarify docs for google-cloud-trace
dazuma Dec 16, 2016
4db6a30
Improve the Logger activation warning messages even more
hxiong388 Dec 17, 2016
73db861
Remove orphaned span hack from middleware, and fix conversion of orph…
dazuma Dec 17, 2016
dcc3774
Document capture_stack rails config
dazuma Dec 18, 2016
b0eb908
Best Logger activation warning messages ever!
hxiong388 Dec 19, 2016
b1c31bc
Fix examples related to thread traces
dazuma Dec 19, 2016
b83c2a6
Trace sampler interface is now just a Proc
dazuma Dec 19, 2016
d93935c
Rename to_proto/from_proto to to_grpc/from_grpc for trace models
dazuma Dec 19, 2016
8c806a8
Update docs to clarify how blacklisting and sampling work
dazuma Dec 20, 2016
eac4d89
Change proto to grpc terminology in Utils
dazuma Dec 20, 2016
7e38bc5
Update google-cloud-core dependency for logging and trace to pick up …
dazuma Dec 21, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Trace instrumentation
  • Loading branch information
dazuma authored and blowmage committed Dec 21, 2016
commit ab50c20aa9190d6a9298b2969c88e873e67c5b6b
8 changes: 8 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@
"v0.20.0"
]
},
{
"id": "google-cloud-trace",
"name": "google-cloud-trace",
"defaultService": "google/cloud/trace",
"versions": [
"master"
]
},
{
"id": "google-cloud-translate",
"name": "google-cloud-translate",
Expand Down
15 changes: 15 additions & 0 deletions google-cloud-trace/.autotest
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- ruby -*-

require "autotest/suffix"

# Autotest.add_hook :initialize do |at|
# at.clear_mappings
#
# at.add_mapping %r%^lib/(.*)\.rb$% do |_, m|
# at.files_matching %r%^test/#{m[1]}.*_test.rb$%
# end
#
# at.add_mapping %r%^test/.*_test\.rb$% do |filename, _|
# filename
# end
# end
6 changes: 6 additions & 0 deletions google-cloud-trace/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,11 @@ Style/ClassVars:
Enabled: false
Style/TrivialAccessors:
Enabled: false
Style/CaseEquality:
Enabled: false
Style/GuardClause:
Enabled: false
Style/FileName:
Enabled: false # for lib/google-cloud-trace.rb file
Lint/RescueException:
Enabled: false # for lib/google/cloud/logging/rails.rb file
3 changes: 2 additions & 1 deletion google-cloud-trace/.yardopts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
--no-private
--title=Stackdriver Trace
--title=Stackdriver Trace
--markup markdown

./lib/**/*.rb
-
Expand Down
4 changes: 0 additions & 4 deletions google-cloud-trace/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
# Release History

### 0.21.0 / 2016-11-03

* First release
1 change: 1 addition & 0 deletions google-cloud-trace/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source "https://rubygems.org"
gemspec

gem "rake", "~> 11.0"
gem "stackdriver-core", path: "../stackdriver-core"
gem "gcloud-jsondoc",
git: "https://github.com/GoogleCloudPlatform/google-cloud-ruby.git",
branch: "gcloud-jsondoc"
69 changes: 57 additions & 12 deletions google-cloud-trace/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,79 @@ RuboCop::RakeTask.new

desc "Run tests."
task :test do
puts "The google-cloud-trace gem does not have tests."
$LOAD_PATH.unshift "lib", "test"
Dir.glob("test/**/*_test.rb").each { |file| require_relative file }
end

namespace :test do
desc "Run tests with coverage."
desc "Runs tests with coverage."
task :coverage do
require "simplecov"
SimpleCov.start do
command_name "google-cloud-trace"
track_files "lib/**/*.rb"
add_filter "test/"
end

Rake::Task["test"].invoke
end
end

# Acceptance tests
desc "Run the trace acceptance tests."
task :acceptance do
puts "The google-cloud-trace gem does not have acceptance tests."
desc "Runs the trace acceptance tests."
task :acceptance, :project, :keyfile do |t, args|
project = args[:project]
project ||= ENV["GCLOUD_TEST_PROJECT"] || ENV["TRACE_TEST_PROJECT"]
keyfile = args[:keyfile]
keyfile ||= ENV["GCLOUD_TEST_KEYFILE"] || ENV["TRACE_TEST_KEYFILE"]
if keyfile
keyfile = File.read keyfile
else
keyfile ||= ENV["GCLOUD_TEST_KEYFILE_JSON"] || ENV["TRACE_TEST_KEYFILE_JSON"]
end
if project.nil? || keyfile.nil?
fail "You must provide a project and keyfile. e.g. rake acceptance[test123, /path/to/keyfile.json] or TRACE_TEST_PROJECT=test123 TRACE_TEST_KEYFILE=/path/to/keyfile.json rake acceptance"
end
# always overwrite when running tests
ENV["TRACE_PROJECT"] = project
ENV["TRACE_KEYFILE"] = nil
ENV["TRACE_KEYFILE_JSON"] = keyfile

$LOAD_PATH.unshift "lib", "acceptance"
Dir.glob("acceptance/trace/**/*_test.rb").each { |file| require_relative file }
end

namespace :acceptance do
desc "Run acceptance tests with coverage."
task :coverage do
end
desc "Runs acceptance tests with coverage."
task :coverage, :project, :keyfile do |t, args|
require "simplecov"
SimpleCov.start do
command_name "google-cloud-trace"
track_files "lib/**/*.rb"
add_filter "acceptance/"
end

desc "Run acceptance cleanup."
task :cleanup do
Rake::Task["acceptance"].invoke
end
end

desc "Run yard-doctest example tests."
desc "Runs yard-doctest example tests."
task :doctest do
puts "The google-cloud-trace gem does not have doctest tests."
end

desc "Start an interactive shell."
task :console do
require "irb"
require "irb/completion"
require "pp"

$LOAD_PATH.unshift "lib"

require "google-cloud-trace"
def gcloud; @gcloud ||= Google::Cloud.new; end

ARGV.clear
IRB.start
end

require "yard"
Expand Down
67 changes: 65 additions & 2 deletions google-cloud-trace/docs/toc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,71 @@
{
"guides": [],
"guides": [
{
"title": "Troubleshooting",
"id": "troubleshooting",
"edit": "https://github.com/GoogleCloudPlatform/gcloud-common/edit/master/troubleshooting/readme.md",
"contents": "https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/troubleshooting/readme.md"
},
{
"title": "Contributing",
"id": "contributing",
"edit": "https://github.com/GoogleCloudPlatform/gcloud-common/edit/master/contributing/readme.md",
"contents": "https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/contributing/readme.md"
}
],
"services": [
{
"title": "TraceServiceApi",
"title": "Google::Cloud",
"type": "google/cloud"
},
{
"title": "Google::Cloud::Trace",
"type": "google/cloud/trace",
"nav": [

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

{
"title": "LabelKey",
"type": "google/cloud/trace/labelkey"
},
{
"title": "Middleware",
"type": "google/cloud/trace/middleware"
},
{
"title": "Notifications",
"type": "google/cloud/trace/notifications"
},
{
"title": "Project",
"type": "google/cloud/trace/project"
},
{
"title": "Railtie",
"type": "google/cloud/trace/railtie"
},
{
"title": "ResultSet",
"type": "google/cloud/trace/resultset"
},
{
"title": "Span",
"type": "google/cloud/trace/span"
},
{
"title": "SpanKind",
"type": "google/cloud/trace/spankind"
},
{
"title": "TimeSampler",
"type": "google/cloud/trace/timesampler"
},
{
"title": "TraceRecord",
"type": "google/cloud/trace/tracerecord"
},
]
},
{
"title": "Low-Level API",
"type": "google/cloud/trace/v1/traceserviceapi"
}
]
Expand Down
23 changes: 17 additions & 6 deletions google-cloud-trace/google-cloud-trace.gemspec
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# -*- ruby -*-
# encoding: utf-8
# -*- encoding: utf-8 -*-
require File.expand_path("../lib/google/cloud/trace/version", __FILE__)

Gem::Specification.new do |gem|
gem.name = "google-cloud-trace"
gem.version = "0.21.0"
gem.version = Google::Cloud::Trace::VERSION

gem.authors = ["Google Inc"]
gem.email = ["googleapis-packages@google.com"]
gem.authors = ["Daniel Azuma"]
gem.email = ["dazuma@google.com"]
gem.description = "google-cloud-trace is the official library for Stackdriver Trace."
gem.summary = "API Client library for Stackdriver Trace"
gem.summary = "Application Instrumentation and API Client library for Stackdriver Trace"
gem.homepage = "http://googlecloudplatform.github.io/google-cloud-ruby/"
gem.license = "Apache-2.0"

Expand All @@ -24,6 +24,17 @@ Gem::Specification.new do |gem|
gem.add_dependency "google-gax", "~> 0.6.0"
gem.add_dependency "google-protobuf", "~> 3.0"
gem.add_dependency "googleapis-common-protos", "~> 1.3"
gem.add_dependency "google-cloud-core", "~> 0.21.0"

This comment was marked as spam.

gem.add_dependency "stackdriver-core", "~> 0.21.0"

gem.add_development_dependency "minitest", "~> 5.9"
gem.add_development_dependency "minitest-autotest", "~> 1.0"
gem.add_development_dependency "minitest-focus", "~> 1.1"
gem.add_development_dependency "minitest-rg", "~> 5.2"
gem.add_development_dependency "autotest-suffix", "~> 1.1"
gem.add_development_dependency "railties", "~> 4.0"
gem.add_development_dependency "rubocop", "<= 0.35.1"
gem.add_development_dependency "simplecov", "~> 0.9"
gem.add_development_dependency "yard", "~> 0.9"
gem.add_development_dependency "yard-doctest", "~> 0.1.6"
end
79 changes: 76 additions & 3 deletions google-cloud-trace/lib/google-cloud-trace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,85 @@
# limitations under the License.

##
# This file is here to be autorequired by bundler, so that the .logging and
# #logging methods can be available, but the library and all dependencies won't
# This file is here to be autorequired by bundler, so that the .trace and
# #trace methods can be available, but the library and all dependencies won't
# be loaded until required and used.


gem "google-cloud-core"
require "google/cloud"

# There is no Google::Cloud integration to add.
module Google
module Cloud
##
# Creates a new object for connecting to the Stackdriver Trace service.
# Each call creates a new connection.
#
# For more information on connecting to Google Cloud see the [Authentication
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
#
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
# set of resources and operations that the connection can access. See
# [Using OAuth 2.0 to Access Google
# APIs](https://developers.google.com/identity/protocols/OAuth2).
# The default scope is `https://www.googleapis.com/auth/cloud-platform`
# @param [Integer] timeout Default timeout to use in requests. Optional.
#
# @return [Google::Cloud::Trace::Project]
#
# @example
# require "google/cloud"
#
# gcloud = Google::Cloud.new
# trace_client = gcloud.trace
#
# traces = trace_client.list_traces Time.now - 3600, Time.now
# traces.each do |trace|
# puts "Retrieved trace ID: #{trace.trace_id}"
# end
#
def trace scope: nil, timeout: nil, client_config: nil
Google::Cloud.trace @project, @keyfile, scope: scope,
timeout: (timeout || @timeout),
client_config: client_config
end

##
# Creates a new object for connecting to the Stackdriver Trace service.
# Each call creates a new connection.
#
# For more information on connecting to Google Cloud see the [Authentication
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
#
# @param [String] project Project identifier for the Stackdriver Trace
# service.
# @param [String, Hash] keyfile Keyfile downloaded from Google Cloud:
# either the JSON data or the path to a readable file.
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
# set of resources and operations that the connection can access. See
# [Using OAuth 2.0 to Access Google
# APIs](https://developers.google.com/identity/protocols/OAuth2).
# The default scope is `https://www.googleapis.com/auth/cloud-platform`
# @param [Integer] timeout Default timeout to use in requests. Optional.
#
# @return [Google::Cloud::Trace::Project]
#
# @example
# require "google/cloud"
#
# trace_client = Google::Cloud.trace
#
# traces = trace_client.list_traces Time.now - 3600, Time.now
# traces.each do |trace|
# puts "Retrieved trace ID: #{trace.trace_id}"
# end
#
def self.trace project = nil, keyfile = nil, scope: nil, timeout: nil,
client_config: nil
require "google/cloud/trace"
Google::Cloud::Trace.new project: project, keyfile: keyfile,
scope: scope, timeout: timeout,
client_config: client_config
end
end
end
Loading