Skip to content

Conversation

@alco
Copy link
Member

@alco alco commented Nov 10, 2025

Extract telemetry code from Electric into a separate package. On top of that, the new package accepts additional user-provided periodic measurements and metric definitions for otel/prometheus exporters; both exporters now use the same list of metrics.

One thing that's been lost in this move is the stack_id sentry tag inside the CallHomeRepoter process. Sentry is a dependency of Electric and there's no straightforward way of propagating it into CallHomeReporter which is a module in the electric_telemetry dependency now. I don't feel like it's a big loss because we set stack_id in the logger metadata for that process, as well as mention it in the process name and label.

With this merged, we can delete the electric-sql/electric-telemetry repo.

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

❌ Patch coverage is 8.84615% with 237 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.00%. Comparing base (abc5e09) to head (93eed43).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
...metry/lib/electric/telemetry/call_home_reporter.ex 0.00% 94 Missing ⚠️
...ry/lib/electric/telemetry/application_telemetry.ex 22.54% 79 Missing ⚠️
...elemetry/lib/electric/telemetry/stack_telemetry.ex 0.00% 18 Missing ⚠️
...electric/telemetry/reporters/call_home_reporter.ex 0.00% 16 Missing ⚠️
...lectric-telemetry/lib/electric/telemetry/poller.ex 0.00% 13 Missing ⚠️
...try/lib/electric/telemetry/reporters/prometheus.ex 0.00% 6 Missing ⚠️
...lemetry/lib/electric/telemetry/reporters/statsd.ex 0.00% 6 Missing ⚠️
...telemetry/lib/electric/telemetry/reporters/otel.ex 0.00% 3 Missing ⚠️
.../electric-telemetry/lib/electric/telemetry/opts.ex 0.00% 1 Missing ⚠️
...telemetry/lib/electric/telemetry/system_monitor.ex 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3412      +/-   ##
==========================================
+ Coverage   67.54%   75.00%   +7.46%     
==========================================
  Files         180       50     -130     
  Lines        9672     2657    -7015     
  Branches      360      382      +22     
==========================================
- Hits         6533     1993    -4540     
+ Misses       3137      662    -2475     
  Partials        2        2              
Flag Coverage Δ
electric-telemetry 22.71% <8.84%> (?)
elixir 57.74% <8.84%> (-6.40%) ⬇️
elixir-client 74.47% <ø> (+0.52%) ⬆️
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/typescript-client 93.62% <ø> (+0.05%) ⬆️
packages/y-electric 55.12% <ø> (ø)
postgres-140000 ?
postgres-150000 ?
postgres-170000 ?
sync-service ?
typescript 87.53% <ø> (+0.46%) ⬆️
unit-tests 75.00% <8.84%> (+7.46%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@netlify
Copy link

netlify bot commented Nov 10, 2025

Deploy Preview for electric-next ready!

Name Link
🔨 Latest commit 8fedf3d
🔍 Latest deploy log https://app.netlify.com/projects/electric-next/deploys/69147aa30d752b0008e83cd3
😎 Deploy Preview https://deploy-preview-3412--electric-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@alco alco marked this pull request as ready for review November 10, 2025 23:25
@msfstef
Copy link
Contributor

msfstef commented Nov 11, 2025

Why not keep https://github.com/electric-sql/electric-telemetry as part of our mono-repo as another elixir project? Easier to access and work with.

@alco
Copy link
Member Author

alco commented Nov 11, 2025

@msfstef Main reason is decoupling.

Our primary use case for telemetry is in Electric Cloud. So if we're going to make any changes to the telemetry code, it'll be informed by Cloud and should be tested first in Cloud. All while Electric keeps using its own stable version of the lib.

How can we achieve that?

  1. Keep electric-telemetry in a separate repo and pin Cloud and Electric to different commits.
  2. Publish electric-telemetry on Hex and pin different versions of the package in the two repos.

Moving electric-telemetry into Electric's repo would work fine with the 2nd option but I'm against publishing our telemetry as a Hex package since it is only ever going to work as part of Electric.

With the 1st option it becomes awkward: we cannot use electric-telemetry in Electric as a path dependency because then Electric will necessarily always use the latest version of it. And the alternative is to pull it from Github (i.e. {:electric_telemetry, github: "electric-sql/electric", path: "packages/electric-telemetry", ref: "..."}), even though it's part of the same repo as Electric itself?

@alco alco force-pushed the alco/electric-telemetry branch 4 times, most recently from 66f1c97 to 8fedf3d Compare November 12, 2025 12:16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a bunch of tests still in place for these, and I suspect they are still passing because we're reusing the Electric.Telemetry namespace, whereas I think this should now be in ElectricTelemetry, and the tests should move to the new repo, no?

@alco alco force-pushed the alco/electric-telemetry branch 3 times, most recently from e9756ff to 4f74858 Compare November 18, 2025 12:13
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 18, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@electric-sql/react@3412
npm i https://pkg.pr.new/@electric-sql/client@3412
npm i https://pkg.pr.new/@electric-sql/y-electric@3412

commit: acf1224

@alco alco force-pushed the alco/electric-telemetry branch 6 times, most recently from dc3c87c to e3b5328 Compare November 19, 2025 12:01
alco added 9 commits November 19, 2025 13:04
These settings must be set in Electric and in Cloud, so using a single
function helps avoid discrepancies.
This way, the electric_telemetry dependency can be included or excluded
as a whole. And conditional compilation is only relevant to Electric
anyway.
The telemetry library doesn't actually use Sentry. Cloud has its own
setup for it, so electric_telemetry is not the right place for it.
Once telemetry is enabled via MIX_TARGET=application, making individual
deps optional only puts the burden on the parent app to include them
directly. We want it the other way around: let the telemetry library
define its deps and fetch them.
The way to enable electric_telemetry is to set MIX_TARGET=application.
In Cloud it is always enabled anyway.
@alco alco force-pushed the alco/electric-telemetry branch from e3b5328 to a8fa894 Compare November 19, 2025 12:15
@alco alco force-pushed the alco/electric-telemetry branch from a8fa894 to acf1224 Compare November 19, 2025 12:31
alco added 3 commits November 19, 2025 16:02
It is now used by electric_telemetry
This version fixes an issue with unintentional overriding of OTLP
headers
Chasing a bug in metric export via Otel...
@alco alco force-pushed the alco/electric-telemetry branch from 732c6de to 93eed43 Compare November 20, 2025 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants