Adjust assert.Equiv to recognize the OTel semantics:
Convert the array indices of resourceMetrics/logs/spans into non-positional indices. This will allow comparisons to be independent of the ordering and merging of resources.
Similarly, convert the array indices of scopeMetrics/logs/spans into non-positional indices to enable comparisons that do not depend on the ordering and merging of scopes.
Convert the array indices of attributes into non-positional indices. This will allow comparisons to be independent of the ordering of attributes.
Convert the array indices of events into non-positional indices. This will allow comparisons to be independent of the ordering of events.
Convert the array indices of links into non-positional indices. This will allow comparisons to be independent of the ordering of links.
Convert the array indices of metrics, logRecord, and spans into non-positional indices. This will allow comparisons to be independent of the ordering of the corresponding objects.
The non-positional indices for resources (metrics, logs, and spans) are computed as a signature of the resource object itself. Attributes and map objects are organized in an order determined by their keys, followed by a JSON serialization. The non-positional index then corresponds to the MD5 hash of this serialization.
Similarly, non-positional indices for scopes are computed using the same method but applied to the scope object.
When a difference is observed, assert.Equiv returns:
The missing expected elements
The actual elements that were not expected
The expected and actual json representations of metrics, logs, or spans when an issue occurs
In addition to the assert.Equiv improvements, the following changes have been integrated:
Improve the trace generator to test more corner cases.
Fix a bug when metrics, logs, or traces have resource or scope without attribute.
Integrate bug fix #205 to make unit tests happy with the new assert.Equiv
ToDo:
The new assert.Equiv is already used with metrics and logs but the corresponding unit tests must be more exhaustives (similar to the modifications done in traces).
Adjust assert.Equiv to recognize the OTel semantics:
resourceMetrics
/logs
/spans
into non-positional indices. This will allow comparisons to be independent of the ordering and merging of resources.scopeMetrics
/logs
/spans
into non-positional indices to enable comparisons that do not depend on the ordering and merging of scopes.attributes
into non-positional indices. This will allow comparisons to be independent of the ordering of attributes.events
into non-positional indices. This will allow comparisons to be independent of the ordering of events.links
into non-positional indices. This will allow comparisons to be independent of the ordering of links.metrics
,logRecord
, andspans
into non-positional indices. This will allow comparisons to be independent of the ordering of the corresponding objects.The non-positional indices for resources (metrics, logs, and spans) are computed as a signature of the resource object itself. Attributes and map objects are organized in an order determined by their keys, followed by a JSON serialization. The non-positional index then corresponds to the MD5 hash of this serialization.
Similarly, non-positional indices for scopes are computed using the same method but applied to the scope object.
When a difference is observed,
assert.Equiv
returns:In addition to the
assert.Equiv
improvements, the following changes have been integrated:assert.Equiv
ToDo:
assert.Equiv
is already used with metrics and logs but the corresponding unit tests must be more exhaustives (similar to the modifications done in traces).