InfoGrab DocsInfoGrab Docs

프로파일링

GitLab에서 성능 문제를 추적하기 위해 제공되는 프로파일링 도구의 종류와 사용 방법을 설명합니다.

# 프로파일링 성능 문제를 보다 쉽게 추적할 수 있도록 GitLab은 다양한 프로파일링 도구를 제공합니다. 일부 도구는 기본적으로 사용 가능하며, 나머지는 명시적으로 활성화해야 합니다. ## URL 프로파일링 `Gitlab::Profiler.profile` 메서드와 이에 대응하는 `bin/profile-url` 스크립트를 사용하면 특정 URL에 대한 GET 또는 POST 요청을 프로파일링할 수 있습니다. 익명 사용자(기본값) 또는 특정 사용자로 프로파일링할 수 있습니다. 프로파일러의 첫 번째 인수는 인스턴스 호스트명을 포함한 전체 URL이거나, 앞에 슬래시가 붙는 절대 경로입니다. 기본적으로 보고서 덤프는 임시 파일에 저장되며, [Stackprof API](/19.1/development/profiling/#reading-a-gitlabprofiler-report)를 사용하여 상호작용할 수 있습니다. 스크립트를 사용할 때는 인수를 전달하지 않으면 명령줄 도움말을 확인할 수 있습니다. 대화형 콘솔 세션에서 메서드를 사용하면, 해당 콘솔 세션 내의 애플리케이션 코드 변경 사항이 프로파일러 출력에 반영됩니다. 예시: ``` Gitlab::Profiler.profile('/my-user') # Returns the location of the temp file where the report dump is stored class UsersController; def show; sleep 100; end; end Gitlab::Profiler.profile('/my-user') # Returns the location of the temp file where the report dump is stored # where 100 seconds is spent in UsersController#show # 인가가 필요한 라우트의 경우 `Gitlab::Profiler`에 사용자를 제공해야 합니다. 다음과 같이 사용합니다: ``` Gitlab::Profiler.profile('/gitlab-org/gitlab-test', user: User.first) # `Gitlab::Profiler.profile`에 `logger:` 키워드 인수를 전달하면 ActiveRecord와 ActionController 로그 출력을 해당 로거로 전송합니다. 추가 옵션은 메서드 소스에 설명되어 있습니다. ``` Gitlab::Profiler.profile('/gitlab-org/gitlab-test', user: User.first, logger: Logger.new($stdout)) # 샘플링 데이터의 출력 파일(`out`)을 구성하려면 `profiler_options` 해시를 전달합니다. 예시: ``` Gitlab::Profiler.profile('/gitlab-org/gitlab-test', user: User.first, profiler_options: { out: 'tmp/profile.dump' }) # ## GitLab::Profiler 보고서 읽기 샘플링 데이터에