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

Add metric for WatchDocument streams #998

Merged
merged 3 commits into from
Sep 5, 2024
Merged

Add metric for WatchDocument streams #998

merged 3 commits into from
Sep 5, 2024

Conversation

emplam27
Copy link
Contributor

@emplam27 emplam27 commented Sep 4, 2024

What this PR does / why we need it:

Added count of watch document connection Metrics.

  • count is increased when client watch document
  • count is decreased when client unwatch document

Which issue(s) this PR fixes:

Address #984

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Additional documentation:


Checklist:

  • Added relevant tests or not required
  • Didn't break anything

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new metric for tracking document watch stream connections, enhancing monitoring capabilities.
    • Added methods to manage document watch connection counts.
  • Bug Fixes

    • Improved error handling in the document watching process to ensure accurate metrics tracking for document connections.

These changes enhance the overall reliability and monitoring of document watch streams in the application.

@emplam27 emplam27 self-assigned this Sep 4, 2024
Copy link

coderabbitai bot commented Sep 4, 2024

Walkthrough

The changes implement a new metric for tracking document watch stream connections in the Prometheus metrics system. This includes adding a gauge for total connections, updating the metrics initialization, and enhancing the WatchDocument function for better error handling and metrics tracking. The modifications aim to improve monitoring capabilities related to real-time collaboration features.

Changes

Files Change Summary
server/profiling/prometheus/metrics.go Introduced a new metric watchDocumentConnectionTotal to track document watch stream connections. Updated NewMetrics to initialize this metric and added methods for incrementing and decrementing connection counts.
server/rpc/yorkie_server.go Modified WatchDocument function to enhance error handling and metrics tracking. Added connection recording on invocation and improved unwatched document error handling to ensure accurate metrics removal.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant YorkieServer
    participant Metrics

    Client->>YorkieServer: WatchDocument()
    YorkieServer->>Metrics: AddWatchDocumentConnection(project)
    YorkieServer->>YorkieServer: Handle document watching
    YorkieServer->>YorkieServer: Unwatch document
    YorkieServer->>Metrics: RemoveWatchDocumentConnection(project) if success
Loading

🐰 Hopping through the code with glee,
Metrics for watches, oh what a spree!
Connections counted, errors now tracked,
Real-time insights, no detail lacked.
In the garden of data, we’ll surely thrive,
With these new changes, our metrics come alive! 🌼

Possibly related issues


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7a23cb1 and 9a1e286.

Files selected for processing (2)
  • server/profiling/prometheus/metrics.go (3 hunks)
  • server/rpc/yorkie_server.go (1 hunks)
Additional context used
GitHub Check: build
server/rpc/yorkie_server.go

[failure] 435-435:
s.unwatchDoc(subscription, docRefKey) (no value) used as value (typecheck)


[failure] 435-435:
s.unwatchDoc(subscription, docRefKey) (no value) used as value) (typecheck)


[failure] 435-435:
s.unwatchDoc(subscription, docRefKey) (no value) used as value) (typecheck)


[failure] 435-435:
s.unwatchDoc(subscription, docRefKey) (no value) used as value) (typecheck)

GitHub Check: bench
server/rpc/yorkie_server.go

[failure] 435-435:
s.unwatchDoc(subscription, docRefKey) (no value) used as value

Additional comments not posted (6)
server/profiling/prometheus/metrics.go (5)

67-67: LGTM!

The new field watchDocumentConnectionTotal is correctly added to the Metrics struct.


148-156: LGTM!

The watchDocumentConnectionTotal field is correctly initialized in the NewMetrics function with appropriate labels and description.


271-277: LGTM!

The AddWatchDocumentConnection method is correctly implemented to increment the watchDocumentConnectionTotal gauge when a client starts watching a document.


279-285: LGTM!

The RemoveWatchDocumentConnection method is correctly implemented to decrement the watchDocumentConnectionTotal gauge when a client stops watching a document.


Line range hint 1-290: Verify the usage of the new methods in the codebase.

Ensure that the AddWatchDocumentConnection and RemoveWatchDocumentConnection methods are called appropriately when a client starts and stops watching a document, respectively.

Run the following script to verify the method usage:

Verification successful

Methods are used correctly in the codebase.

The AddWatchDocumentConnection and RemoveWatchDocumentConnection methods are appropriately used in the server/rpc/yorkie_server.go file, confirming their intended functionality. No issues found with their usage.

  • server/rpc/yorkie_server.go: Usage of both methods.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `AddWatchDocumentConnection` and `RemoveWatchDocumentConnection` methods.

# Test 1: Search for the usage of `AddWatchDocumentConnection`. Expect: Called when a client starts watching a document.
ast-grep --lang go --pattern $'func $_($_, $_) {
  $$$
  metrics.AddWatchDocumentConnection($_)
  $$$
}'

# Test 2: Search for the usage of `RemoveWatchDocumentConnection`. Expect: Called when a client stops watching a document.
ast-grep --lang go --pattern $'func $_($_, $_) {
  $$$
  metrics.RemoveWatchDocumentConnection($_)
  $$$
}'

Length of output: 214


Script:

#!/bin/bash
# Description: Use ripgrep to search for the usage of `AddWatchDocumentConnection` and `RemoveWatchDocumentConnection` methods.

