Module: ZuoraObservability::Logging::ZuoraFields
- Defined in:
- lib/zuora_observability/logging/formatter.rb
Overview
The Zuora Extension to ECS defined by ZECS
Constant Summary collapse
- ZECS_VERSION =
'1.1'
Class Method Summary collapse
- .base_fields(data) ⇒ Object
-
.call(data) ⇒ Object
zuora top level field.
-
.http_fields(data) ⇒ Object
zuora.http.
-
.service_fields(data) ⇒ Object
Service’s Custom Fields.
Class Method Details
.base_fields(data) ⇒ Object
155 156 157 158 159 160 161 162 163 |
# File 'lib/zuora_observability/logging/formatter.rb', line 155 def base_fields(data) { cp_id: data[:zuora_track_id], entity_ids: data[:entity_ids], environment: data[:environment], tenant_id: data[:tenant_ids], trace_id: data[:zuora_trace_id] }.compact end |
.call(data) ⇒ Object
zuora top level field
141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/zuora_observability/logging/formatter.rb', line 141 def call(data) hash = base_fields(data) z_http = http_fields(data) hash[:http] = z_http unless z_http.empty? z_service = service_fields(data) hash[Env.name.to_sym] = z_service unless z_service.empty? return {} if hash.empty? hash.merge({ ecs: { version: ZECS_VERSION } }) end |
.http_fields(data) ⇒ Object
zuora.http
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/zuora_observability/logging/formatter.rb', line 166 def http_fields(data) z_http_request = { headers: data[:headers] || data.dig(:request, :headers), headers_blob: data.dig(:request, :headers_blob) }.compact z_http_response = { headers: data.dig(:response, :headers), headers_blob: data.dig(:response, :headers_blob) }.compact { request: (z_http_request unless z_http_request.empty?), response: (z_http_response unless z_http_response.empty?) }.compact end |
.service_fields(data) ⇒ Object
Service’s Custom Fields
184 185 186 187 188 |
# File 'lib/zuora_observability/logging/formatter.rb', line 184 def service_fields(data) { app_instance_id: data[:app_instance_id] }.merge(data.fetch(:zecs_service, {})).compact end |