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

Remove guage & add Observer metric instrument #498

Merged
merged 7 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="Counter.cs" company="OpenTelemetry Authors">
// <copyright file="CounterMetric.cs" company="OpenTelemetry Authors">
// Copyright 2018, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -24,7 +24,7 @@ namespace OpenTelemetry.Metrics
/// Counter instrument.
/// </summary>
/// <typeparam name="T">The type of counter. Only long and double are supported now.</typeparam>
public abstract class Counter<T>
public abstract class CounterMetric<T>
where T : struct
{
/// <summary>
Expand Down Expand Up @@ -64,13 +64,13 @@ public abstract class Counter<T>
/// </summary>
/// <param name="labelset">The labelset from which handle should be constructed.</param>
/// <returns>The handle.</returns>
public abstract CounterHandle<T> GetHandle(LabelSet labelset);
public abstract CounterMetricHandle<T> GetHandle(LabelSet labelset);

/// <summary>
/// Gets the handle with given labels.
/// </summary>
/// <param name="labels">The labels or dimensions associated with this value.</param>
/// <returns>The handle.</returns>
public abstract CounterHandle<T> GetHandle(IEnumerable<KeyValuePair<string, string>> labels);
public abstract CounterMetricHandle<T> GetHandle(IEnumerable<KeyValuePair<string, string>> labels);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="CounterHandle.cs" company="OpenTelemetry Authors">
// <copyright file="CounterMetricHandle.cs" company="OpenTelemetry Authors">
// Copyright 2018, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -23,7 +23,7 @@ namespace OpenTelemetry.Metrics
/// Handle to the metrics counter with the defined <see cref="LabelSet"/>.
/// </summary>
/// <typeparam name="T">The type of counter. Only long and double are supported now.</typeparam>
public abstract class CounterHandle<T>
public abstract class CounterMetricHandle<T>
where T : struct
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="Measure.cs" company="OpenTelemetry Authors">
// <copyright file="MeasureMetric.cs" company="OpenTelemetry Authors">
// Copyright 2018, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -24,7 +24,7 @@ namespace OpenTelemetry.Metrics
/// Measure instrument.
/// </summary>
/// <typeparam name="T">The type of counter. Only long and double are supported now.</typeparam>
public abstract class Measure<T>
public abstract class MeasureMetric<T>
where T : struct
{
/// <summary>
Expand Down Expand Up @@ -64,13 +64,13 @@ public abstract class Measure<T>
/// </summary>
/// <param name="labelset">The labelset from which handle should be constructed.</param>
/// <returns>The handle.</returns>
public abstract MeasureHandle<T> GetHandle(LabelSet labelset);
public abstract MeasureMetricHandle<T> GetHandle(LabelSet labelset);

/// <summary>
/// Gets the handle with given labelset.
/// </summary>
/// <param name="labels">The labels or dimensions associated with this value.</param>
/// <returns>The handle.</returns>
public abstract MeasureHandle<T> GetHandle(IEnumerable<KeyValuePair<string, string>> labels);
public abstract MeasureMetricHandle<T> GetHandle(IEnumerable<KeyValuePair<string, string>> labels);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="MeasureHandle.cs" company="OpenTelemetry Authors">
// <copyright file="MeasureMetricHandle.cs" company="OpenTelemetry Authors">
// Copyright 2018, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -23,7 +23,7 @@ namespace OpenTelemetry.Metrics
/// Handle to the metrics Measure with the defined <see cref="LabelSet"/>.
/// </summary>
/// <typeparam name="T">The type of Measure. Only long and double are supported now.</typeparam>
public abstract class MeasureHandle<T>
public abstract class MeasureMetricHandle<T>
where T : struct
{
/// <summary>
Expand Down
40 changes: 20 additions & 20 deletions src/OpenTelemetry.Api/Metrics/Meter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,47 +29,47 @@ public abstract class Meter
/// <param name="name">The name of the counter.</param>
/// <param name="monotonic">indicates if only positive values are expected.</param>
/// <returns>The counter instance.</returns>
public abstract Counter<long> CreateInt64Counter(string name, bool monotonic = true);
public abstract CounterMetric<long> CreateInt64Counter(string name, bool monotonic = true);

/// <summary>
/// Creates double counter with given name.
/// </summary>
/// <param name="name">indicates if only positive values are expected.</param>
/// <param name="monotonic">The name of the counter.</param>
/// <returns>The counter instance.</returns>
public abstract Counter<double> CreateDoubleCounter(string name, bool monotonic = true);

/// <summary>
/// Creates Int64 Gauge with given name.
/// </summary>
/// <param name="name">The name of the counter.</param>
/// <param name="monotonic">indicates if only positive values are expected.</param>
/// <returns>The Gauge instance.</returns>
public abstract Gauge<long> CreateInt64Gauge(string name, bool monotonic = false);

/// <summary>
/// Creates double Gauge with given name.
/// </summary>
/// <param name="name">The name of the counter.</param>
/// <param name="monotonic">indicates if only positive values are expected.</param>
/// <returns>The Gauge instance.</returns>
public abstract Gauge<double> CreateDoubleGauge(string name, bool monotonic = false);
public abstract CounterMetric<double> CreateDoubleCounter(string name, bool monotonic = true);

/// <summary>
/// Creates Int64 Measure with given name.
/// </summary>
/// <param name="name">The name of the measure.</param>
/// <param name="absolute">indicates if only positive values are expected.</param>
/// <returns>The measure instance.</returns>
public abstract Measure<long> CreateInt64Measure(string name, bool absolute = true);
public abstract MeasureMetric<long> CreateInt64Measure(string name, bool absolute = true);

/// <summary>
/// Creates double Measure with given name.
/// </summary>
/// <param name="name">The name of the measure.</param>
/// <param name="absolute">indicates if only positive values are expected.</param>
/// <returns>The measure instance.</returns>
public abstract Measure<double> CreateDoubleMeasure(string name, bool absolute = true);
public abstract MeasureMetric<double> CreateDoubleMeasure(string name, bool absolute = true);

/// <summary>
/// Creates Int64 Observer with given name.
/// </summary>
/// <param name="name">The name of the observer.</param>
/// <param name="absolute">indicates if only positive values are expected.</param>
/// <returns>The observer instance.</returns>
public abstract ObserverMetric<long> CreateInt64Observer(string name, bool absolute = true);

/// <summary>
/// Creates a double Observer with given name.
/// </summary>
/// <param name="name">The name of the observer.</param>
/// <param name="absolute">indicates if only positive values are expected.</param>
/// <returns>The observer instance.</returns>
public abstract ObserverMetric<double> CreateDoubleObserver(string name, bool absolute = true);

/// <summary>
/// Constructs or retrieves the <see cref="LabelSet"/> from the given label key-value pairs.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="NoOpCounter.cs" company="OpenTelemetry Authors">
// <copyright file="NoOpCounterMetric.cs" company="OpenTelemetry Authors">
// Copyright 2018, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -24,24 +24,24 @@ namespace OpenTelemetry.Metrics
/// A no-op counter instrument.
/// </summary>
/// <typeparam name="T">The type of counter. Only long and double are supported now.</typeparam>
public sealed class NoOpCounter<T> : Counter<T>
public sealed class NoOpCounterMetric<T> : CounterMetric<T>
where T : struct
{
/// <summary>
/// No op counter instance.
/// </summary>
public static readonly NoOpCounter<T> Instance = new NoOpCounter<T>();
public static readonly NoOpCounterMetric<T> Instance = new NoOpCounterMetric<T>();

/// <inheritdoc/>
public override CounterHandle<T> GetHandle(LabelSet labelset)
public override CounterMetricHandle<T> GetHandle(LabelSet labelset)
{
return NoOpCounterHandle<T>.Instance;
return NoOpCounterMetricHandle<T>.Instance;
}

/// <inheritdoc/>
public override CounterHandle<T> GetHandle(IEnumerable<KeyValuePair<string, string>> labels)
public override CounterMetricHandle<T> GetHandle(IEnumerable<KeyValuePair<string, string>> labels)
{
return NoOpCounterHandle<T>.Instance;
return NoOpCounterMetricHandle<T>.Instance;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="NoOpCounterHandle.cs" company="OpenTelemetry Authors">
// <copyright file="NoOpCounterMetricHandle.cs" company="OpenTelemetry Authors">
// Copyright 2018, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -23,13 +23,13 @@ namespace OpenTelemetry.Metrics
/// No-Op handle.
/// </summary>
/// <typeparam name="T">The type of counter. Only long and double are supported now.</typeparam>
public sealed class NoOpCounterHandle<T> : CounterHandle<T>
public sealed class NoOpCounterMetricHandle<T> : CounterMetricHandle<T>
where T : struct
{
/// <summary>
/// No op counter handle instance.
/// </summary>
public static readonly NoOpCounterHandle<T> Instance = new NoOpCounterHandle<T>();
public static readonly NoOpCounterMetricHandle<T> Instance = new NoOpCounterMetricHandle<T>();

/// <inheritdoc/>
public override void Add(in SpanContext context, T value)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="NoOpMeasure.cs" company="OpenTelemetry Authors">
// <copyright file="NoOpMeasureMetric.cs" company="OpenTelemetry Authors">
// Copyright 2018, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -24,24 +24,24 @@ namespace OpenTelemetry.Metrics
/// No op measure instrument.
/// </summary>
/// <typeparam name="T">The type of counter. Only long and double are supported now.</typeparam>
public sealed class NoOpMeasure<T> : Measure<T>
public sealed class NoOpMeasureMetric<T> : MeasureMetric<T>
where T : struct
{
/// <summary>
/// No op measure instance.
/// </summary>
public static readonly NoOpMeasure<T> Instance = new NoOpMeasure<T>();
public static readonly NoOpMeasureMetric<T> Instance = new NoOpMeasureMetric<T>();

/// <inheritdoc/>
public override MeasureHandle<T> GetHandle(LabelSet labelset)
public override MeasureMetricHandle<T> GetHandle(LabelSet labelset)
{
return NoOpMeasureHandle<T>.Instance;
return NoOpMeasureMetricHandle<T>.Instance;
}

/// <inheritdoc/>
public override MeasureHandle<T> GetHandle(IEnumerable<KeyValuePair<string, string>> labels)
public override MeasureMetricHandle<T> GetHandle(IEnumerable<KeyValuePair<string, string>> labels)
{
return NoOpMeasureHandle<T>.Instance;
return NoOpMeasureMetricHandle<T>.Instance;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="NoOpMeasureHandle.cs" company="OpenTelemetry Authors">
// <copyright file="NoOpMeasureMetricHandle.cs" company="OpenTelemetry Authors">
// Copyright 2018, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -23,13 +23,13 @@ namespace OpenTelemetry.Metrics
/// No op measure handle.
/// </summary>
/// <typeparam name="T">The type of Measure. Only long and double are supported now.</typeparam>
public sealed class NoOpMeasureHandle<T> : MeasureHandle<T>
public sealed class NoOpMeasureMetricHandle<T> : MeasureMetricHandle<T>
where T : struct
{
/// <summary>
/// No op measure handle instance.
/// </summary>
public static readonly NoOpMeasureHandle<T> Instance = new NoOpMeasureHandle<T>();
public static readonly NoOpMeasureMetricHandle<T> Instance = new NoOpMeasureMetricHandle<T>();

/// <inheritdoc/>
public override void Record(in SpanContext context, T value)
Expand Down
24 changes: 12 additions & 12 deletions src/OpenTelemetry.Api/Metrics/NoOpMeter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,34 @@ public NoOpMeter()
{
}

public override Counter<double> CreateDoubleCounter(string name, bool monotonic = true)
public override CounterMetric<double> CreateDoubleCounter(string name, bool monotonic = true)
{
return NoOpCounter<double>.Instance;
return NoOpCounterMetric<double>.Instance;
}

public override Gauge<double> CreateDoubleGauge(string name, bool monotonic = false)
public override MeasureMetric<double> CreateDoubleMeasure(string name, bool absolute = true)
{
return NoOpGauge<double>.Instance;
return NoOpMeasureMetric<double>.Instance;
}

public override Measure<double> CreateDoubleMeasure(string name, bool absolute = true)
public override ObserverMetric<double> CreateDoubleObserver(string name, bool monotonic = true)
{
return NoOpMeasure<double>.Instance;
return NoOpObserverMetric<double>.Instance;
}

public override Counter<long> CreateInt64Counter(string name, bool monotonic = true)
public override CounterMetric<long> CreateInt64Counter(string name, bool monotonic = true)
{
return NoOpCounter<long>.Instance;
return NoOpCounterMetric<long>.Instance;
}

public override Gauge<long> CreateInt64Gauge(string name, bool monotonic = false)
public override MeasureMetric<long> CreateInt64Measure(string name, bool absolute = true)
{
return NoOpGauge<long>.Instance;
return NoOpMeasureMetric<long>.Instance;
}

public override Measure<long> CreateInt64Measure(string name, bool absolute = true)
public override ObserverMetric<long> CreateInt64Observer(string name, bool absolute = true)
{
return NoOpMeasure<long>.Instance;
return NoOpObserverMetric<long>.Instance;
}

public override LabelSet GetLabelSet(IEnumerable<KeyValuePair<string, string>> labels)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="NoOpGauge.cs" company="OpenTelemetry Authors">
// <copyright file="NoOpObserverMetric.cs" company="OpenTelemetry Authors">
// Copyright 2018, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -21,27 +21,27 @@
namespace OpenTelemetry.Metrics
{
/// <summary>
/// A no-op gauge instrument.
/// A no-op observer instrument.
/// </summary>
/// <typeparam name="T">The type of gauge. Only long and double are supported now.</typeparam>
public sealed class NoOpGauge<T> : Gauge<T>
/// <typeparam name="T">The type of observer. Only long and double are supported now.</typeparam>
public sealed class NoOpObserverMetric<T> : ObserverMetric<T>
where T : struct
{
/// <summary>
/// No op gauge instance.
/// No op observer instance.
/// </summary>
public static readonly NoOpGauge<T> Instance = new NoOpGauge<T>();
public static readonly NoOpObserverMetric<T> Instance = new NoOpObserverMetric<T>();

/// <inheritdoc/>
public override GaugeHandle<T> GetHandle(LabelSet labelset)
public override ObserverMetricHandle<T> GetHandle(LabelSet labelset)
{
return NoOpGaugeHandle<T>.Instance;
return NoOpObserverMetricHandle<T>.Instance;
}

/// <inheritdoc/>
public override GaugeHandle<T> GetHandle(IEnumerable<KeyValuePair<string, string>> labels)
public override ObserverMetricHandle<T> GetHandle(IEnumerable<KeyValuePair<string, string>> labels)
{
return NoOpGaugeHandle<T>.Instance;
return NoOpObserverMetricHandle<T>.Instance;
}
}
}
Loading