Repository: membraneframework/membrane_core (elixir)

Issue:
component_type in telemetry is component_module instead
in ComponentContext 

![Image](https://github.com/user-attachments/assets/365778e6-1525-46d3-bb0d-190428bf0787)

But

![Image](https://github.com/user-attachments/assets/7cdbf445-6c05-400e-a438-fe5d450d7297)

Which are incosisten with each other

Pull request:
Fixed telemetry metadata bug of component_type and covered it by tests
Closes #957 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7dfde8bf..6e8ff3b0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
 # Changelog
 
+## 1.2.3
+* Telemetry event's metadata `component_type` now correctly refers to the root type and not the implementing module [#958](https://github.com/membraneframework/membrane_core/pull/958)
+
 ## 1.2.2
  * Improve conditions for generating compilation warnings. [#956](https://github.com/membraneframework/membrane_core/pull/956)
 
diff --git a/lib/membrane/core/telemetry.ex b/lib/membrane/core/telemetry.ex
index 02c47a34..9426a3b2 100644
--- a/lib/membrane/core/telemetry.ex
+++ b/lib/membrane/core/telemetry.ex
@@ -176,16 +176,17 @@ defmodule Membrane.Core.Telemetry do
           Telemetry.callback_context()
         ) :: CallbackHandler.callback_return() | no_return()
   def track_callback_handler(f, callback, args, state, context) do
+    component_type = state_module_to_atom(state.__struct__)
+
     meta =
       callback_meta(
         state,
         callback,
         args,
-        context
+        context,
+        component_type
       )
 
-    component_type = state_module_to_atom(state.__struct__)
-
     if handler_reported?(component_type, callback) do
       :telemetry.span([:membrane, component_type, callback], meta, fn ->
         {_actions, int_state} = res = f.()
@@ -198,13 +199,13 @@ defmodule Membrane.Core.Telemetry do
     end
   end
 
-  defp callback_meta(state, callback, args, context) do
+  defp callback_meta(state, callback, args, context, component_type) do
     %{
       callback: callback,
       callback_args: args,
       callback_context: context,
       component_path: ComponentPath.get(),
-      component_type: state.module,
+      component_type: component_type,
       monotonic_time: System.monotonic_time(),
       state_before_callback: state.internal_state,
       state_after_callback: nil
diff --git a/mix.exs b/mix.exs
index e6d4d079..01005c85 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,7 +1,7 @@
 defmodule Membrane.Mixfile do
   use Mix.Project
 
-  @version "1.2.2"
+  @version "1.2.3"
   @source_ref "v#{@version}"
 
   def project do


Test patch:
diff --git a/test/membrane/telemetry_test.exs b/test/membrane/telemetry_test.exs
index 8d3dee49..e87e2c06 100644
--- a/test/membrane/telemetry_test.exs
+++ b/test/membrane/telemetry_test.exs
@@ -110,10 +110,11 @@ defmodule Membrane.TelemetryTest do
 
         assert_receive {^ref, :telemetry_ack,
                         {[:membrane, :element, ^span, :stop], results,
-                         %{component_path: [_, ^element_type]}}},
+                         %{component_path: [_, ^element_type]} = metadata}},
                        1000
 
         assert results.duration >= 0
+        assert metadata.component_type == :element
       end
     end
   end