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

System.Diagnostics (Observability) work planned for .NET 7 #62027

Closed
10 tasks done
Tracked by #57209
tarekgh opened this issue Nov 24, 2021 · 7 comments
Closed
10 tasks done
Tracked by #57209

System.Diagnostics (Observability) work planned for .NET 7 #62027

tarekgh opened this issue Nov 24, 2021 · 7 comments
Assignees
Labels
area-System.Diagnostics Epic Groups multiple user stories. Can be grouped under a theme. Priority:2 Work that is important, but not critical for the release Team:Libraries
Milestone

Comments

@tarekgh
Copy link
Member

tarekgh commented Nov 24, 2021

This issue captures the planned work for .NET 7. This list is expected to change throughout the release cycle according to ongoing planning and discussions, with possible additions and subtractions to the scope.

Planned for .NET 7

Planned for .NET 8+

@tarekgh tarekgh added Epic Groups multiple user stories. Can be grouped under a theme. area-System.Diagnostics labels Nov 24, 2021
@tarekgh tarekgh added this to the .NET 7.0 milestone Nov 24, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Nov 24, 2021
@tarekgh tarekgh removed the untriaged New issue has not been triaged by the area owner label Nov 24, 2021
@tarekgh
Copy link
Member Author

tarekgh commented Nov 24, 2021

CC @noahfalk @shirhatti @cijothomas @reyang @maryamariyan

@ghost
Copy link

ghost commented Nov 24, 2021

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

Issue Details

This issue is listing the candidate features/work for .NET 7.0. This list is expected to change according to the discussions and planning. We expect this list will be filtered and possibly other items can be added.

Author: tarekgh
Assignees: -
Labels:

Epic, area-System.Diagnostics

Milestone: .NET 7.0

@karelz karelz modified the milestones: .NET 7.0, 7.0.0 Nov 25, 2021
@jeffhandley jeffhandley changed the title Observability candidate items for .NET 7.0 System.Diagnostics (Observability) work planned for .NET 7 Jan 14, 2022
@tarekgh tarekgh self-assigned this Jan 17, 2022
@jeffhandley jeffhandley added the Priority:2 Work that is important, but not critical for the release label Feb 1, 2022
@ejsmith
Copy link

ejsmith commented Apr 29, 2022

@tarekgh this OpenTelemetry spec feature is really important for a lot of scenarios:

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#multiple-instrument-callbacks

I am attempting to populate queue stats like queue count, working item count and deadletter counts as 3 different observable gauges. Getting the counts requires an expensive call and, when I make that, it returns all 3 counts at the same time. The problem is since gauges are required to be observable, I have to give different callbacks for each gauge. I think there are a lot of similar use cases that would greatly benefit from this feature being implemented.

@tarekgh
Copy link
Member Author

tarekgh commented May 2, 2022

@ejsmith thanks for the suggestion. For now, you may solve this by using the following simple workaround:

    public class InstrumentsValues<T1, T2, T3>
                    where T1 : struct
                    where T2 : struct
                    where T3 : struct
    {
        private T1? _value1;
        private T2? _value2;
        private T3? _value3;
        private Func<(T1, T2, T3)> UpdateValues { get; set; }

        public InstrumentsValues(Func<(T1, T2, T3)> readValues)
        {
            _value1 = null;
            _value2 = null;
            _value3 = null;

            UpdateValues = readValues;
        }

        public T1 GetValue1()
        {
            if (!_value1.HasValue)
            {
                (_value1, _value2, _value3) = UpdateValues();
            }

            T1 value = _value1.Value;
            _value1 = null;
            return value;
        }

        public T2 GetValue2()
        {
            if (!_value2.HasValue)
            {
                (_value1, _value2, _value3) = UpdateValues();
            }

            T2 value = _value2.Value;
            _value2 = null;
            return value;
        }

        public T3 GetValue3()
        {
            if (!_value3.HasValue)
            {
                (_value1, _value2, _value3) = UpdateValues();
            }

            T3 value = _value3.Value;
            _value3 = null;
            return value;
        }
    }

and here is an example how to use it:

            Random random = new Random();
            using Meter meter = new Meter("My Meter");
            InstrumentsValues<int, long, double> values = new InstrumentsValues<int, long, double>(() => (random.Next(), random.NextInt64(), random.NextDouble()));

            ObservableCounter<int> observableCounter1 = meter.CreateObservableCounter<int>("Counter 1", () => new Measurement<int>(values.GetValue1(), new KeyValuePair<string, object?>("Counter 1", null)));
            ObservableGauge<long> observableGauge = meter.CreateObservableGauge<long>("Gauge 1", () => new Measurement<long>(values.GetValue2(), new KeyValuePair<string, object?>("Gauge 1", null)));
            ObservableCounter<double> observableCounter2 = meter.CreateObservableCounter<double>("Counter 2", () => new Measurement<double>(values.GetValue3(), new KeyValuePair<string, object?>("Counter 2", null)));

I assume your gauges are going to be observed at the same time. But if not, it is easy to tweak this implementation to invalidate the values periodically.

CC @noahfalk @reyang @CodeBlanch

@ejsmith
Copy link

ejsmith commented May 2, 2022

@tarekgh I'll give this method a try. I tried something similar, but it didn't work.

@ejsmith
Copy link

ejsmith commented May 2, 2022

@tarekgh that did work. Thank you!

@tarekgh tarekgh modified the milestones: 7.0.0, 8.0.0 Jul 22, 2022
@noahfalk
Copy link
Member

@tarekgh - how do you feel about closing this issue and we can re-open a new one once we've made plans with the OpenTelemetry folks for .NET 8? We can always refer back to this issue if we want to see the list of items we were considering - the list won't be lost.

@tarekgh tarekgh closed this as completed Jul 26, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 25, 2022
@jeffhandley jeffhandley modified the milestones: 8.0.0, 7.0.0 Jan 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Diagnostics Epic Groups multiple user stories. Can be grouped under a theme. Priority:2 Work that is important, but not critical for the release Team:Libraries
Projects
None yet
Development

No branches or pull requests

5 participants