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(infra): add opentelemetry metric instrumentation #1375

Merged
merged 27 commits into from
Mar 14, 2024

Conversation

ssupecial
Copy link
Collaborator

@ssupecial ssupecial commented Feb 13, 2024

Description

Close #1298

opentelemetry metric 데이터를 수집하기 위해 [backend의 client와 admin] 과 [iris]에 opentelemetry 코드를 추가하였습니다.
api 서버는 CPU, Memory, Network 데이터를, iris서버는 CPU, Memory 정보를 수집합니다.
API Server의 경우, apps/backend/apps/client/src 와 apps/backend/apps/admin/src폴더에 metric.ts 를 생성하여 모듈을 생성하였고, main.ts 에서 해당 모듈을 import하여 사용하였습니다.
IRIS Server의 경우 apps/iris/src/observability/ 에 metric.go를 생성하여 main.go에서 이를 받아와 meter를 수집합니다.
opentelemetry 관련된 여러 패키지를 설치하였습니다.

API Server

  • metric.ts 로 모듈 생성 -> import 하여 사용
  • CPU, Memory, Network Metric을 자동으로 수집해주는 host-metrics 패키지를 이용합니다.
  • 추가한 패키지
    • @opentelemetry/host-metrics
    • @opentelemetry/exporter-metrics-otlp-http
    • @opentelemetry/sdk-metrics
    • @opentelemetry/resources
    • @opentelemetry/semantic-conventions

IRIS Server

  • metric.go로 MeterProvider를 만들고, 이를 통해 main.go 에서 필요한 metric정보를 얻기 위해 수동으로 생성합니다. (ts진영처럼 자동으로 metric정보를 얻기 위한 sdk가 opentelemetry쪽에서 아직 개발중입니다.
  • Asynchronous 측정이라 별도의 goroutine의 도움은 필요 없다고 생각됩니다.
  • 추가한 패키지
    • github.com/shirou/gopsutil
    • go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp
    • go.opentelemetry.io/otel/metric
    • go.opentelemetry.io/otel/sdk/metric

Additional context


Before submitting the PR, please make sure you do the following

@ssupecial ssupecial requested review from goathoon and k1g99 February 13, 2024 08:56
Copy link

vercel bot commented Feb 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
codedang ✅ Ready (Inspect) Visit Preview Mar 14, 2024 7:04am

Copy link
Collaborator

@k1g99 k1g99 left a comment

Choose a reason for hiding this comment

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

apps/frontend/app 에 있는 파일들은 다시 최신 main 브랜치로 merge main 해야할 것 같아요!
현재 main 에는 없는 파일들입니다

Copy link
Collaborator

@k1g99 k1g99 left a comment

Choose a reason for hiding this comment

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

고생하셨어요!!!!

Copy link
Member

@goathoon goathoon left a comment

Choose a reason for hiding this comment

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

ㅇㅍㄹㅂ

@ssupecial ssupecial merged commit 4a586dd into main Mar 14, 2024
9 checks passed
@ssupecial ssupecial deleted the 1298-server-monitor-metric branch March 14, 2024 10:19
jihorobert pushed a commit that referenced this pull request Mar 16, 2024
* chore: merge main branch

* feat: add codes for automatic instrumentation in client api

* feat(infra): rebase main branch

* chore(infra): merge tracer into metrics

* Revert "chore(infra): merge tracer into metrics"

This reverts commit 5c9d899.

* chore(infra): merge mian

* Revert "feat(infra): rebase main branch"

This reverts commit a65f505.

* feat(infra): iris memory metrics

* refactor(iris): separate application logic from metric-related code

* feat(iris): add CPU metrics in iris

* chore(iris): add comment of asynchronous metrics

* feat(infra): add backend opentelemtry instrumentation for client and admin api

* feat(infra): install packages for opentelemetry instrumentation

* feat(infra): change iris metric exporter url from env not specifying url

* chore(infra): add env of stage-otel

* fix(infra): delete grafana agent otlp endpoint variable

* feat(infra): install nest package for opentelemetry metric instrumentation

* feat(infra): install nest package for opentelemetry metric instrumentation

* feat(infra): install go package for iris opentelemetry metric instrumentation

* feat(infra): add metric.go functions to main which trace.go functions are already included

* feat(infra): add metric.ts functions to main which trace is included for admin and client api

* chore: resolve otel dependency

* chore: resolve otel dependency for iris

* fix(infra): delete files which not in main branch

---------

Co-authored-by: k1g99 <[email protected]>
Co-authored-by: Goathoon <[email protected]>
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.

배포 환경 모니터링 - Metric
3 participants