-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
779 additions
and
52 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
38 changes: 38 additions & 0 deletions
38
ex_webrtc/integration_test/test_videoroom/lib/test_videoroom/scraper.ex
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,38 @@ | ||
defmodule TestVideoroom.MetricsScraper do | ||
@moduledoc false | ||
|
||
use GenServer, restart: :temporary | ||
|
||
alias Membrane.TelemetryMetrics.Reporter | ||
|
||
@scrape_interval 1_000 | ||
|
||
def start_link(_opts) do | ||
GenServer.start_link(__MODULE__, @scrape_interval, name: __MODULE__) | ||
end | ||
|
||
@impl true | ||
def init(scrape_interval) do | ||
send(self(), :scrape) | ||
|
||
{:ok, %{scrape_interval: scrape_interval, subscriptions: []}} | ||
end | ||
|
||
@impl true | ||
def handle_info(:scrape, state) do | ||
report = Reporter.scrape(ExWebrtcMetricsReporter) | ||
|
||
Process.send_after(self(), :scrape, state.scrape_interval) | ||
|
||
Enum.each(state.subscriptions, &send(&1, {:metrics, report})) | ||
|
||
{:noreply, state} | ||
end | ||
|
||
@impl true | ||
def handle_info({:subscribe, pid}, state) do | ||
Reporter.scrape_and_cleanup(ExWebrtcMetricsReporter) | ||
state = update_in(state.subscriptions, &[pid | &1]) | ||
{:noreply, state} | ||
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
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
Oops, something went wrong.