Module: Datadog::Tracing::Metadata::Ext::HTTP::Headers
- Defined in:
- lib/datadog/tracing/metadata/ext.rb
Overview
General header functionality
Constant Summary collapse
- INVALID_TAG_CHARACTERS =
%r{[^a-z0-9_\-:./]}.freeze
Class Method Summary collapse
-
.to_tag(name, allow_nested: false) ⇒ Object
Normalizes an HTTP header string into a valid tag string.
Class Method Details
.to_tag(name, allow_nested: false) ⇒ Object
Normalizes an HTTP header string into a valid tag string.
By default, tags cannot create nested span tag levels: ‘allow_nested` allows you to override this behavior.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/datadog/tracing/metadata/ext.rb', line 109 def to_tag(name, allow_nested: false) # Tag normalization based on: https://docs.datadoghq.com/getting_started/tagging/#defining-tags. # # Only the following characters are accepted. # * Alphanumerics # * Underscores # * Minuses # * Colons # * Periods # * Slashes # # All other characters are replaced with an underscore. tag = name.to_s.strip tag.downcase! tag.gsub!(INVALID_TAG_CHARACTERS, '_') # Additional HTTP header normalization. # # Periods are replaced with an underscore. tag.tr!('.', '_') unless allow_nested tag end |