Class: XRay::DynamicNaming
- Inherits:
-
Object
- Object
- XRay::DynamicNaming
- Includes:
- SegmentNaming
- Defined in:
- lib/aws-xray-sdk/segment_naming/dynamic_naming.rb
Overview
Decides what name to use on a segment generated from an incoming request. This default naming takes the host name and compares it to a pre-defined pattern. If the host name matches that pattern, it returns the host name, otherwise it returns the fallback name. The host name usually comes from the incoming request’s headers.
Instance Attribute Summary
Attributes included from SegmentNaming
Instance Method Summary collapse
-
#initialize(fallback:) ⇒ DynamicNaming
constructor
A new instance of DynamicNaming.
- #provide_name(host:) ⇒ Object
Constructor Details
#initialize(fallback:) ⇒ DynamicNaming
Returns a new instance of DynamicNaming.
15 16 17 |
# File 'lib/aws-xray-sdk/segment_naming/dynamic_naming.rb', line 15 def initialize(fallback:) @fallback = fallback end |
Instance Method Details
#provide_name(host:) ⇒ Object
20 21 22 23 24 |
# File 'lib/aws-xray-sdk/segment_naming/dynamic_naming.rb', line 20 def provide_name(host:) # use fallback name when either the pattern or host name is unavailable. return fallback unless pattern && !pattern.empty? && host && !host.empty? SearchPattern.wildcard_match?(pattern: pattern, text: host) ? host : fallback end |