You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The pattern is to define two traits per OTLP data type . For
productionizing this concept, we will extend the ./derive macro
package.
For each type there is a Visitor (an actor) and a Visitable. Using these traits allows an implementation to perform
an in-order traversal of OTLP-like data structure.
A Visitable impl is passed to the Visitor to enact the
visitation. Visitable adapter structs are provided for presenting OTLP
data types as Visitable impls. Visitable impls are immutable, passed
by &self.
Visitor impls are passed to the Visitable carrying logic as the
traversal descends into a child. Visitors are provided for each field
of the child. Visitors are mutable, passed by &mut self.
In general, the Visitor calls the Visitable and the Visitable calls
the child Visitors. At the top-level, users are directed to use for
example, LogsVisitor which consumes the visitor and returns the
associated Return type.
As an example, to count log records we can use the visitor:
Implement a OTLP protocol buffer encoding using this abstraction. The
same abstraction will be implemented for OTAP data frames, and we
expect that directly encoding OTLP bytes using the visitor will
outperform the use of intermediate protocol buffer objects for
encoding.
A two-pass implementation will:
Using scratch memory, build a Vec containing the size of
every length-delimited field in traversal order.
Generate output in a second pass while iterating over the
Vec above to know the size of each object in advance.
We recognize that this is not the only way to encode a protocol
buffer. Our task is to benchmark this algorithm and compare it with
the performance of directly encoding with Prost.
The text was updated successfully, but these errors were encountered:
Visitor pattern
The pattern is to define two traits per OTLP data type . For
productionizing this concept, we will extend the ./derive macro
package.
For each type there is a Visitor (an actor) and a
Visitable. Using these traits allows an implementation to perform
an in-order traversal of OTLP-like data structure.
A Visitable impl is passed to the Visitor to enact the
visitation. Visitable adapter structs are provided for presenting OTLP
data types as Visitable impls. Visitable impls are immutable, passed
by
&self
.Visitor impls are passed to the Visitable carrying logic as the
traversal descends into a child. Visitors are provided for each field
of the child. Visitors are mutable, passed by
&mut self
.In general, the Visitor calls the Visitable and the Visitable calls
the child Visitors. At the top-level, users are directed to use for
example, LogsVisitor which consumes the visitor and returns the
associated Return type.
As an example, to count log records we can use the visitor:
Benchmark results for counting 10 resources * 10 scopes each * 10
records each indicate a slowdown of 50%.
This is inconclusive. We expect some cost for the abstraction, and a
more realistic application should be measured.
Example traits
For the
LogsData
type, which is a top-level container for logs, theVisitor trait is:
The Vistable trait is:
The OTLP adapter is:
and the complete log item-counter implementation used for the benchmark:
Next steps
Implement a OTLP protocol buffer encoding using this abstraction. The
same abstraction will be implemented for OTAP data frames, and we
expect that directly encoding OTLP bytes using the visitor will
outperform the use of intermediate protocol buffer objects for
encoding.
A two-pass implementation will:
every length-delimited field in traversal order.
Vec above to know the size of each object in advance.
We recognize that this is not the only way to encode a protocol
buffer. Our task is to benchmark this algorithm and compare it with
the performance of directly encoding with Prost.
The text was updated successfully, but these errors were encountered: