Skip to content

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

Closed

Description

@tarekgh

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+

Activity

  1. added
    Epic
    on Nov 24, 2021
  2. added this to the milestone on Nov 24, 2021
  3. ghost added
    untriaged
    on Nov 24, 2021
  4. removed
    untriaged
    on Nov 24, 2021
  5. tarekgh commented on Nov 24, 2021

    @tarekgh
    MemberAuthor
  6. modified the milestones: , 7.0.0 on Nov 25, 2021
  7. changed the title [-]Observability candidate items for .NET 7.0[/-] [+]System.Diagnostics (Observability) work planned for .NET 7[/+] on Jan 14, 2022
  8. self-assigned this
    on Jan 17, 2022
  9. added
    Priority:2
    on Feb 1, 2022
  10. ejsmith commented on Apr 29, 2022

    @ejsmith

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

  11. tarekgh commented on May 2, 2022

    @tarekgh
    MemberAuthor

    @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

  12. ejsmith commented on May 2, 2022

    @ejsmith

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

  13. ejsmith commented on May 2, 2022

    @ejsmith

    @tarekgh that did work. Thank you!

  14. modified the milestones: 7.0.0, 8.0.0 on Jul 22, 2022
  15. noahfalk commented on Jul 26, 2022

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

  16. ghost locked as resolved and limited conversation to collaborators on Aug 25, 2022
  17. modified the milestones: 8.0.0, 7.0.0 on Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

EpicPriority:2Team:Librariesarea-System.Diagnostics

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions