mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
Remove separator vertices and associated edges from serialized output
The separator vertices are an implementation detail of the serialized output of the LIR, and are not meaningful to the pipeline viewer. This commit removes the separator vertices, and reworks the edges to account for this. Fixes #11779
This commit is contained in:
parent
a8fca3c07f
commit
2e545c75e4
1 changed files with 23 additions and 5 deletions
|
@ -26,7 +26,7 @@ module LogStash;
|
|||
def self.serialize(lir_pipeline)
|
||||
self.new(lir_pipeline).serialize
|
||||
end
|
||||
|
||||
|
||||
def initialize(lir_pipeline)
|
||||
@lir_pipeline = lir_pipeline
|
||||
end
|
||||
|
@ -44,11 +44,11 @@ module LogStash;
|
|||
end
|
||||
|
||||
def vertices
|
||||
graph.getVertices.map {|v| vertex(v) }
|
||||
graph.getVertices.map {|v| vertex(v) }.compact
|
||||
end
|
||||
|
||||
def edges
|
||||
graph.getEdges.map {|e| edge(e) }
|
||||
remove_separators_from_edges(graph.getEdges)
|
||||
end
|
||||
|
||||
def graph
|
||||
|
@ -64,10 +64,10 @@ module LogStash;
|
|||
when :queue
|
||||
queue_vertex(v)
|
||||
when :separator
|
||||
separator_vertex(v)
|
||||
nil
|
||||
end
|
||||
|
||||
decorate_vertex(v, hashified_vertex)
|
||||
decorate_vertex(v, hashified_vertex) unless hashified_vertex.nil?
|
||||
end
|
||||
|
||||
def vertex_type(v)
|
||||
|
@ -114,6 +114,24 @@ module LogStash;
|
|||
{}
|
||||
end
|
||||
|
||||
# For separators, create new edges going between the incoming and all of the outgoing edges, and remove
|
||||
# the separator vertices from the serialized output.
|
||||
def remove_separators_from_edges(edges)
|
||||
edges_with_separators_removed = []
|
||||
edges.each do |e|
|
||||
if vertex_type(e.to) == :separator
|
||||
e.to.getOutgoingEdges.each do |outgoing|
|
||||
edges_with_separators_removed << edge(org.logstash.config.ir.graph.PlainEdge.new(e.from, outgoing.to))
|
||||
end
|
||||
elsif vertex_type(e.from) == :separator
|
||||
# Skip the edges coming from the 'from' separator
|
||||
else
|
||||
edges_with_separators_removed << edge(e)
|
||||
end
|
||||
end
|
||||
edges_with_separators_removed
|
||||
end
|
||||
|
||||
def edge(e)
|
||||
e_json = {
|
||||
"from" => e.from.id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue