-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Draft: Perf Counter Implementation #52679
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
still adding changes
- Loading branch information
commit e062c1805e08c9b12d916d964e3089b14c14c88b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/PerfCounterItemCounts.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Threading; | ||
|
|
||
| namespace Azure.Monitor.OpenTelemetry.Exporter.Internals | ||
| { | ||
| /// <summary> | ||
| /// Thread-safe counters for performance metrics. | ||
| /// </summary> | ||
| internal sealed class PerfCounterItemCounts | ||
| { | ||
| private long _totalRequestCount = 0; | ||
| private long _totalExceptionCount = 0; | ||
|
|
||
| /// <summary> | ||
| /// Atomically increments the total request count. | ||
| /// </summary> | ||
| /// <returns>The new value after incrementing.</returns> | ||
| public long IncrementRequestCount() | ||
| { | ||
| return Interlocked.Increment(ref _totalRequestCount); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Atomically increments the total exception count. | ||
| /// </summary> | ||
| /// <returns>The new value after incrementing.</returns> | ||
| public long IncrementExceptionCount() | ||
| { | ||
| return Interlocked.Increment(ref _totalExceptionCount); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exception rate should be derived from |
||
| } | ||
|
|
||
| /// <summary> | ||
| /// Atomically reads the current total request count. | ||
| /// </summary> | ||
| /// <returns>The current request count.</returns> | ||
| public long ReadRequestCount() | ||
| { | ||
| return Interlocked.Read(ref _totalRequestCount); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Atomically reads the current total exception count. | ||
| /// </summary> | ||
| /// <returns>The current exception count.</returns> | ||
| public long ReadExceptionCount() | ||
| { | ||
| return Interlocked.Read(ref _totalExceptionCount); | ||
| } | ||
| } | ||
| } | ||
41 changes: 41 additions & 0 deletions
41
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/PerfCounterLogProcessor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Diagnostics; | ||
| using OpenTelemetry; | ||
| using OpenTelemetry.Logs; | ||
|
|
||
| namespace Azure.Monitor.OpenTelemetry.Exporter.Internals | ||
| { | ||
| internal sealed class PerfCounterLogProcessor : BaseProcessor<LogRecord> | ||
| { | ||
| private bool _disposed; | ||
| private readonly PerfCounterItemCounts _itemCounts; | ||
|
|
||
| internal PerfCounterLogProcessor(PerfCounterItemCounts itemCounts) | ||
| { | ||
| _itemCounts = itemCounts; | ||
| } | ||
|
|
||
| public override void OnEnd(LogRecord data) | ||
| { | ||
| if (data.Exception is not null) | ||
| { | ||
| _itemCounts.IncrementExceptionCount(); | ||
| } | ||
| } | ||
|
|
||
| protected override void Dispose(bool disposing) | ||
| { | ||
| if (!_disposed) | ||
| { | ||
| if (disposing) | ||
| { | ||
| // cleanup if needed | ||
| } | ||
| _disposed = true; | ||
| } | ||
| base.Dispose(disposing); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request rate should be derived from
http.server.request.durationmetrics by taking the histogram count and dividing by 60 (the aggregation window) to get requests per second.