Created
February 13, 2017 16:30
-
-
Save pior/f2bd839925bbeb1cde5ca4202f3d3311 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'securerandom' | |
| require 'date' | |
| require 'googleauth' | |
| require 'google/apis/cloudtrace_v1' | |
| service = Google::Apis::CloudtraceV1::CloudTraceService.new | |
| service.authorization = Google::Auth.get_application_default(['https://www.googleapis.com/auth/trace.append']) | |
| project_id = 'XXXXX' | |
| t1 = Time.now.utc.round(10).iso8601(6) | |
| sleep 0.05 | |
| t2 = Time.now.utc.round(10).iso8601(6) | |
| span = Google::Apis::CloudtraceV1::TraceSpan.new( | |
| name: '/test', | |
| span_id: 1.to_s, | |
| start_time: t1, | |
| end_time: t2, | |
| labels: {}, | |
| kind: 'RPC_SERVER', | |
| ) | |
| trace = Google::Apis::CloudtraceV1::Trace.new( | |
| trace_id: SecureRandom.uuid.split('-').join, | |
| project_id: project_id, | |
| spans: [span] | |
| ) | |
| traces = Google::Apis::CloudtraceV1::Traces.new(traces: [trace]) | |
| response = service.patch_project_traces(project_id, traces) | |
| puts response.inspect |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
API
https://cloud.google.com/trace/api/reference/rpc/google.devtools.cloudtrace.v1#google.devtools.cloudtrace.v1.TraceSpan.SpanKind
Rb
http://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/CloudtraceV1/TraceSpan