Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: opentelementry support #14668

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

incubator4
Copy link
Contributor

Involved Issue / 该 PR 相关 Issue

Close #

Example for the Proposed Route(s) / 路由地址示例

NOROUTE

New RSS Route Checklist / 新 RSS 路由检查表

  • New Route / 新的路由
  • Documentation / 文档说明
  • Full text / 全文获取
    • Use cache / 使用缓存
  • Anti-bot or rate limit / 反爬/频率限制
    • If yes, do your code reflect this sign? / 如果有, 是否有对应的措施?
  • Date and time / 日期和时间
    • Parsed / 可以解析
    • Correct time zone / 时区正确
  • New package added / 添加了新的包
  • Puppeteer

Note / 说明

Implement opentelementry feature metrics and trace

Metrics

metrics endpoint with /metrics
labels:

  • method http method (example: GET/POST)
  • path request path
  • status response return status code
  • unit only for bucket (example: second/millisecond)

The following metric name supported for now.

  • request_total record request with params
  • request_error_total record request error with params
  • request_duration_seconds_bucket record request second with params
  • request_duration_milliseconds_bucket record request millisecond with params

trace

trace with opentelementry OTLP exporter, which could be collected by jaeger (for example)
endpoint follow OpenTelemetry Specification on Protocol Exporter.

@github-actions github-actions bot added dependencies This PR involves changes to dependencies core enhancement labels Mar 5, 2024
@incubator4 incubator4 changed the title Feat/otel feat: opentelementry support Mar 5, 2024
@incubator4 incubator4 closed this Mar 5, 2024
@incubator4 incubator4 reopened this Mar 5, 2024
@github-actions github-actions bot added the Auto: Route Test Skipped PR involves no routes label Mar 5, 2024
},
});

export const metric_handler = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
export const metric_handler = {
export const metric = {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if the rename is necessary, the metric_handler here is just a wrapper around the aggregated metrics counter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or any other better var name?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

@TonyRL TonyRL left a comment

Choose a reason for hiding this comment

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

Please fix your git history. There shouldn't be 2000+ changed files.

@incubator4 incubator4 force-pushed the feat/otel branch 2 times, most recently from 2f42b79 to 704d639 Compare March 8, 2024 02:41
lib/errors/index.tsx Fixed Show fixed Hide fixed
Comment on lines +54 to +60
"@opentelemetry/api": "^1.8.0",
"@opentelemetry/exporter-prometheus": "^0.49.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.49.1",
"@opentelemetry/resources": "^1.22.0",
"@opentelemetry/sdk-metrics": "^1.22.0",
"@opentelemetry/sdk-trace-base": "^1.22.0",
"@opentelemetry/semantic-conventions": "^1.22.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"@opentelemetry/api": "^1.8.0",
"@opentelemetry/exporter-prometheus": "^0.49.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.49.1",
"@opentelemetry/resources": "^1.22.0",
"@opentelemetry/sdk-metrics": "^1.22.0",
"@opentelemetry/sdk-trace-base": "^1.22.0",
"@opentelemetry/semantic-conventions": "^1.22.0",
"@opentelemetry/api": "1.8.0",
"@opentelemetry/exporter-prometheus": "0.49.1",
"@opentelemetry/exporter-trace-otlp-http": "0.49.1",
"@opentelemetry/resources": "1.22.0",
"@opentelemetry/sdk-metrics": "1.22.0",
"@opentelemetry/sdk-trace-base": "1.22.0",
"@opentelemetry/semantic-conventions": "1.22.0",

Please pin the dependency version.

@@ -158,6 +158,16 @@ Access code is the md5 generated based on the access key + route, eg:

`SENTRY_ROUTE_TIMEOUT`: Report Sentry if route execution takes more than this milliseconds, default to `3000`

## Opentelementry Config
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
## Opentelementry Config
## OpenTelemetry Config

@@ -27,6 +28,7 @@ const app = new Hono();
app.use(compress());

app.use(mLogger);
app.use(trace);
Copy link
Collaborator

Choose a reason for hiding this comment

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

If DEBUG_INFO is set to false or any strings other than true, the debug info from RSSHub will be hidden and only available if the same string is provided as query string debug.

/metrics does not respect this behaviour currently.

The same also apply to ACCESS_KEY.

if (requestPath === '/' || requestPath === '/robots.txt' || requestPath === '/metrics') {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basicly, metrics should be export with a external local port. In that case rsshub may handle another port with 127.0.0.1:9090 for example.
I'm not sure if an external port should be created, but it might be a better solution than modify if else for access-control.
And also should be with env to control local server enable or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto: Route Test Skipped PR involves no routes core enhancement dependencies This PR involves changes to dependencies Route: deprecated Route
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants