Module: OpenTelemetry::Resource::Detector::Container
- Extended by:
- Container
- Included in:
- Container
- Defined in:
- lib/opentelemetry/resource/detector/container.rb,
lib/opentelemetry/resource/detector/container/version.rb
Overview
Container contains detect class method for determining container resource attributes
Constant Summary collapse
- UUID_PATTERN =
'[0-9a-f]{8}[-_]?[0-9a-f]{4}[-_]?[0-9a-f]{4}[-_]?[0-9a-f]{4}[-_]?[0-9a-f]{12}'
- CONTAINER_PATTERN =
'[0-9a-f]{64}'
- CONTAINER_REGEX =
/(?<container>#{UUID_PATTERN}|#{CONTAINER_PATTERN})(?:.scope)?$/
- CGROUP_V1_PATH =
'/proc/self/cgroup'
- CGROUP_V2_PATH =
'/proc/self/mountinfo'
- VERSION =
'0.1.2'
Instance Method Summary collapse
-
#detect ⇒ OpenTelemetry::SDK::Resources::Resource
Detects container attributes and creates a SDK::Resources::Resource with the specified attributes.
Instance Method Details
#detect ⇒ OpenTelemetry::SDK::Resources::Resource
Detects container attributes and creates a SDK::Resources::Resource with the specified attributes. If no container attributes could be determined an empty resource is returned
24 25 26 27 28 29 30 31 |
# File 'lib/opentelemetry/resource/detector/container.rb', line 24 def detect id = container_id resource_attributes = {} resource_attributes[OpenTelemetry::SemanticConventions::Resource::CONTAINER_ID] = id unless id.nil? resource_attributes.delete_if { |_key, value| value.nil? || value.empty? } OpenTelemetry::SDK::Resources::Resource.create(resource_attributes) end |