Skip to content

Commit

Permalink
Rename to_proto/from_proto to to_grpc/from_grpc for trace models
Browse files Browse the repository at this point in the history
  • Loading branch information
dazuma authored and blowmage committed Dec 21, 2016
1 parent b83c2a6 commit d93935c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion google-cloud-trace/lib/google/cloud/trace/result_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def self.from_gax_page service, project_id,
next_page_token = page.next_page_token
next_page_token = nil unless page.next_page_token?
results = page.map do |proto|
Google::Cloud::Trace::TraceRecord.from_proto proto
Google::Cloud::Trace::TraceRecord.from_grpc proto
end
new service, project_id,
results, next_page_token,
Expand Down
4 changes: 2 additions & 2 deletions google-cloud-trace/lib/google/cloud/trace/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def patch_traces traces
traces = Array(traces)
traces_proto = Google::Devtools::Cloudtrace::V1::Traces.new
traces.each do |trace|
traces_proto.traces.push trace.to_proto
traces_proto.traces.push trace.to_grpc
end
execute do
lowlevel_client.patch_traces @project, traces_proto
Expand All @@ -107,7 +107,7 @@ def get_trace trace_id
trace_proto = execute do
lowlevel_client.get_trace @project, trace_id
end
Google::Cloud::Trace::TraceRecord.from_proto trace_proto
Google::Cloud::Trace::TraceRecord.from_grpc trace_proto
end

##
Expand Down
4 changes: 2 additions & 2 deletions google-cloud-trace/lib/google/cloud/trace/span.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def eql? other
# to contain the span.
# @return [Google::Cloud::Trace::Span] A corresponding Span object.
#
def self.from_proto span_proto, trace
def self.from_grpc span_proto, trace
labels = {}
span_proto.labels.each { |k, v| labels[k] = v }
span_kind = SpanKind.get span_proto.kind
Expand All @@ -173,7 +173,7 @@ def self.from_proto span_proto, trace
# @return [Google::Devtools::Cloudtrace::V1::TraceSpan] The generated
# protobuf.
#
def to_proto default_parent_id = 0
def to_grpc default_parent_id = 0
start_proto = Google::Cloud::Trace::Utils.time_to_proto start_time
end_proto = Google::Cloud::Trace::Utils.time_to_proto end_time
Google::Devtools::Cloudtrace::V1::TraceSpan.new \
Expand Down
10 changes: 5 additions & 5 deletions google-cloud-trace/lib/google/cloud/trace/trace_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module Trace
# span = trace.create_span "root_span"
# subspan = span.create_span "subspan"
#
# trace_proto = trace.to_proto
# trace_proto = trace.to_grpc
#
class TraceRecord
##
Expand Down Expand Up @@ -79,7 +79,7 @@ def eql? other
# @return [Trace, nil] A corresponding Trace object, or `nil` if the
# proto does not represent an existing trace object.
#
def self.from_proto trace_proto
def self.from_grpc trace_proto
trace_id = trace_proto.trace_id.to_s
return nil if trace_id.empty?

Expand All @@ -105,9 +105,9 @@ def self.from_proto trace_proto
# @return [Google::Devtools::Cloudtrace::V1::Trace] The generated
# protobuf.
#
def to_proto
def to_grpc
span_protos = @spans_by_id.values.map do |span|
span.to_proto trace_context.span_id.to_i
span.to_grpc trace_context.span_id.to_i
end
Google::Devtools::Cloudtrace::V1::Trace.new \
project_id: project,
Expand Down Expand Up @@ -320,7 +320,7 @@ def add_span_protos span_protos, parent_span_ids
new_span_ids = ::Set.new
span_protos.each do |span_proto|
if parent_span_ids.include? span_proto.parent_span_id
Google::Cloud::Trace::Span.from_proto span_proto, self
Google::Cloud::Trace::Span.from_grpc span_proto, self
new_span_ids.add span_proto.span_id
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@
labels: sub_labels)
]

trace.to_proto.must_equal proto
Google::Cloud::Trace::TraceRecord.from_proto(proto).must_equal trace
trace.to_grpc.must_equal proto
Google::Cloud::Trace::TraceRecord.from_grpc(proto).must_equal trace
end

it "converts to and from a protobuf with an orphaned span" do
Expand Down Expand Up @@ -298,7 +298,7 @@
labels: sub_labels)
]

trace.to_proto.must_equal proto
Google::Cloud::Trace::TraceRecord.from_proto(proto).must_equal trace
trace.to_grpc.must_equal proto
Google::Cloud::Trace::TraceRecord.from_grpc(proto).must_equal trace
end
end

0 comments on commit d93935c

Please sign in to comment.