Pārlūkot izejas kodu

docs: document pyroscope env var

Seefs 2 mēneši atpakaļ
vecāks
revīzija
531dfb2555
6 mainītis faili ar 15 papildinājumiem un 4 dzēšanām
  1. 2 0
      .env.example
  2. 2 0
      README.en.md
  3. 2 0
      README.fr.md
  4. 2 0
      README.ja.md
  5. 2 0
      README.md
  6. 5 4
      common/pyro.go

+ 2 - 0
.env.example

@@ -14,6 +14,8 @@
 # PYROSCOPE_APP_NAME=new-api
 # PYROSCOPE_BASIC_AUTH_USER=your-user
 # PYROSCOPE_BASIC_AUTH_PASSWORD=your-password
+# PYROSCOPE_MUTEX_RATE=5
+# PYROSCOPE_BLOCK_RATE=5
 # HOSTNAME=your-hostname
 
 # 数据库相关配置

+ 2 - 0
README.en.md

@@ -311,6 +311,8 @@ docker run --name new-api -d --restart always \
 | `PYROSCOPE_APP_NAME` | Pyroscope application name | `new-api` |
 | `PYROSCOPE_BASIC_AUTH_USER` | Pyroscope basic auth user | - |
 | `PYROSCOPE_BASIC_AUTH_PASSWORD` | Pyroscope basic auth password | - |
+| `PYROSCOPE_MUTEX_RATE` | Pyroscope mutex sampling rate | `5` |
+| `PYROSCOPE_BLOCK_RATE` | Pyroscope block sampling rate | `5` |
 | `HOSTNAME` | Hostname tag for Pyroscope | `new-api` |
 
 📖 **Complete configuration:** [Environment Variables Documentation](https://docs.newapi.pro/installation/environment-variables)

+ 2 - 0
README.fr.md

@@ -307,6 +307,8 @@ docker run --name new-api -d --restart always \
 | `PYROSCOPE_APP_NAME` | Nom de l'application Pyroscope | `new-api` |
 | `PYROSCOPE_BASIC_AUTH_USER` | Utilisateur Basic Auth Pyroscope | - |
 | `PYROSCOPE_BASIC_AUTH_PASSWORD` | Mot de passe Basic Auth Pyroscope | - |
+| `PYROSCOPE_MUTEX_RATE` | Taux d'échantillonnage mutex Pyroscope | `5` |
+| `PYROSCOPE_BLOCK_RATE` | Taux d'échantillonnage block Pyroscope | `5` |
 | `HOSTNAME` | Nom d'hôte tagué pour Pyroscope | `new-api` |
 
 📖 **Configuration complète:** [Documentation des variables d'environnement](https://docs.newapi.pro/installation/environment-variables)

+ 2 - 0
README.ja.md

@@ -316,6 +316,8 @@ docker run --name new-api -d --restart always \
 | `PYROSCOPE_APP_NAME` | Pyroscopeアプリ名 | `new-api` |
 | `PYROSCOPE_BASIC_AUTH_USER` | Pyroscope Basic Authユーザー | - |
 | `PYROSCOPE_BASIC_AUTH_PASSWORD` | Pyroscope Basic Authパスワード | - |
+| `PYROSCOPE_MUTEX_RATE` | Pyroscope mutexサンプリング率 | `5` |
+| `PYROSCOPE_BLOCK_RATE` | Pyroscope blockサンプリング率 | `5` |
 | `HOSTNAME` | Pyroscope用のホスト名タグ | `new-api` |
 
 📖 **完全な設定:** [環境変数ドキュメント](https://docs.newapi.pro/installation/environment-variables)

+ 2 - 0
README.md

@@ -312,6 +312,8 @@ docker run --name new-api -d --restart always \
 | `PYROSCOPE_APP_NAME` | Pyroscope 应用名                                        | `new-api` |
 | `PYROSCOPE_BASIC_AUTH_USER` | Pyroscope Basic Auth 用户名                        | - |
 | `PYROSCOPE_BASIC_AUTH_PASSWORD` | Pyroscope Basic Auth 密码                  | - |
+| `PYROSCOPE_MUTEX_RATE` | Pyroscope mutex 采样率                               | `5` |
+| `PYROSCOPE_BLOCK_RATE` | Pyroscope block 采样率                               | `5` |
 | `HOSTNAME` | Pyroscope 标签里的主机名                                          | `new-api` |
 
 📖 **完整配置:** [环境变量文档](https://docs.newapi.pro/installation/environment-variables)

+ 5 - 4
common/pyro.go

@@ -18,10 +18,11 @@ func StartPyroScope() error {
 	pyroscopeBasicAuthPassword := GetEnvOrDefaultString("PYROSCOPE_BASIC_AUTH_PASSWORD", "")
 	pyroscopeHostname := GetEnvOrDefaultString("HOSTNAME", "new-api")
 
-	// These 2 lines are only required if you're using mutex or block profiling
-	// Read the explanation below for how to set these rates:
-	runtime.SetMutexProfileFraction(5)
-	runtime.SetBlockProfileRate(5)
+	mutexRate := GetEnvOrDefault("PYROSCOPE_MUTEX_RATE", 5)
+	blockRate := GetEnvOrDefault("PYROSCOPE_BLOCK_RATE", 5)
+
+	runtime.SetMutexProfileFraction(mutexRate)
+	runtime.SetBlockProfileRate(blockRate)
 
 	_, err := pyroscope.Start(pyroscope.Config{
 		ApplicationName: pyroscopeAppName,