[PR #567] feat: add prometheus metric #588

Open
opened 2026-02-16 01:16:25 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-plugin-daemon/pull/567
Author: @fatelei
Created: 1/11/2026
Status: 🔄 Open

Base: mainHead: issue-383


📝 Commits (3)

  • e96f524 feat: add prometheus metric
  • 8948c19 feat: add switch PrometheusEnabled
  • d72e9e9 chore: change metric collect position

📊 Changes

16 files changed (+604 additions, -9 deletions)

View changed files

📝 .env.example (+3 -0)
📝 go.mod (+9 -2)
📝 go.sum (+16 -2)
internal/core/control_panel/metrics_notifier.go (+107 -0)
internal/core/control_panel/metrics_notifier_test.go (+127 -0)
📝 internal/core/plugin_manager/manager.go (+1 -0)
📝 internal/server/http_server.go (+9 -0)
📝 internal/server/middleware.go (+19 -0)
internal/server/middleware_test.go (+56 -0)
📝 internal/service/base_sse.go (+98 -0)
internal/service/base_sse_test.go (+23 -0)
📝 internal/service/install_plugin.go (+1 -1)
📝 internal/tasks/install_plugin.go (+16 -0)
📝 internal/types/app/config.go (+2 -0)
pkg/utils/metrics/metrics.go (+115 -0)
📝 pkg/utils/parser/identity.go (+2 -4)

📄 Description

Description

fix #383

Example Metrics

Visit http://localhost:5002/metrics to see:

Plugin invocation count

plugin_invocations_total{plugin_id="openai",plugin_type="model",runtime_type="local",operation="invoke_llm",status="success"} 1234

Plugin invocation latency (histogram)

plugin_invocation_duration_seconds{plugin_id="openai",plugin_type="model",runtime_type="local",operation="invoke_llm"}

Current active invocations

plugin_invocations_active{plugin_id="openai",plugin_type="model",runtime_type="local"} 2

Plugin runtime status

plugin_runtime_status{plugin_id="openai",runtime_type="local"} 1

Active plugins

active_plugins_total{runtime_type="local"} 15

Plugin installation count

plugin_installations_total{plugin_id="openai",status="success"} 5

Plugin restart count

plugin_restarts_total{plugin_id="openai",runtime_type="local"} 1

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • Other

Essential Checklist

Testing

  • I have tested the changes locally and confirmed they work as expected
  • I have added unit tests where necessary and they pass successfully

Bug Fix (if applicable)

  • I have used GitHub syntax to close the related issue (e.g., Fixes #123 or Closes #123)

Additional Information

Please provide any additional context that would help reviewers understand the changes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langgenius/dify-plugin-daemon/pull/567 **Author:** [@fatelei](https://github.com/fatelei) **Created:** 1/11/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `issue-383` --- ### 📝 Commits (3) - [`e96f524`](https://github.com/langgenius/dify-plugin-daemon/commit/e96f524ec3753d95d1acf94e95727d3d76ec4d39) feat: add prometheus metric - [`8948c19`](https://github.com/langgenius/dify-plugin-daemon/commit/8948c1954efb2ce69df7752be857fdc4dfc58eae) feat: add switch PrometheusEnabled - [`d72e9e9`](https://github.com/langgenius/dify-plugin-daemon/commit/d72e9e95f7d0e71ff0a2574b99d874d26e44e69e) chore: change metric collect position ### 📊 Changes **16 files changed** (+604 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+3 -0) 📝 `go.mod` (+9 -2) 📝 `go.sum` (+16 -2) ➕ `internal/core/control_panel/metrics_notifier.go` (+107 -0) ➕ `internal/core/control_panel/metrics_notifier_test.go` (+127 -0) 📝 `internal/core/plugin_manager/manager.go` (+1 -0) 📝 `internal/server/http_server.go` (+9 -0) 📝 `internal/server/middleware.go` (+19 -0) ➕ `internal/server/middleware_test.go` (+56 -0) 📝 `internal/service/base_sse.go` (+98 -0) ➕ `internal/service/base_sse_test.go` (+23 -0) 📝 `internal/service/install_plugin.go` (+1 -1) 📝 `internal/tasks/install_plugin.go` (+16 -0) 📝 `internal/types/app/config.go` (+2 -0) ➕ `pkg/utils/metrics/metrics.go` (+115 -0) 📝 `pkg/utils/parser/identity.go` (+2 -4) </details> ### 📄 Description ## Description fix #383 # Example Metrics Visit http://localhost:5002/metrics to see: # Plugin invocation count plugin_invocations_total{plugin_id="openai",plugin_type="model",runtime_type="local",operation="invoke_llm",status="success"} 1234 # Plugin invocation latency (histogram) plugin_invocation_duration_seconds{plugin_id="openai",plugin_type="model",runtime_type="local",operation="invoke_llm"} # Current active invocations plugin_invocations_active{plugin_id="openai",plugin_type="model",runtime_type="local"} 2 # Plugin runtime status plugin_runtime_status{plugin_id="openai",runtime_type="local"} 1 # Active plugins active_plugins_total{runtime_type="local"} 15 # Plugin installation count plugin_installations_total{plugin_id="openai",status="success"} 5 # Plugin restart count plugin_restarts_total{plugin_id="openai",runtime_type="local"} 1 ## Type of Change - [ ] Bug fix - [x] New feature - [ ] Refactor - [ ] Performance improvement - [ ] Other ## Essential Checklist ### Testing - [x] I have tested the changes locally and confirmed they work as expected - [x] I have added unit tests where necessary and they pass successfully ### Bug Fix (if applicable) - [x] I have used GitHub syntax to close the related issue (e.g., `Fixes #123` or `Closes #123`) ## Additional Information Please provide any additional context that would help reviewers understand the changes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 01:16:25 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugin-daemon#588