-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #310 from membraneframework/release/v0.7.0
Release membrane_core v0.7.0
- Loading branch information
Showing
27 changed files
with
207 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
defmodule Membrane.Core.Telemetry do | ||
@moduledoc false | ||
|
||
alias Membrane.ComponentPath | ||
alias Membrane.Core.Parent.Link.Endpoint | ||
alias Membrane.Telemetry | ||
|
||
require Membrane.Pad | ||
|
||
@enable_telemetry Application.compile_env(:membrane_core, :enable_telemetry, false) | ||
|
||
@doc """ | ||
Macro for reporting metrics. | ||
Provided `calculate_measurement` is a function. | ||
Metrics are reported only when it is enabled in the application using Membrane Core. | ||
""" | ||
defmacro report_measurement(event_name, calculate_measurement) do | ||
if @enable_telemetry do | ||
quote do | ||
:telemetry.execute( | ||
unquote(event_name), | ||
unquote(calculate_measurement).(), | ||
%{} | ||
) | ||
end | ||
else | ||
# A hack to suppress the 'unused variable' warnings | ||
quote do | ||
fn -> | ||
_unused = unquote(event_name) | ||
_unused = unquote(calculate_measurement) | ||
end | ||
|
||
:ok | ||
end | ||
end | ||
end | ||
|
||
@doc """ | ||
Reports metrics such as input buffer's size inside functions, incoming events and received caps. | ||
""" | ||
@spec report_metric(String.t(), integer(), String.t()) :: :ok | ||
def report_metric(metric, value, log_tag) do | ||
calculate_measurement = fn -> | ||
component_path = ComponentPath.get_formatted() <> "/" <> (log_tag || "") | ||
|
||
%{ | ||
component_path: component_path, | ||
metric: metric, | ||
value: value | ||
} | ||
end | ||
|
||
report_measurement( | ||
Telemetry.metric_event_name(), | ||
calculate_measurement | ||
) | ||
end | ||
|
||
@doc """ | ||
Reports new link connection being initialized in pipeline. | ||
""" | ||
@spec report_new_link(Endpoint.t(), Endpoint.t()) :: :ok | ||
def report_new_link(from, to) do | ||
calculate_measurement = fn -> | ||
%Endpoint{child: from_child, pad_ref: from_pad} = from | ||
%Endpoint{child: to_child, pad_ref: to_pad} = to | ||
|
||
%{ | ||
parent_path: Membrane.ComponentPath.get_formatted(), | ||
from: "#{inspect(from_child)}", | ||
to: "#{inspect(to_child)}", | ||
pad_from: "#{inspect(get_public_pad_name(from_pad))}", | ||
pad_to: "#{inspect(get_public_pad_name(to_pad))}" | ||
} | ||
end | ||
|
||
report_measurement( | ||
Telemetry.new_link_event_name(), | ||
calculate_measurement | ||
) | ||
end | ||
|
||
defp get_public_pad_name(pad) do | ||
case pad do | ||
{:private, direction} -> direction | ||
{Membrane.Pad, {:private, direction}, ref} -> {Membrane.Pad, direction, ref} | ||
_pad -> pad | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
defmodule Membrane.CrashGroup do | ||
@moduledoc """ | ||
Module containing types and functions for operating on crash groups. | ||
""" | ||
|
||
@type name_t() :: any() | ||
end |
Oops, something went wrong.