Understand Attribute Translation in the New Relic Ruby Agent
devThe New Relic Ruby agent uses attribute translation to map OpenTelemetry (OTel) semantic conventions to New Relic standards. This process ensures that telemetry data sent via OTel is correctly categorized and formatted for New Relic's platform.
How it works
- Identification: When
Tracer#start_spanis called,NewRelic::Agent::OpenTelemetry::AttributeTranslator.translateis invoked. It uses the instrumentation scope, attributes, span name, and span kind to identify the correct translator. - Translation: The identified translator (e.g.,
HttpClientTranslator) uses its correspondingAttributeMappingsconstant to distribute attributes into categories likeintrinsic,agent,instance_variable, orcustom. - Application: Before the span completes, the agent applies these translated attributes to the New Relic transaction or segment.
- Lifecycle Persistence: The translator is assigned as an instance variable on the span. Consequently, any subsequent calls to
Span#add_attributesorSpan#set_attributeduring the span's life will use that same translator to ensure attributes are correctly categorized.
If no specific translator is identified, a GenericTranslator is used, and all attributes are treated as custom attributes.