Skip to content

Commit

Permalink
Improve YARD types for attributes. (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
fhwang authored Feb 13, 2020
1 parent 5dd0c82 commit 85b020b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
7 changes: 4 additions & 3 deletions api/lib/opentelemetry/trace/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Event

# Returns the frozen attributes for this event
#
# @return [Hash<String, Object>]
# @return [Hash{String => String, Numeric, Boolean}]
attr_reader :attributes

# Returns the timestamp for this event
Expand All @@ -30,8 +30,9 @@ class Event
# Returns a new immutable {Event}.
#
# @param [String] name The name of this event
# @param [optional Hash<String, Object>] attributes A hash of attributes for this
# event. Attributes will be frozen during Event initialization.
# @param [optional Hash{String => String, Numeric, Boolean}]
# attributes A hash of attributes for this event. Attributes will be
# frozen during Event initialization.
# @param [optional Time] timestamp The timestamp for this event.
# Defaults to Time.now.
# @return [Event]
Expand Down
7 changes: 4 additions & 3 deletions api/lib/opentelemetry/trace/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ class Link

# Returns the frozen attributes for this link.
#
# @return [Hash<String, Object>]
# @return [Hash{String => String, Numeric, Boolean}]
attr_reader :attributes

# Returns a new immutable {Link}.
#
# @param [SpanContext] span_context The context of the linked {Span}.
# @param [optional Hash<String, Object>] attributes A hash of attributes for
# this link. Attributes will be frozen during Link initialization.
# @param [optional Hash{String => String, Numeric, Boolean}] attributes A
# hash of attributes for this link. Attributes will be frozen during
# Link initialization.
# @return [Link]
def initialize(span_context, attributes = nil)
@context = span_context
Expand Down
8 changes: 4 additions & 4 deletions api/lib/opentelemetry/trace/span.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def set_attribute(key, value)
#
# @param [optional String] name Optional name of the event. This is
# required if a block is not given.
# @param [optional Hash<String, Object>] attributes One or more key:value
# pairs, where the keys must be strings and the values may be string,
# boolean or numeric type. This argument should only be used when
# passing in a name.
# @param [optional Hash{String => String, Numeric, Boolean}] attributes
# One or more key:value pairs, where the keys must be strings and the
# values may be string, boolean or numeric type. This argument should
# only be used when passing in a name.
# @param [optional Time] timestamp Optional timestamp for the event.
# This argument should only be used when passing in a name.
#
Expand Down
7 changes: 4 additions & 3 deletions sdk/lib/opentelemetry/sdk/trace/samplers/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ class Result

# Returns a frozen hash of attributes to be attached span.
#
# @return [Hash<String, Object>]
# @return [Hash{String => String, Numeric, Boolean}]
attr_reader :attributes

# Returns a new sampling result with the specified decision and
# attributes.
#
# @param [Symbol] decision Whether or not a span should be sampled
# and/or record events.
# @param [optional Hash<String, Object>] attributes A frozen or freezable hash
# containing attributes to be attached to the span.
# @param [optional Hash{String => String, Numeric, Boolean}]
# attributes A frozen or freezable hash containing attributes to be
# attached to the span.
def initialize(decision:, attributes: nil)
@decision = decision
@attributes = attributes.freeze || EMPTY_HASH
Expand Down
10 changes: 5 additions & 5 deletions sdk/lib/opentelemetry/sdk/trace/span.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Span < OpenTelemetry::Trace::Span
# use of SpanProcesses and should not be considered part of the public
# interface for instrumentation.
#
# @return [Hash<String, Object>] may be nil.
# @return [Hash{String => String, Numeric, Boolean}] may be nil.
def attributes
# Don't bother synchronizing. Access by SpanProcessors is expected to
# be serialized.
Expand Down Expand Up @@ -96,10 +96,10 @@ def set_attribute(key, value)
#
# @param [optional String] name Optional name of the event. This is
# required if a block is not given.
# @param [optional Hash<String, Object>] attributes One or more key:value
# pairs, where the keys must be strings and the values may be string,
# boolean or numeric type. This argument should only be used when
# passing in a name.
# @param [optional Hash{String => String, Numeric, Boolean}] attributes
# One or more key:value pairs, where the keys must be strings and the
# values may be string, boolean or numeric type. This argument should
# only be used when passing in a name.
# @param [optional Time] timestamp Optional timestamp for the event.
# This argument should only be used when passing in a name.
#
Expand Down

0 comments on commit 85b020b

Please sign in to comment.