# Search for the usage of `AddWatchDocumentConnection`.
rg 'AddWatchDocumentConnection'

# Search for the usage of `RemoveWatchDocumentConnection`.
rg 'RemoveWatchDocumentConnection'

Length of output: 710

server/rpc/yorkie_server.go (1)

433-433: LGTM!

The code changes are approved.

server/rpc/yorkie_server.go Outdated Show resolved Hide resolved
@emplam27 emplam27 changed the title Add Count of Connection Metric(#984) Add Count of Connection Metric Sep 5, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9a1e286 and c9ebfd2.

Files selected for processing (1)
  • server/rpc/yorkie_server.go (3 hunks)
Additional comments not posted (2)
server/rpc/yorkie_server.go (2)

433-438: Approve the metric tracking implementation; ensure error handling fix is incorporated.

The addition of metric tracking in the WatchDocument function enhances monitoring capabilities, which aligns with the PR objectives. Ensure that the error handling fix suggested in the previous review is incorporated to improve the reliability of the metrics tracking.

-		err := s.unwatchDoc(subscription, docRefKey)
-		if err == nil {
+		unwatchErr := s.unwatchDoc(subscription, docRefKey)
+		if unwatchErr == nil {

Line range hint 590-608: Approve the changes in unwatchDoc function.

The modification to return an error in the unwatchDoc function enhances error handling by allowing the calling function to manage the error appropriately. This change is crucial for maintaining robustness and reliability in the system.

func (s *yorkieServer) unwatchDoc(
	subscription *sync.Subscription,
	documentRefKey types.DocRefKey,
) error {
	ctx := context.Background()
	err := s.backend.Coordinator.Unsubscribe(ctx, documentRefKey, subscription)
	if err != nil {
		logging.From(ctx).Error(err)
		return err
	}

	s.backend.Coordinator.Publish(
		ctx,
		subscription.Subscriber(),
		sync.DocEvent{
			Type:           types.DocumentUnwatchedEvent,
			Publisher:      subscription.Subscriber(),
			DocumentRefKey: documentRefKey,
		},
	)
	return nil
}

Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 7.14286% with 13 lines in your changes missing coverage. Please review.

Project coverage is 50.80%. Comparing base (2f93922) to head (8623a14).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
server/rpc/yorkie_server.go 7.14% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #998      +/-   ##
==========================================
- Coverage   50.84%   50.80%   -0.04%     
==========================================
  Files          73       73              
  Lines       10855    10865      +10     
==========================================
+ Hits         5519     5520       +1     
- Misses       4787     4796       +9     
  Partials      549      549              

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

Added count of watch document connection Metrics.
the count is increased when client watch document, and decreased when client unwatch document
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c9ebfd2 and 4711e7a.

Files selected for processing (2)
  • server/profiling/prometheus/metrics.go (3 hunks)
  • server/rpc/yorkie_server.go (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • server/profiling/prometheus/metrics.go
  • server/rpc/yorkie_server.go

Copy link

@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.

Go Benchmark

Benchmark suite Current: 8623a14 Previous: c9ebfd2 Ratio
BenchmarkDocument/constructor_test 1573 ns/op 1337 B/op 24 allocs/op 1503 ns/op 1337 B/op 24 allocs/op 1.05
BenchmarkDocument/constructor_test - ns/op 1573 ns/op 1503 ns/op 1.05
BenchmarkDocument/constructor_test - B/op 1337 B/op 1337 B/op 1
BenchmarkDocument/constructor_test - allocs/op 24 allocs/op 24 allocs/op 1
BenchmarkDocument/status_test 1004 ns/op 1305 B/op 22 allocs/op 964.5 ns/op 1305 B/op 22 allocs/op 1.04
BenchmarkDocument/status_test - ns/op 1004 ns/op 964.5 ns/op 1.04
BenchmarkDocument/status_test - B/op 1305 B/op 1305 B/op 1
BenchmarkDocument/status_test - allocs/op 22 allocs/op 22 allocs/op 1
BenchmarkDocument/equals_test 7960 ns/op 7273 B/op 132 allocs/op 7649 ns/op 7273 B/op 132 allocs/op 1.04
BenchmarkDocument/equals_test - ns/op 7960 ns/op 7649 ns/op 1.04
BenchmarkDocument/equals_test - B/op 7273 B/op 7273 B/op 1
BenchmarkDocument/equals_test - allocs/op 132 allocs/op 132 allocs/op 1
BenchmarkDocument/nested_update_test 17594 ns/op 12139 B/op 262 allocs/op 16743 ns/op 12138 B/op 262 allocs/op 1.05
BenchmarkDocument/nested_update_test - ns/op 17594 ns/op 16743 ns/op 1.05
BenchmarkDocument/nested_update_test - B/op 12139 B/op 12138 B/op 1.00
BenchmarkDocument/nested_update_test - allocs/op 262 allocs/op 262 allocs/op 1
BenchmarkDocument/delete_test 23457 ns/op 15364 B/op 341 allocs/op 26497 ns/op 15363 B/op 341 allocs/op 0.89
BenchmarkDocument/delete_test - ns/op 23457 ns/op 26497 ns/op 0.89
BenchmarkDocument/delete_test - B/op 15364 B/op 15363 B/op 1.00
BenchmarkDocument/delete_test - allocs/op 341 allocs/op 341 allocs/op 1
BenchmarkDocument/object_test 9817 ns/op 6817 B/op 120 allocs/op 8637 ns/op 6817 B/op 120 allocs/op 1.14
BenchmarkDocument/object_test - ns/op 9817 ns/op 8637 ns/op 1.14
BenchmarkDocument/object_test - B/op 6817 B/op 6817 B/op 1
BenchmarkDocument/object_test - allocs/op 120 allocs/op 120 allocs/op 1
BenchmarkDocument/array_test 30521 ns/op 11947 B/op 276 allocs/op 28927 ns/op 11947 B/op 276 allocs/op 1.06
BenchmarkDocument/array_test - ns/op 30521 ns/op 28927 ns/op 1.06
BenchmarkDocument/array_test - B/op 11947 B/op 11947 B/op 1
BenchmarkDocument/array_test - allocs/op 276 allocs/op 276 allocs/op 1
BenchmarkDocument/text_test 32022 ns/op 14716 B/op 469 allocs/op 31033 ns/op 14715 B/op 469 allocs/op 1.03
BenchmarkDocument/text_test - ns/op 32022 ns/op 31033 ns/op 1.03
BenchmarkDocument/text_test - B/op 14716 B/op 14715 B/op 1.00
BenchmarkDocument/text_test - allocs/op 469 allocs/op 469 allocs/op 1
BenchmarkDocument/text_composition_test 30259 ns/op 18420 B/op 484 allocs/op 28878 ns/op 18422 B/op 484 allocs/op 1.05
BenchmarkDocument/text_composition_test - ns/op 30259 ns/op 28878 ns/op 1.05
BenchmarkDocument/text_composition_test - B/op 18420 B/op 18422 B/op 1.00
BenchmarkDocument/text_composition_test - allocs/op 484 allocs/op 484 allocs/op 1
BenchmarkDocument/rich_text_test 84924 ns/op 38477 B/op 1148 allocs/op 81697 ns/op 38476 B/op 1148 allocs/op 1.04
BenchmarkDocument/rich_text_test - ns/op 84924 ns/op 81697 ns/op 1.04
BenchmarkDocument/rich_text_test - B/op 38477 B/op 38476 B/op 1.00
BenchmarkDocument/rich_text_test - allocs/op 1148 allocs/op 1148 allocs/op 1
BenchmarkDocument/counter_test 18280 ns/op 10722 B/op 244 allocs/op 17391 ns/op 10722 B/op 244 allocs/op 1.05
BenchmarkDocument/counter_test - ns/op 18280 ns/op 17391 ns/op 1.05
BenchmarkDocument/counter_test - B/op 10722 B/op 10722 B/op 1
BenchmarkDocument/counter_test - allocs/op 244 allocs/op 244 allocs/op 1
BenchmarkDocument/text_edit_gc_100 1331423 ns/op 870933 B/op 16752 allocs/op 1275547 ns/op 870986 B/op 16753 allocs/op 1.04
BenchmarkDocument/text_edit_gc_100 - ns/op 1331423 ns/op 1275547 ns/op 1.04
BenchmarkDocument/text_edit_gc_100 - B/op 870933 B/op 870986 B/op 1.00
BenchmarkDocument/text_edit_gc_100 - allocs/op 16752 allocs/op 16753 allocs/op 1.00
BenchmarkDocument/text_edit_gc_1000 53720296 ns/op 50535339 B/op 181708 allocs/op 51247643 ns/op 50535168 B/op 181716 allocs/op 1.05
BenchmarkDocument/text_edit_gc_1000 - ns/op 53720296 ns/op 51247643 ns/op 1.05
BenchmarkDocument/text_edit_gc_1000 - B/op 50535339 B/op 50535168 B/op 1.00
BenchmarkDocument/text_edit_gc_1000 - allocs/op 181708 allocs/op 181716 allocs/op 1.00
BenchmarkDocument/text_split_gc_100 1973870 ns/op 1528855 B/op 15605 allocs/op 1868608 ns/op 1528777 B/op 15604 allocs/op 1.06
BenchmarkDocument/text_split_gc_100 - ns/op 1973870 ns/op 1868608 ns/op 1.06
BenchmarkDocument/text_split_gc_100 - B/op 1528855 B/op 1528777 B/op 1.00
BenchmarkDocument/text_split_gc_100 - allocs/op 15605 allocs/op 15604 allocs/op 1.00
BenchmarkDocument/text_split_gc_1000 119311994 ns/op 135076877 B/op 182194 allocs/op 111367891 ns/op 135076461 B/op 182181 allocs/op 1.07
BenchmarkDocument/text_split_gc_1000 - ns/op 119311994 ns/op 111367891 ns/op 1.07
BenchmarkDocument/text_split_gc_1000 - B/op 135076877 B/op 135076461 B/op 1.00
BenchmarkDocument/text_split_gc_1000 - allocs/op 182194 allocs/op 182181 allocs/op 1.00
BenchmarkDocument/text_delete_all_10000 19747662 ns/op 10182682 B/op 40675 allocs/op 16121151 ns/op 10182565 B/op 40673 allocs/op 1.22
BenchmarkDocument/text_delete_all_10000 - ns/op 19747662 ns/op 16121151 ns/op 1.22
BenchmarkDocument/text_delete_all_10000 - B/op 10182682 B/op 10182565 B/op 1.00
BenchmarkDocument/text_delete_all_10000 - allocs/op 40675 allocs/op 40673 allocs/op 1.00
BenchmarkDocument/text_delete_all_100000 352104006 ns/op 142736213 B/op 411682 allocs/op 302124715 ns/op 142644924 B/op 411617 allocs/op 1.17
BenchmarkDocument/text_delete_all_100000 - ns/op 352104006 ns/op 302124715 ns/op 1.17
BenchmarkDocument/text_delete_all_100000 - B/op 142736213 B/op 142644924 B/op 1.00
BenchmarkDocument/text_delete_all_100000 - allocs/op 411682 allocs/op 411617 allocs/op 1.00
BenchmarkDocument/text_100 217565 ns/op 120036 B/op 5081 allocs/op 216646 ns/op 120037 B/op 5081 allocs/op 1.00
BenchmarkDocument/text_100 - ns/op 217565 ns/op 216646 ns/op 1.00
BenchmarkDocument/text_100 - B/op 120036 B/op 120037 B/op 1.00
BenchmarkDocument/text_100 - allocs/op 5081 allocs/op 5081 allocs/op 1
BenchmarkDocument/text_1000 2398609 ns/op 1169024 B/op 50085 allocs/op 2342047 ns/op 1169024 B/op 50085 allocs/op 1.02
BenchmarkDocument/text_1000 - ns/op 2398609 ns/op 2342047 ns/op 1.02
BenchmarkDocument/text_1000 - B/op 1169024 B/op 1169024 B/op 1
BenchmarkDocument/text_1000 - allocs/op 50085 allocs/op 50085 allocs/op 1
BenchmarkDocument/array_1000 1256036 ns/op 1091399 B/op 11832 allocs/op 1254553 ns/op 1091302 B/op 11831 allocs/op 1.00
BenchmarkDocument/array_1000 - ns/op 1256036 ns/op 1254553 ns/op 1.00
BenchmarkDocument/array_1000 - B/op 1091399 B/op 1091302 B/op 1.00
BenchmarkDocument/array_1000 - allocs/op 11832 allocs/op 11831 allocs/op 1.00
BenchmarkDocument/array_10000 13872624 ns/op 9800246 B/op 120298 allocs/op 13302775 ns/op 9800203 B/op 120297 allocs/op 1.04
BenchmarkDocument/array_10000 - ns/op 13872624 ns/op 13302775 ns/op 1.04
BenchmarkDocument/array_10000 - B/op 9800246 B/op 9800203 B/op 1.00
BenchmarkDocument/array_10000 - allocs/op 120298 allocs/op 120297 allocs/op 1.00
BenchmarkDocument/array_gc_100 153281 ns/op 132699 B/op 1260 allocs/op 151575 ns/op 132710 B/op 1260 allocs/op 1.01
BenchmarkDocument/array_gc_100 - ns/op 153281 ns/op 151575 ns/op 1.01
BenchmarkDocument/array_gc_100 - B/op 132699 B/op 132710 B/op 1.00
BenchmarkDocument/array_gc_100 - allocs/op 1260 allocs/op 1260 allocs/op 1
BenchmarkDocument/array_gc_1000 1439296 ns/op 1159213 B/op 12877 allocs/op 1426240 ns/op 1159231 B/op 12877 allocs/op 1.01
BenchmarkDocument/array_gc_1000 - ns/op 1439296 ns/op 1426240 ns/op 1.01
BenchmarkDocument/array_gc_1000 - B/op 1159213 B/op 1159231 B/op 1.00
BenchmarkDocument/array_gc_1000 - allocs/op 12877 allocs/op 12877 allocs/op 1
BenchmarkDocument/counter_1000 204543 ns/op 193080 B/op 5771 allocs/op 204626 ns/op 193081 B/op 5771 allocs/op 1.00
BenchmarkDocument/counter_1000 - ns/op 204543 ns/op 204626 ns/op 1.00
BenchmarkDocument/counter_1000 - B/op 193080 B/op 193081 B/op 1.00
BenchmarkDocument/counter_1000 - allocs/op 5771 allocs/op 5771 allocs/op 1
BenchmarkDocument/counter_10000 2227465 ns/op 2088011 B/op 59778 allocs/op 2164496 ns/op 2088012 B/op 59778 allocs/op 1.03
BenchmarkDocument/counter_10000 - ns/op 2227465 ns/op 2164496 ns/op 1.03
BenchmarkDocument/counter_10000 - B/op 2088011 B/op 2088012 B/op 1.00
BenchmarkDocument/counter_10000 - allocs/op 59778 allocs/op 59778 allocs/op 1
BenchmarkDocument/object_1000 1430933 ns/op 1428075 B/op 9849 allocs/op 1410690 ns/op 1428157 B/op 9849 allocs/op 1.01
BenchmarkDocument/object_1000 - ns/op 1430933 ns/op 1410690 ns/op 1.01
BenchmarkDocument/object_1000 - B/op 1428075 B/op 1428157 B/op 1.00
BenchmarkDocument/object_1000 - allocs/op 9849 allocs/op 9849 allocs/op 1
BenchmarkDocument/object_10000 16158448 ns/op 12166977 B/op 100563 allocs/op 15394923 ns/op 12165836 B/op 100562 allocs/op 1.05
BenchmarkDocument/object_10000 - ns/op 16158448 ns/op 15394923 ns/op 1.05
BenchmarkDocument/object_10000 - B/op 12166977 B/op 12165836 B/op 1.00
BenchmarkDocument/object_10000 - allocs/op 100563 allocs/op 100562 allocs/op 1.00
BenchmarkDocument/tree_100 1083690 ns/op 943704 B/op 6101 allocs/op 1065998 ns/op 943703 B/op 6101 allocs/op 1.02
BenchmarkDocument/tree_100 - ns/op 1083690 ns/op 1065998 ns/op 1.02
BenchmarkDocument/tree_100 - B/op 943704 B/op 943703 B/op 1.00
BenchmarkDocument/tree_100 - allocs/op 6101 allocs/op 6101 allocs/op 1
BenchmarkDocument/tree_1000 80501050 ns/op 86460486 B/op 60115 allocs/op 78089433 ns/op 86460445 B/op 60115 allocs/op 1.03
BenchmarkDocument/tree_1000 - ns/op 80501050 ns/op 78089433 ns/op 1.03
BenchmarkDocument/tree_1000 - B/op 86460486 B/op 86460445 B/op 1.00
BenchmarkDocument/tree_1000 - allocs/op 60115 allocs/op 60115 allocs/op 1
BenchmarkDocument/tree_10000 10162194012 ns/op 8580659040 B/op 600209 allocs/op 9880035610 ns/op 8580662800 B/op 600242 allocs/op 1.03
BenchmarkDocument/tree_10000 - ns/op 10162194012 ns/op 9880035610 ns/op 1.03
BenchmarkDocument/tree_10000 - B/op 8580659040 B/op 8580662800 B/op 1.00
BenchmarkDocument/tree_10000 - allocs/op 600209 allocs/op 600242 allocs/op 1.00
BenchmarkDocument/tree_delete_all_1000 78419683 ns/op 87508781 B/op 75262 allocs/op 78305100 ns/op 87510107 B/op 75266 allocs/op 1.00
BenchmarkDocument/tree_delete_all_1000 - ns/op 78419683 ns/op 78305100 ns/op 1.00
BenchmarkDocument/tree_delete_all_1000 - B/op 87508781 B/op 87510107 B/op 1.00
BenchmarkDocument/tree_delete_all_1000 - allocs/op 75262 allocs/op 75266 allocs/op 1.00
BenchmarkDocument/tree_edit_gc_100 3937239 ns/op 4146689 B/op 15140 allocs/op 3935750 ns/op 4147854 B/op 15141 allocs/op 1.00
BenchmarkDocument/tree_edit_gc_100 - ns/op 3937239 ns/op 3935750 ns/op 1.00
BenchmarkDocument/tree_edit_gc_100 - B/op 4146689 B/op 4147854 B/op 1.00
BenchmarkDocument/tree_edit_gc_100 - allocs/op 15140 allocs/op 15141 allocs/op 1.00
BenchmarkDocument/tree_edit_gc_1000 315300013 ns/op 383748964 B/op 154865 allocs/op 311100525 ns/op 383750078 B/op 154867 allocs/op 1.01
BenchmarkDocument/tree_edit_gc_1000 - ns/op 315300013 ns/op 311100525 ns/op 1.01
BenchmarkDocument/tree_edit_gc_1000 - B/op 383748964 B/op 383750078 B/op 1.00
BenchmarkDocument/tree_edit_gc_1000 - allocs/op 154865 allocs/op 154867 allocs/op 1.00
BenchmarkDocument/tree_split_gc_100 2612929 ns/op 2413230 B/op 11125 allocs/op 2605644 ns/op 2412512 B/op 11125 allocs/op 1.00
BenchmarkDocument/tree_split_gc_100 - ns/op 2612929 ns/op 2605644 ns/op 1.00
BenchmarkDocument/tree_split_gc_100 - B/op 2413230 B/op 2412512 B/op 1.00
BenchmarkDocument/tree_split_gc_100 - allocs/op 11125 allocs/op 11125 allocs/op 1
BenchmarkDocument/tree_split_gc_1000 195443013 ns/op 222251470 B/op 121995 allocs/op 191108242 ns/op 222251650 B/op 121997 allocs/op 1.02
BenchmarkDocument/tree_split_gc_1000 - ns/op 195443013 ns/op 191108242 ns/op 1.02
BenchmarkDocument/tree_split_gc_1000 - B/op 222251470 B/op 222251650 B/op 1.00
BenchmarkDocument/tree_split_gc_1000 - allocs/op 121995 allocs/op 121997 allocs/op 1.00
BenchmarkRPC/client_to_server 360316073 ns/op 16587344 B/op 167373 allocs/op 349112170 ns/op 18452957 B/op 167462 allocs/op 1.03
BenchmarkRPC/client_to_server - ns/op 360316073 ns/op 349112170 ns/op 1.03
BenchmarkRPC/client_to_server - B/op 16587344 B/op 18452957 B/op 0.90
BenchmarkRPC/client_to_server - allocs/op 167373 allocs/op 167462 allocs/op 1.00
BenchmarkRPC/client_to_client_via_server 663497810 ns/op 33099220 B/op 321382 allocs/op 635786750 ns/op 33886604 B/op 321034 allocs/op 1.04
BenchmarkRPC/client_to_client_via_server - ns/op 663497810 ns/op 635786750 ns/op 1.04
BenchmarkRPC/client_to_client_via_server - B/op 33099220 B/op 33886604 B/op 0.98
BenchmarkRPC/client_to_client_via_server - allocs/op 321382 allocs/op 321034 allocs/op 1.00
BenchmarkRPC/attach_large_document 1249518144 ns/op 1919111832 B/op 8788 allocs/op 1458297393 ns/op 1895473392 B/op 8800 allocs/op 0.86
BenchmarkRPC/attach_large_document - ns/op 1249518144 ns/op 1458297393 ns/op 0.86
BenchmarkRPC/attach_large_document - B/op 1919111832 B/op 1895473392 B/op 1.01
BenchmarkRPC/attach_large_document - allocs/op 8788 allocs/op 8800 allocs/op 1.00
BenchmarkRPC/adminCli_to_server 562029438 ns/op 36775260 B/op 289556 allocs/op 557325760 ns/op 35959428 B/op 289552 allocs/op 1.01
BenchmarkRPC/adminCli_to_server - ns/op 562029438 ns/op 557325760 ns/op 1.01
BenchmarkRPC/adminCli_to_server - B/op 36775260 B/op 35959428 B/op 1.02
BenchmarkRPC/adminCli_to_server - allocs/op 289556 allocs/op 289552 allocs/op 1.00
BenchmarkLocker 64.46 ns/op 16 B/op 1 allocs/op 68.17 ns/op 16 B/op 1 allocs/op 0.95
BenchmarkLocker - ns/op 64.46 ns/op 68.17 ns/op 0.95
BenchmarkLocker - B/op 16 B/op 16 B/op 1
BenchmarkLocker - allocs/op 1 allocs/op 1 allocs/op 1
BenchmarkLockerParallel 39.22 ns/op 0 B/op 0 allocs/op 39.19 ns/op 0 B/op 0 allocs/op 1.00
BenchmarkLockerParallel - ns/op 39.22 ns/op 39.19 ns/op 1.00
BenchmarkLockerParallel - B/op 0 B/op 0 B/op 1
BenchmarkLockerParallel - allocs/op 0 allocs/op 0 allocs/op 1
BenchmarkLockerMoreKeys 150 ns/op 15 B/op 0 allocs/op 175.6 ns/op 15 B/op 0 allocs/op 0.85
BenchmarkLockerMoreKeys - ns/op 150 ns/op 175.6 ns/op 0.85
BenchmarkLockerMoreKeys - B/op 15 B/op 15 B/op 1
BenchmarkLockerMoreKeys - allocs/op 0 allocs/op 0 allocs/op 1
BenchmarkChange/Push_10_Changes 3808552 ns/op 115454 B/op 1205 allocs/op 3700362 ns/op 115800 B/op 1205 allocs/op 1.03
BenchmarkChange/Push_10_Changes - ns/op 3808552 ns/op 3700362 ns/op 1.03
BenchmarkChange/Push_10_Changes - B/op 115454 B/op 115800 B/op 1.00
BenchmarkChange/Push_10_Changes - allocs/op 1205 allocs/op 1205 allocs/op 1
BenchmarkChange/Push_100_Changes 15169256 ns/op 567108 B/op 6575 allocs/op 14523601 ns/op 572151 B/op 6575 allocs/op 1.04
BenchmarkChange/Push_100_Changes - ns/op 15169256 ns/op 14523601 ns/op 1.04
BenchmarkChange/Push_100_Changes - B/op 567108 B/op 572151 B/op 0.99
BenchmarkChange/Push_100_Changes - allocs/op 6575 allocs/op 6575 allocs/op 1
BenchmarkChange/Push_1000_Changes 121703642 ns/op 5206604 B/op 63069 allocs/op 117475158 ns/op 5372712 B/op 63069 allocs/op 1.04
BenchmarkChange/Push_1000_Changes - ns/op 121703642 ns/op 117475158 ns/op 1.04
BenchmarkChange/Push_1000_Changes - B/op 5206604 B/op 5372712 B/op 0.97
BenchmarkChange/Push_1000_Changes - allocs/op 63069 allocs/op 63069 allocs/op 1
BenchmarkChange/Pull_10_Changes 3072678 ns/op 100145 B/op 1009 allocs/op 2958947 ns/op 101180 B/op 1008 allocs/op 1.04
BenchmarkChange/Pull_10_Changes - ns/op 3072678 ns/op 2958947 ns/op 1.04
BenchmarkChange/Pull_10_Changes - B/op 100145 B/op 101180 B/op 0.99
BenchmarkChange/Pull_10_Changes - allocs/op 1009 allocs/op 1008 allocs/op 1.00
BenchmarkChange/Pull_100_Changes 4623497 ns/op 263603 B/op 3479 allocs/op 4441355 ns/op 266071 B/op 3479 allocs/op 1.04
BenchmarkChange/Pull_100_Changes - ns/op 4623497 ns/op 4441355 ns/op 1.04
BenchmarkChange/Pull_100_Changes - B/op 263603 B/op 266071 B/op 0.99
BenchmarkChange/Pull_100_Changes - allocs/op 3479 allocs/op 3479 allocs/op 1
BenchmarkChange/Pull_1000_Changes 9399177 ns/op 1489023 B/op 29846 allocs/op 8867395 ns/op 1493003 B/op 29859 allocs/op 1.06
BenchmarkChange/Pull_1000_Changes - ns/op 9399177 ns/op 8867395 ns/op 1.06
BenchmarkChange/Pull_1000_Changes - B/op 1489023 B/op 1493003 B/op 1.00
BenchmarkChange/Pull_1000_Changes - allocs/op 29846 allocs/op 29859 allocs/op 1.00
BenchmarkSnapshot/Push_3KB_snapshot 17815569 ns/op 705835 B/op 6581 allocs/op 16951572 ns/op 707728 B/op 6575 allocs/op 1.05
BenchmarkSnapshot/Push_3KB_snapshot - ns/op 17815569 ns/op 16951572 ns/op 1.05
BenchmarkSnapshot/Push_3KB_snapshot - B/op 705835 B/op 707728 B/op 1.00
BenchmarkSnapshot/Push_3KB_snapshot - allocs/op 6581 allocs/op 6575 allocs/op 1.00
BenchmarkSnapshot/Push_30KB_snapshot 125125420 ns/op 5664634 B/op 63334 allocs/op 121416056 ns/op 5630515 B/op 63204 allocs/op 1.03
BenchmarkSnapshot/Push_30KB_snapshot - ns/op 125125420 ns/op 121416056 ns/op 1.03
BenchmarkSnapshot/Push_30KB_snapshot - B/op 5664634 B/op 5630515 B/op 1.01
BenchmarkSnapshot/Push_30KB_snapshot - allocs/op 63334 allocs/op 63204 allocs/op 1.00
BenchmarkSnapshot/Pull_3KB_snapshot 6887622 ns/op 917511 B/op 15512 allocs/op 6545501 ns/op 921975 B/op 15514 allocs/op 1.05
BenchmarkSnapshot/Pull_3KB_snapshot - ns/op 6887622 ns/op 6545501 ns/op 1.05
BenchmarkSnapshot/Pull_3KB_snapshot - B/op 917511 B/op 921975 B/op 1.00
BenchmarkSnapshot/Pull_3KB_snapshot - allocs/op 15512 allocs/op 15514 allocs/op 1.00
BenchmarkSnapshot/Pull_30KB_snapshot 16171293 ns/op 7152175 B/op 150109 allocs/op 15212139 ns/op 7160550 B/op 150109 allocs/op 1.06
BenchmarkSnapshot/Pull_30KB_snapshot - ns/op 16171293 ns/op 15212139 ns/op 1.06
BenchmarkSnapshot/Pull_30KB_snapshot - B/op 7152175 B/op 7160550 B/op 1.00
BenchmarkSnapshot/Pull_30KB_snapshot - allocs/op 150109 allocs/op 150109 allocs/op 1
BenchmarkSync/memory_sync_10_test 7742 ns/op 1286 B/op 38 allocs/op 7543 ns/op 1286 B/op 38 allocs/op 1.03
BenchmarkSync/memory_sync_10_test - ns/op 7742 ns/op 7543 ns/op 1.03
BenchmarkSync/memory_sync_10_test - B/op 1286 B/op 1286 B/op 1
BenchmarkSync/memory_sync_10_test - allocs/op 38 allocs/op 38 allocs/op 1
BenchmarkSync/memory_sync_100_test 51265 ns/op 9007 B/op 296 allocs/op 45086 ns/op 9121 B/op 303 allocs/op 1.14
BenchmarkSync/memory_sync_100_test - ns/op 51265 ns/op 45086 ns/op 1.14
BenchmarkSync/memory_sync_100_test - B/op 9007 B/op 9121 B/op 0.99
BenchmarkSync/memory_sync_100_test - allocs/op 296 allocs/op 303 allocs/op 0.98
BenchmarkSync/memory_sync_1000_test 433571 ns/op 83185 B/op 2670 allocs/op 425685 ns/op 84465 B/op 2754 allocs/op 1.02
BenchmarkSync/memory_sync_1000_test - ns/op 433571 ns/op 425685 ns/op 1.02
BenchmarkSync/memory_sync_1000_test - B/op 83185 B/op 84465 B/op 0.98
BenchmarkSync/memory_sync_1000_test - allocs/op 2670 allocs/op 2754 allocs/op 0.97
BenchmarkSync/memory_sync_10000_test 4439279 ns/op 804342 B/op 24262 allocs/op 4455897 ns/op 802312 B/op 24368 allocs/op 1.00
BenchmarkSync/memory_sync_10000_test - ns/op 4439279 ns/op 4455897 ns/op 1.00
BenchmarkSync/memory_sync_10000_test - B/op 804342 B/op 802312 B/op 1.00
BenchmarkSync/memory_sync_10000_test - allocs/op 24262 allocs/op 24368 allocs/op 1.00
BenchmarkTextEditing 5661768389 ns/op 3901925712 B/op 18743110 allocs/op 5235122561 ns/op 3901918608 B/op 18743200 allocs/op 1.08
BenchmarkTextEditing - ns/op 5661768389 ns/op 5235122561 ns/op 1.08
BenchmarkTextEditing - B/op 3901925712 B/op 3901918608 B/op 1.00
BenchmarkTextEditing - allocs/op 18743110 allocs/op 18743200 allocs/op 1.00
BenchmarkTree/10000_vertices_to_protobuf 3810930 ns/op 6262973 B/op 70025 allocs/op 3493135 ns/op 6262967 B/op 70025 allocs/op 1.09
BenchmarkTree/10000_vertices_to_protobuf - ns/op 3810930 ns/op 3493135 ns/op 1.09
BenchmarkTree/10000_vertices_to_protobuf - B/op 6262973 B/op 6262967 B/op 1.00
BenchmarkTree/10000_vertices_to_protobuf - allocs/op 70025 allocs/op 70025 allocs/op 1
BenchmarkTree/10000_vertices_from_protobuf 170067436 ns/op 442173065 B/op 290053 allocs/op 159962557 ns/op 442171427 B/op 290038 allocs/op 1.06
BenchmarkTree/10000_vertices_from_protobuf - ns/op 170067436 ns/op 159962557 ns/op 1.06
BenchmarkTree/10000_vertices_from_protobuf - B/op 442173065 B/op 442171427 B/op 1.00
BenchmarkTree/10000_vertices_from_protobuf - allocs/op 290053 allocs/op 290038 allocs/op 1.00
BenchmarkTree/20000_vertices_to_protobuf 8245066 ns/op 12716994 B/op 140028 allocs/op 7887523 ns/op 12716873 B/op 140028 allocs/op 1.05
BenchmarkTree/20000_vertices_to_protobuf - ns/op 8245066 ns/op 7887523 ns/op 1.05
BenchmarkTree/20000_vertices_to_protobuf - B/op 12716994 B/op 12716873 B/op 1.00
BenchmarkTree/20000_vertices_to_protobuf - allocs/op 140028 allocs/op 140028 allocs/op 1
BenchmarkTree/20000_vertices_from_protobuf 730097395 ns/op 1697272400 B/op 580047 allocs/op 704537086 ns/op 1697268636 B/op 580091 allocs/op 1.04
BenchmarkTree/20000_vertices_from_protobuf - ns/op 730097395 ns/op 704537086 ns/op 1.04
BenchmarkTree/20000_vertices_from_protobuf - B/op 1697272400 B/op 1697268636 B/op 1.00
BenchmarkTree/20000_vertices_from_protobuf - allocs/op 580047 allocs/op 580091 allocs/op 1.00
BenchmarkTree/30000_vertices_to_protobuf 12718967 ns/op 19318244 B/op 210030 allocs/op 12539730 ns/op 19318327 B/op 210030 allocs/op 1.01
BenchmarkTree/30000_vertices_to_protobuf - ns/op 12718967 ns/op 12539730 ns/op 1.01
BenchmarkTree/30000_vertices_to_protobuf - B/op 19318244 B/op 19318327 B/op 1.00
BenchmarkTree/30000_vertices_to_protobuf - allocs/op 210030 allocs/op 210030 allocs/op 1
BenchmarkTree/30000_vertices_from_protobuf 1714435530 ns/op 3752051912 B/op 870046 allocs/op 1639297100 ns/op 3752044072 B/op 870047 allocs/op 1.05
BenchmarkTree/30000_vertices_from_protobuf - ns/op 1714435530 ns/op 1639297100 ns/op 1.05
BenchmarkTree/30000_vertices_from_protobuf - B/op 3752051912 B/op 3752044072 B/op 1.00
BenchmarkTree/30000_vertices_from_protobuf - allocs/op 870046 allocs/op 870047 allocs/op 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4711e7a and e0a69c7.

Files selected for processing (2)
  • server/profiling/prometheus/metrics.go (3 hunks)
  • server/rpc/yorkie_server.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • server/profiling/prometheus/metrics.go
Additional comments not posted (2)
server/rpc/yorkie_server.go (2)

433-439: Approve the changes in WatchDocument with a suggestion for error handling.

The changes to add metrics tracking and update error handling are well-aligned with the PR objectives. The use of a deferred function to handle unwatching and metrics removal is appropriate.

However, consider improving the error handling by logging more context or specific error messages to aid in debugging and monitoring.


Line range hint 591-609: Approve the changes in unwatchDoc with a suggestion for context usage.

The updated function now properly returns an error, which is crucial for the error handling in WatchDocument. The logging and event publishing within the function are correctly implemented.

Consider using the passed context ctx instead of creating a new background context within the function. This would ensure that any cancellations or timeouts are respected throughout the function execution.

Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e0a69c7 and 8623a14.

Files selected for processing (1)
  • server/profiling/prometheus/metrics.go (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • server/profiling/prometheus/metrics.go

@hackerwins hackerwins changed the title Add Count of Connection Metric Add metric for WatchDocument streams Sep 5, 2024
@hackerwins hackerwins merged commit 0994f95 into main Sep 5, 2024
5 checks passed
@hackerwins hackerwins deleted the feat-watch-metric branch September 5, 2024 08:11
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.

2 participants