尧图网站设计 尧图网站设计YAOTU DESIGN
ARTICLE DETAIL

资讯详情

深耕网站设计与一线实操的经验洞察。

Coroot 匿名使用统计机制详解:收集了哪些数据、底层如何采集以及如何彻底关闭

Coroot 匿名使用统计机制详解:收集了哪些数据、底层如何采集以及如何彻底关闭 Coroot 匿名使用统计机制详解收集了哪些数据、底层如何采集以及如何彻底关闭【免费下载链接】corootCoroot is an open-source observability and APM tool with AI-powered Root Cause Analysis. It combines metrics, logs, traces, continuous profiling, and SLO-based alerting with predefined dashboards and inspections.项目地址: https://gitcode.com/GitHub_Trending/co/corootCoroot 默认开启匿名使用统计Anonymous usage statistics用于帮助项目维护者了解社区的使用情况从而改进产品。本文基于 Coroot 官方文档 anonymous-usage-statistics.md 并结合 stats/stats.go、config/flags.go 等源码实现完整解析上报 payload 的每个字段含义、数据采集与上报的底层调用链以及通过命令行参数、环境变量和 Kubernetes Operator 关闭统计的多种实操方式。一、设计原则数据完全匿名默认开启可随时退出Coroot 官方文档明确指出To improve Coroot we collect anonymous usage statistics. The collection of statistics is enabled by default, but you can opt out at any time.即统计功能默认开启用户可以在任何时候通过 opt-out 方式关闭。上报的数据不包含任何可识别个人或租户身份的信息实例用首次启动时生成并持久化的随机 UUID 标识浏览器端用前端生成的随机 device UUID 标识基础设施信息只上报聚合数量项目数、应用数、节点数等不上报任何名称、IP、域名或业务数据。二、上报 Payload 全景解析文档中给出了一个完整的上报 payload 示例它由instance、integration、stack、infra、ux、performance、profile七个顶层部分组成与 stats/stats.go 中Stats结构的 JSON tag 一一对应{ instance: { uuid: 4423595b-9d97-4e01-a19f-8e3d60c83b2a, // generated upon the first startup and stored in data-dir/instance.uuid version: 0.20.0, // Coroot version database_type: sqlite // the type of database being used }, integration: { prometheus: true, // shows whether a Prometheus integration has been configured or not node_agent: true, // shows whether Coroot has seen the metrics gathered by node-agent or not kube_state_metrics: true, // shows whether Coroot has seen the metrics gathered by kube-state-metrics or not inspection_overrides: { // the number of overridden inspection thresholds CPUNode: {project_level: 1, application_level: 2}, NetworkRTT: {project_level: 0, application_level: 1} }, application_categories: 3, // the number of configured application categories alerting_integrations: [slack], // configured alerting integration types cloud_costs: true, // shows if prices are available for the cloud in use clickhouse: true, // whether a Clickhouse integration is configured tracing: true, // whether Distributed Tracing is enabled logs: true, // whether Logs Monitoring is enabled profiles: true, // whether Continuous Profiling is enabled fluxcd: true, // whether Coroot has seen FluxCD resources argocd: true // whether Coroot has seen ArgoCD applications }, stack: { clouds: [aws, hetzner, ovh], // based on the node_cloud_info metric services: [pgbouncer, postgres, redis], // based on the container_application_type metric instrumented_service: [postgres, redis] // the services monitored by the relevant exporters, such as pg-agent or redis_exporter }, infra: { projects: 2, // the number of configured projects applications: 18, // the total number of applications nodes: 10, // the total number of nodes gpus: 4, // the total number of GPUs across all nodes instances: 50, // the total number of application instances (containers) deployments: 1, // the number of application rollouts deployment_summaries: {-CPU: 1, Logs: 1, -Memory: 1} // the number of notable changes during new deployments by type }, ux: { users_by_screen_size: { // the number of browsers by display breakpoints (https://vuetifyjs.com/en/features/breakpoints/) xs: 1, lg: 7, xl: 5 }, users: [ // browser UUIDs 20174a56-4a1e-41ca-a90d-b657d1fa873e ], page_views: { // the number of page views by type /p/$projectId: 1, /p/$projectId/app/$id/SLO: 3 }, world_load_time_avg: 0.053, // the average time to load telemetry from the Prometheus cache audit_time_avg: 0.011, // the average time to audit telemetry sent_notifications: {slack: 4} // the number of sent notifications by destination }, performance: { constructor: { stages: { // the maximum time to load and process metrics from the Prometheus cache query: 0.022014374, load_rds: 0.000004882, load_nodes: 0.000139763, join_db_cluster: 0.000008697, load_containers: 0.017340304, enrich_instances: 0.002621411, load_k8s_metadata: 0.000543033 }, queries: { // per Prometheus query statistics: result set size, latency and status node_info: { failed: false, query_time: 0.012892758, metrics_count: 4 }, // ... container_net_latency: { failed: false, query_time: 0.015887205, metrics_count: 130 } } }, cpu_usage: [0.079, 0,071, ...], // CPU usage of the Coroot process memory_usage: [27086848, 27086848, ...], // memory usage of the Coroot process }, profile: { from: 1678113877, to: 1678114877, cpu: ..., // base64-encoded CPU profile in the pprof format memory: ... // base64-encoded memory profile in the pprof format } }instance实例身份标识uuid实例 UUID。首次启动时生成持久化在数据目录的instance.uuid文件中。对应源码 utils/dir.go 中的GetInstanceUuid读取data-dir/instance.uuid若文件不存在或内容不是合法 UUID则用uuid.NewString()生成新的并写回文件。因此该标识在实例生命周期内稳定不变但随机且不可反推任何身份信息。versionCoroot 版本号。database_type使用的元数据库类型如sqlite或 Postgres。从源码结构看Stats.Instance结构stats/stats.go还包含editionCE/EE 版本标识与installation_type读取自环境变量INSTALLATION_TYPE用于区分安装形态帮助维护者定位不同部署方式的兼容问题。integration已配置的功能与集成该部分只记录功能开关状态布尔值或类型名称列表不涉及任何连接地址或凭据字段含义prometheus是否配置了 Prometheus 集成node_agentCoroot 是否见过node-agent采集的节点指标kube_state_metrics是否见过kube-state-metrics的指标inspection_overrides被用户覆盖过的巡检Inspection阈值数量按巡检 ID 区分项目级与应用级application_categories已配置的应用分类数量alerting_integrations已配置的告警通知渠道类型列表如slackcloud_costs当前使用的云是否可查到价格用于成本功能clickhouse/tracing/logs/profiles是否配置 ClickHouse 集成、启用分布式追踪、日志监控、持续剖析fluxcd/argocd是否检测到 FluxCD 资源 / ArgoCD 应用从源码实现看这些状态是在collect()stats/stats.go中遍历各项目配置与world数据时逐项判定并置位的例如配置了 ClickHouse 地址时会同时把clickhouse、tracing、logs、profiles置为trueL395-L400fluxcd/argocd则取决于world中是否加载到了相应资源L467-L472。stack技术栈构成clouds基于node_cloud_info指标推断出的云厂商列表小写services基于container_application_type指标得到的服务类型列表instrumented_services被对应 exporter如pg-agent、redis_exporter监控的服务类型。源码中对应Stack.Clouds / Services / InstrumentedServices三个*utils.StringSet字段stats/stats.go聚合自节点与应用实例的元数据。infra基础设施规模仅聚合数量上报的均为总数而非明细项目数、应用总数、节点总数、GPU 总数、应用实例容器总数、最近一小时内的滚动发布deployment数量以及按类型统计的部署变更摘要如Logs表示新部署中日志相关的正向变化数量。从源码看stats/stats.go只有开始时间距当前不足一小时的 rollout 会被计入deployments其摘要条目按/-前缀区分改善与劣化。ux使用体验与交互users_by_screen_size按屏幕断点Vuetify breakpoint如xs/lg/xl统计的浏览器数量users浏览器端随机 UUID 列表不是用户身份page_views按路由模板统计的页面浏览量world_load_time_avg从 Prometheus 缓存加载 telemetry 的平均耗时秒audit_time_avg对 telemetry 执行审计audit的平均耗时秒sent_notifications按通知渠道统计的已发送通知数量。前端埋点链路front/src/main.js 在路由变化时调用api.stats(route-open, { path: p })front/src/api.js 首次访问时生成并持久化随机device-id存于 localStorage随请求附带device_idfront/src/api.js。服务端Collector.RegisterRequeststats/stats.go据此累加页面浏览、按屏幕尺寸/主题去重统计浏览器数量。performanceCoroot 自身性能画像constructor.stages从 Prometheus 缓存加载与处理各阶段query、load_nodes、load_containers 等的最大耗时constructor.queries逐条 Prometheus 查询的统计——是否失败、查询耗时、返回指标数量cpu_usage/memory_usageCoroot 进程自身的 CPU 与内存使用序列。这部分用于让维护者了解不同规模部署下 Coroot 自身的性能表现。profilepprof 剖析数据from/to界定采样窗口cpu与memory是 base64 编码的 pprof 格式 CPU/内存剖析。源码send()stats/stats.go在每次上报前用pprof.StartCPUProfile包裹一次collect()过程采集 CPU profile并用godeltaprof.HeapProfiler采集堆增量 profile随 payload 一并上报——这样维护者可以在不侵入用户集群的前提下观察 Coroot 进程的真实 CPU/内存热点。三、数据采集与上报的实现机制核心实现集中在 stats/stats.go启动与调度main.go 先通过utils.GetInstanceUuid(cfg.DataDir)取得实例 UUIDmain.go 调用stats.NewCollector(...)创建采集器。若未禁用统计NewCollectorstats/stats.go会立即执行一次send()随后以collectInterval 1h为周期定时上报stats/stats.goHTTP 客户端超时sendTimeout 1min。采集逻辑collect()遍历所有非多集群代理的项目逐个加载最近一小时worldWindow timeseries.Hour的 world 数据顺带记录LoadWorld与auditor.Audit的耗时作为world_load_time_avg/audit_time_avg并累加节点、应用、云厂商、服务类型等聚合统计。上报目标数据 POST 到 stats/stats.go 中硬编码的收集端点https://coroot.com/ce/usage-statistics常量collectUrl。官方文档说明Coroot Inc 将这些统计仅用于自身产品改进不会与任何第三方共享。容错上报失败只记录错误日志klog.Errorln(failed to send stats:, ...)不影响 Coroot 主流程collect()中单个项目的加载失败会continue跳过不会中断整体采集。本地可观测Collector.Stats是一个 API handlerstats/stats.goMiddleWare还会统计所有/api/路径的调用次数便于本地验证采集内容。四、如何关闭使用统计官方提供命令行参数--disable-usage-statistics其定义在 config/flags.godisableUsageStatistics kingpin.Flag(disable-usage-statistics, Disable usage statistics).Envar(DISABLE_USAGE_STATISTICS).Bool()关键点该 flag 同时绑定环境变量DISABLE_USAGE_STATISTICS因此 CLI 参数、环境变量两种方式等价该值最终写入配置结构Config.DisableUsageStatisticsconfig/config.goYAML 字段名disable_usage_statistics由 main.go 传给stats.NewCollectordisabled true时采集器不启动任何定时上报 goroutine。方式一Docker 直接传参docker run ... ghcr.io/coroot/coroot --disable-usage-statistics方式二Kubernetes Operator通过 Coroot CR 的 env 注入环境变量apiVersion: coroot.com/v1 kind: Coroot metadata: name: coroot namespace: coroot spec: env: - name: DISABLE_USAGE_STATISTICS value: true ...方式三配置文件与 flag 等价的 YAML 键见 config/config.godisable_usage_statistics: true关闭后实例仍会正常运行instance.uuid的生成与 UI 功能只是不再向收集端点发送任何统计 payload。五、小结Coroot 的匿名使用统计默认开启、每小时上报一次内容覆盖实例身份随机 UUID、功能集成状态、技术栈构成、基础设施聚合规模、UI 交互指标与 Coroot 自身性能画像含 pprof不含任何可识别个人或租户身份的数据数据只发送至 Coroot 官方收集端点仅用于产品改进不与第三方共享实现链路清晰可查utils.GetInstanceUuid→stats.NewCollector→collect()→send()关闭开关统一收口在--disable-usage-statistics/DISABLE_USAGE_STATISTICS/disable_usage_statistics三个等价入口若你的部署环境需要完全隔离出站流量或出于合规要求建议显式设置该开关这也正是官方文档给出的 opt-out 方式。【免费下载链接】corootCoroot is an open-source observability and APM tool with AI-powered Root Cause Analysis. It combines metrics, logs, traces, continuous profiling, and SLO-based alerting with predefined dashboards and inspections.项目地址: https://gitcode.com/GitHub_Trending/co/coroot创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表