Skip to content

Conversation

hsanjuan
Copy link
Contributor

@hsanjuan hsanjuan commented Jul 14, 2025

Currently, IP Shipyard, with the help of Probelab, monitor and extract Amino/IPFS public network metrics with the use of DHT crawlers and bootstrappers (via peerlog plugin). For example, we log all peer IDs seen and their AgentVersion/Addresses obtained from the identify protocol, which provides insights into protocol usage, total number of peers etc.

We would like to increase the ability to obtain more insights from the network by collecting some more information but also to give users more control over this collection (i.e. opt-out). The information collected will not allow unique identification of anyone and is only used for aggregation.

This PR adds:

  • A new "telemetry" plugin is in charge of dealing with telemetry (of type "daemon internal")
  • On first run it generates a UUID and shows an info message to the user.
  • UUID is persistened to "telemetry_uuid"
  • Sends telemetry 15 minutes after boot and every 24h
  • LogEvent is the thing containing all the telemetry that is sent
  • Opt-out possible via env-var or plugin configuration

Telemetry submission consists in a POST request to a telemetry-collecting HTTP endpoint.


This work is part of roadmap sponsored by IPFS Foundation:

hsanjuan added 4 commits June 20, 2025 19:00
Currently, IP Shipyard, with the help of Probelab, monitor and extract
Amino/IPFS public network metrics with the use of DHT crawlers and
bootstrappers (via peerlog plugin). For example, we log all peer IDs seen and
their AgentVersion/Addresses obtained from the `identify` protocol, which
provides insights into protocol usage, total number of peers etc.

We would like to increase the ability to obtain more insights from the network
by collecting some more information in the future, but also to give users more
control over this collection (i.e. opt-out). The information collected will
not allow unique identification of anyone and is only used for aggregation.

Now, this PR explores a way of moving in this direction:

* A new "telemetry" fx plugin is in charge of dealing with telemetry
* The FX plugin allows to plug and make decisions / take actions during the setup phase:
  * We can inspect whether we are using Private Networks before the libp2p.Host has been initialized.
  * We can send telemetry after the libp2p Host is initialized.
  * Everything is self-contained. Custom builds can remove the plugin altogether without needing to surgically edit the code.

As for behaviour:

* The user can opt-in/out via EnvVar, file in the repo path or plugin configuration.
* Users on private networks or with custom bootstrappers are detected, offered a wall of text explaining why we need telemetry and invited to opt-in. Opt-out happens otherwise on a timeout (with no input). Their preferences are stored.
* Users on standard settings are opted-in by default. This is the status quo in Kubo already, except they don't get a chance to opt out.

The telemetry libp2p protocol is yet to be defined, but expect something similar to identify, with a protobuf being pushed to bootstrappers or to a specific telemetry node that we define. In the case of pnets, this will be done with a temporary peer.
* On first run it generates a UUID and shows a message to the user.
* UUID is persistend to "telemetry_uuid"
* Sends telemetry 1 minute after boot and every 24h
* LogEvent is the thing containing all the telemetry that is sent
* Opt-out possible via env-var or plugin configuration

TODO: server URL
@hsanjuan hsanjuan self-assigned this Jul 14, 2025
@hsanjuan hsanjuan marked this pull request as ready for review July 14, 2025 09:25
@hsanjuan hsanjuan requested a review from a team as a code owner July 14, 2025 09:25
@lidel lidel mentioned this pull request Jul 24, 2025
15 tasks
@lidel lidel self-requested a review July 29, 2025 14:29
@lidel lidel mentioned this pull request Jul 29, 2025
51 tasks
@hsanjuan hsanjuan requested a review from gammazero August 7, 2025 09:20
@hsanjuan hsanjuan changed the title Telemetry plugin: second pass Telemetry plugin Aug 7, 2025
lidel added 3 commits August 13, 2025 00:35
making it more obvious nothing was sent yet
and that user had 15m to out-out

plus some debug logs that confirm opt-out
@lidel lidel changed the title Telemetry plugin feat: telemetry plugin Aug 12, 2025
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

LGTM. @hsanjuan @gammazero if CI is green and changes I pushed look ok, feel free to Merge (squash):

  • Improved error handling if our endpoint is down or misbehaves (warning + 30s timeout)
  • Added tests to ensure opt-out is respected and UUID is removed
  • Updated ipfs daemon one-time notice to make it more clear that nothing was sent yet, and user had 15m to opt-out:
    $ ipfs init
    $ ipfs daemon
    Initializing daemon...
    Kubo version: 0.37.0-dev-0c1dc4d97
    Repo version: 16
    System version: amd64/linux
    Golang version: go1.24.6
    PeerID: 12D3KooWPP1uvLNhscFFQ1GgwCFNHhKX1653QwWdQUGaeCxRumB7
    Swarm listening on 127.0.0.1:4001 (TCP+UDP)
    Swarm listening on [::1]:4001 (TCP+UDP)
    Run 'ipfs id' to inspect announced and discovered multiaddrs of this node.
    
    
    ℹ️  Anonymous telemetry will be enabled in 15m0s
    
    Kubo will collect anonymous usage data to help improve the software:
    • What:  Feature usage and configuration (no personal data)
             Use GOLOG_LOG_LEVEL="telemetry=debug" to inspect collected data
    • When:  First collection in 15m0s, then every 24h
    • How:   HTTP POST to https://telemetry.ipshipyard.dev
             Anonymous ID: a21fc379-c3d9-4011-8aec-c8a648aee1d8
    
    No data sent yet. To opt-out before collection starts:
    • Set environment: IPFS_TELEMETRY_PLUGIN_MODE=optout
    • Or run: ipfs config Plugins.Plugins.telemetry.Config.Mode optout
    • Then restart daemon
    
    This message is shown only once.
    Learn more: https://github.com/ipfs/kubo/blob/master/docs/telemetry.md
    
    
    RPC API server listening on /ip4/127.0.0.1/tcp/5001
    WebUI: http://127.0.0.1:5001/webui
    Gateway server listening on /ip4/127.0.0.1/tcp/8080
    Daemon is ready

ipfs-webui tests weare trying to use addAbortListener from
node:events, which requires Node.js v20.5.0+, but the CI is using v18.14.0
Copy link
Contributor

@gammazero gammazero left a comment

Choose a reason for hiding this comment

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

Last set of changes looks good.

Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Lgtm.

Pushed cosmetic changes moving changelog entry bit down the list, and renaming IPFS_TELEMETRY_PLUGIN_MODE=optin|optout|info to IPFS_TELEMETRY=on|off|auto so it is more clear when its on/off and also easier to control default implicit behavior by following convention we have for other things.

Merging to include in 0.37.0-rc1 to gather feedback.

@lidel lidel merged commit 4255cc3 into master Aug 18, 2025
15 of 16 checks passed
@lidel lidel deleted the telemetry-plugin2 branch August 18, 2025 18:46
- `info`: Like `optin`, but logs an informative message about telemetry (default in the first run).
- `on`: Enables telemetry.
- `off`: Disables telemetry.
- `auto`: Like `on`, but logs an informative message about telemetry and gives user 15 minutes to opt-out before first collection. Used automatically on first run and when `IPFS_TELEMETRY` is not set.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Note the 15 minutes are not just during auto or during first run.)

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