Skip to content

Commit

Permalink
Remove existing Metrics code (#2030)
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas authored May 4, 2021
1 parent b1df9db commit 9d415bf
Show file tree
Hide file tree
Showing 110 changed files with 24 additions and 6,805 deletions.
14 changes: 1 addition & 13 deletions OpenTelemetry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Zipk
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Api", "src\OpenTelemetry.Api\OpenTelemetry.Api.csproj", "{99F8A331-05E9-45A5-89BA-4C54E825E5B2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Prometheus", "src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj", "{AD9B2B54-EC9C-448E-BD3C-EDCC3F7AD022}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.AspNetCore", "src\OpenTelemetry.Instrumentation.AspNetCore\OpenTelemetry.Instrumentation.AspNetCore.csproj", "{752D2182-A351-41D8-99EE-DD363D7D5B43}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.AspNetCore.Tests", "test\OpenTelemetry.Instrumentation.AspNetCore.Tests\OpenTelemetry.Instrumentation.AspNetCore.Tests.csproj", "{2A47F6A8-63E5-4237-8046-94CAF321E797}"
Expand Down Expand Up @@ -75,8 +73,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Extensions.Ho
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.OpenTelemetryProtocol", "src\OpenTelemetry.Exporter.OpenTelemetryProtocol\OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj", "{A38AC295-2745-4B85-8B6B-DCA864CEDD5B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Prometheus.Tests", "test\OpenTelemetry.Exporter.Prometheus.Tests\OpenTelemetry.Exporter.Prometheus.Tests.csproj", "{393128EC-454D-45E8-A204-EC54904E5B3F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.ZPages", "src\OpenTelemetry.Exporter.ZPages\OpenTelemetry.Exporter.ZPages.csproj", "{56A34828-621A-478B-A0B8-C065FE938383}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Console", "src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj", "{1AFFF251-3B0C-47CA-BE94-937083732C0A}"
Expand Down Expand Up @@ -209,7 +205,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp.AspNetCore.5.0", "t
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "exception-reporting", "docs\trace\exception-reporting\exception-reporting.csproj", "{08D29501-F0A3-468F-B18D-BD1821A72383}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "customizing-the-sdk", "docs\trace\customizing-the-sdk\customizing-the-sdk.csproj", "{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "customizing-the-sdk", "docs\trace\customizing-the-sdk\customizing-the-sdk.csproj", "{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -233,10 +229,6 @@ Global
{99F8A331-05E9-45A5-89BA-4C54E825E5B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99F8A331-05E9-45A5-89BA-4C54E825E5B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99F8A331-05E9-45A5-89BA-4C54E825E5B2}.Release|Any CPU.Build.0 = Release|Any CPU
{AD9B2B54-EC9C-448E-BD3C-EDCC3F7AD022}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD9B2B54-EC9C-448E-BD3C-EDCC3F7AD022}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD9B2B54-EC9C-448E-BD3C-EDCC3F7AD022}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD9B2B54-EC9C-448E-BD3C-EDCC3F7AD022}.Release|Any CPU.Build.0 = Release|Any CPU
{752D2182-A351-41D8-99EE-DD363D7D5B43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{752D2182-A351-41D8-99EE-DD363D7D5B43}.Debug|Any CPU.Build.0 = Debug|Any CPU
{752D2182-A351-41D8-99EE-DD363D7D5B43}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -285,10 +277,6 @@ Global
{A38AC295-2745-4B85-8B6B-DCA864CEDD5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A38AC295-2745-4B85-8B6B-DCA864CEDD5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A38AC295-2745-4B85-8B6B-DCA864CEDD5B}.Release|Any CPU.Build.0 = Release|Any CPU
{393128EC-454D-45E8-A204-EC54904E5B3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{393128EC-454D-45E8-A204-EC54904E5B3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{393128EC-454D-45E8-A204-EC54904E5B3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{393128EC-454D-45E8-A204-EC54904E5B3F}.Release|Any CPU.Build.0 = Release|Any CPU
{56A34828-621A-478B-A0B8-C065FE938383}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56A34828-621A-478B-A0B8-C065FE938383}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56A34828-621A-478B-A0B8-C065FE938383}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ libraries](https://github.com/open-telemetry/opentelemetry-specification/blob/ma
* [Jaeger](./src/OpenTelemetry.Exporter.Jaeger/README.md)
* [OTLP](./src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md)
(OpenTelemetry Protocol)
* [Prometheus](./src/OpenTelemetry.Exporter.Prometheus/README.md)
* [Zipkin](./src/OpenTelemetry.Exporter.Zipkin/README.md)

See the [OpenTelemetry registry](https://opentelemetry.io/registry/?s=net) for
Expand Down
5 changes: 0 additions & 5 deletions docs/metrics/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ Please check the [Metric support
plan](https://github.com/open-telemetry/opentelemetry-dotnet/issues/1501).

## Sample usage

Check
[TestPrometheusExporter.cs](../../examples/Console/TestPrometheusExporter.cs)
for an example usage of currently implemented Metrics API/SDK along with
Prometheus exporter.
1 change: 0 additions & 1 deletion examples/Console/Examples.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.StackExchangeRedis\OpenTelemetry.Instrumentation.StackExchangeRedis.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.OpenTelemetryProtocol\OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.ZPages\OpenTelemetry.Exporter.ZPages.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Shims.OpenTracing\OpenTelemetry.Shims.OpenTracing.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void Main(string[] args)
.MapResult(
(JaegerOptions options) => TestJaegerExporter.Run(options.Host, options.Port),
(ZipkinOptions options) => TestZipkinExporter.Run(options.Uri),
(PrometheusOptions options) => TestPrometheusExporter.RunAsync(options.Port, options.PushIntervalInSecs, options.DurationInMins),
(PrometheusOptions options) => TestPrometheusExporter.Run(options.Port, options.PushIntervalInSecs, options.DurationInMins),
(GrpcNetClientOptions options) => TestGrpcNetClient.Run(),
(HttpClientOptions options) => TestHttpClient.Run(),
(RedisOptions options) => TestRedis.Run(options.Uri),
Expand Down
71 changes: 1 addition & 70 deletions examples/Console/TestPrometheusExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
using System.Diagnostics;
using System.Threading.Tasks;
using OpenTelemetry;
using OpenTelemetry.Exporter.Prometheus;
using OpenTelemetry.Metrics;
using OpenTelemetry.Metrics.Export;
using OpenTelemetry.Trace;

namespace Examples.Console
{
internal class TestPrometheusExporter
{
internal static async Task<object> RunAsync(int port, int pushIntervalInSecs, int totalDurationInMins)
internal static object Run(int port, int pushIntervalInSecs, int totalDurationInMins)
{
System.Console.WriteLine($"OpenTelemetry Prometheus Exporter is making metrics available at http://localhost:{port}/metrics/");

Expand All @@ -45,74 +42,8 @@ internal static async Task<object> RunAsync(int port, int pushIntervalInSecs, in
static_configs:
- targets: ['localhost:9184']
*/

// Create and Setup Prometheus Exporter
var promOptions = new PrometheusExporterOptions() { Url = $"http://localhost:{port}/metrics/" };
var promExporter = new PrometheusExporter(promOptions);
var metricsHttpServer = new PrometheusExporterMetricsHttpServer(promExporter);
metricsHttpServer.Start();

// Create Processor (called Batcher in Metric spec, this is still not decided)
var processor = new UngroupedBatcher();

// Application which decides to enable OpenTelemetry metrics
// would setup a MeterProvider and make it default.
// All meters from this factory will be configured with the common processing pipeline.
MeterProvider.SetDefault(Sdk.CreateMeterProviderBuilder()
.SetProcessor(processor)
.SetExporter(promExporter)
.SetPushInterval(TimeSpan.FromSeconds(pushIntervalInSecs))
.Build());

// The following shows how libraries would obtain a MeterProvider.
// MeterProvider is the entry point, which provides Meter.
// If user did not set the Default MeterProvider (shown in earlier lines),
// all metric operations become no-ops.
var meterProvider = MeterProvider.Default;
var meter = meterProvider.GetMeter("MyMeter");

// the rest is purely from Metrics API.
var testCounter = meter.CreateInt64Counter("MyCounter");
var testMeasure = meter.CreateInt64Measure("MyMeasure");
var testObserver = meter.CreateInt64Observer("MyObservation", CallBackForMyObservation);
var labels1 = new List<KeyValuePair<string, string>>();
labels1.Add(new KeyValuePair<string, string>("dim1", "value1"));

var labels2 = new List<KeyValuePair<string, string>>();
labels2.Add(new KeyValuePair<string, string>("dim1", "value2"));
var defaultContext = default(SpanContext);

Stopwatch sw = Stopwatch.StartNew();
while (sw.Elapsed.TotalMinutes < totalDurationInMins)
{
testCounter.Add(defaultContext, 100, meter.GetLabelSet(labels1));

testMeasure.Record(defaultContext, 100, meter.GetLabelSet(labels1));
testMeasure.Record(defaultContext, 500, meter.GetLabelSet(labels1));
testMeasure.Record(defaultContext, 5, meter.GetLabelSet(labels1));
testMeasure.Record(defaultContext, 750, meter.GetLabelSet(labels1));

// Obviously there is no testObserver.Oberve() here, as Observer instruments
// have callbacks that are called by the Meter automatically at each collection interval.

await Task.Delay(1000);
var remaining = (totalDurationInMins * 60) - sw.Elapsed.TotalSeconds;
System.Console.WriteLine("Running and emitting metrics. Remaining time:" + (int)remaining + " seconds");
}

// Stopping
metricsHttpServer.Stop();
System.Console.WriteLine("Metrics server shutdown.");
System.Console.WriteLine("Press Enter key to exit.");
return null;
}

internal static void CallBackForMyObservation(Int64ObserverMetric observerMetric)
{
var labels1 = new List<KeyValuePair<string, string>>();
labels1.Add(new KeyValuePair<string, string>("dim1", "value1"));

observerMetric.Observe(Process.GetCurrentProcess().WorkingSet64, labels1);
}
}
}
3 changes: 3 additions & 0 deletions src/OpenTelemetry.Api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ branch](https://github.com/open-telemetry/opentelemetry-dotnet/tree/metrics),
please check the latest changes
[here](https://github.com/open-telemetry/opentelemetry-dotnet/blob/metrics/src/OpenTelemetry.Api/CHANGELOG.md#experimental---metrics).

* Removed existing Metrics code as the spec is completely being re-written.
([#2030](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2030))

## Unreleased

## 1.1.0-beta2
Expand Down
27 changes: 0 additions & 27 deletions src/OpenTelemetry.Api/Metrics/BlankLabelSet.cs

This file was deleted.

44 changes: 0 additions & 44 deletions src/OpenTelemetry.Api/Metrics/BoundCounterMetric.cs

This file was deleted.

44 changes: 0 additions & 44 deletions src/OpenTelemetry.Api/Metrics/BoundMeasureMetric.cs

This file was deleted.

Loading

0 comments on commit 9d415bf

Please sign in to comment.