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

Implement spans for metrics profiling #1268

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

roby2014
Copy link
Member

Description

See linked issue for proposed implementation, but in short:

  • Create new namespace tel with metrics, tracing and logging.
  • Create span utilities to keep track of scopes
  • Associate metrics and logs to spans

Checklist

  • Self-review changes.
  • Evaluate impact on the documentation.
  • Ensure test coverage.
  • Write new samples.
  • Add entry to the changelog's unreleased section.

@roby2014 roby2014 added this to the 0.3 Standalone Editor milestone Jun 20, 2024
@roby2014 roby2014 self-assigned this Jun 20, 2024
@roby2014 roby2014 linked an issue Jun 20, 2024 that may be closed by this pull request
@github-actions github-actions bot added A-Core B-Telemetry S-Triage Issues to discuss in the next meetings labels Jun 20, 2024
Copy link
Contributor

github-actions bot commented Jun 20, 2024

PR Preview Action v1.4.7
🚀 Deployed preview to https://GameDevTecnico.github.io/cubos/docs-preview/pr-1268/
on branch gh-pages at 2024-06-25 17:43 UTC

Copy link

codecov bot commented Jun 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 40.61%. Comparing base (e92064d) to head (495b9c9).

Current head 495b9c9 differs from pull request most recent head fd5ab56

Please upload reports for the commit fd5ab56 to get more accurate results.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1268   +/-   ##
=======================================
  Coverage   40.61%   40.61%           
=======================================
  Files         354      354           
  Lines       26330    26330           
=======================================
  Hits        10695    10695           
  Misses      15635    15635           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Clang-Tidy found issue(s) with the introduced code (1/2)

std::string name();

private:
std::thread::id id; ///< Thread id where span was invoked.
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for private member id

Suggested change
std::thread::id id; ///< Thread id where span was invoked.
std::thread::id mId; ///< Thread id where span was invoked.

}

SpanManager::Span::Span(const std::string& name, std::size_t level, const std::string& file, std::size_t line)
: id(std::this_thread::get_id())
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for private member id

Suggested change
: id(std::this_thread::get_id())
: mId(std::this_thread::get_id())

std::string name();

private:
std::thread::id id; ///< Thread id where span was invoked.
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for private member id

Suggested change
std::thread::id id; ///< Thread id where span was invoked.
std::thread::id mId; ///< Thread id where span was invoked.

std::thread::id id; ///< Thread id where span was invoked.
std::string mName; ///< The name of the scope.
std::string mFile; ///< The file from where it was invoked.
std::size_t mLine; ///< The line from where it was invoked.
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ clang-diagnostic-unused-private-field ⚠️
private field mLine is not used

std::string mFile; ///< The file from where it was invoked.
std::size_t mLine; ///< The line from where it was invoked.
std::chrono::time_point<std::chrono::high_resolution_clock> mStart; ///< Start time when constructed.
int mLevel;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ clang-diagnostic-unused-private-field ⚠️
private field mLevel is not used

return state;
}

SpanManager::Span::Span(const std::string& name, std::size_t level, const std::string& file, std::size_t line)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ modernize-pass-by-value ⚠️
pass by value and use std::move


SpanManager::Span::Span(const std::string& name, std::size_t level, const std::string& file, std::size_t line)
: id(std::this_thread::get_id())
, mLevel(level)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ clang-diagnostic-reorder-ctor ⚠️
field mLevel will be initialized after field mName

Suggested change
, mLevel(level)

, mFile(file)
, mLine(line)
, mStart(std::chrono::time_point<std::chrono::high_resolution_clock>::clock::now())
{
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ clang-diagnostic-reorder-ctor ⚠️
field mLevel will be initialized after field mName

Suggested change
{
, mLevel(level)
{


SpanManager::Span::Span(const std::string& name, std::size_t level, const std::string& file, std::size_t line)
: id(std::this_thread::get_id())
, mLevel(level)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ bugprone-narrowing-conversions ⚠️
narrowing conversion from std::size_t (aka unsigned long) to signed type int is implementation-defined


SpanManager::Span::Span(const std::string& name, std::size_t level, const std::string& file, std::size_t line)
: id(std::this_thread::get_id())
, mLevel(level)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ clang-diagnostic-shorten-64-to-32 ⚠️
implicit conversion loses integer precision: std::size_t (aka unsigned long) to int

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Clang-Tidy found issue(s) with the introduced code (2/2)

SpanManager::Span::~Span()
{
auto now = std::chrono::time_point<std::chrono::high_resolution_clock>::clock::now();
std::chrono::duration<double, std::milli> elapsed = now - mStart;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ clang-analyzer-deadcode.DeadStores ⚠️
Value stored to elapsed during its initialization is never read

SpanManager::Span::~Span()
{
auto now = std::chrono::time_point<std::chrono::high_resolution_clock>::clock::now();
std::chrono::duration<double, std::milli> elapsed = now - mStart;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ clang-diagnostic-unused-variable ⚠️
unused variable elapsed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Core B-Telemetry S-Triage Issues to discuss in the next meetings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement spans for metrics + profiling
1 participant