-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into main
- Loading branch information
Showing
96 changed files
with
2,590 additions
and
736 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
|
@@ -29,9 +29,7 @@ | |
{ | ||
"files": [ | ||
".editorconfig", | ||
"docs/**.cs", | ||
"examples/**.cs", | ||
"src/**.cs" | ||
"**.cs" | ||
] | ||
} | ||
], | ||
|
This file contains 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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPkgVer)" /> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains 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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPkgVer)" /> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains 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,99 @@ | ||
// <copyright file="Program.cs" company="OpenTelemetry Authors"> | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Diagnostics.Metrics; | ||
using OpenTelemetry; | ||
using OpenTelemetry.Metrics; | ||
|
||
public class Program | ||
{ | ||
private static readonly Meter Meter1 = new Meter("CompanyA.ProductA.Library1", "1.0"); | ||
private static readonly Meter Meter2 = new Meter("CompanyA.ProductB.Library2", "1.0"); | ||
|
||
public static void Main(string[] args) | ||
{ | ||
using var meterProvider = Sdk.CreateMeterProviderBuilder() | ||
.AddSource(Meter1.Name) | ||
.AddSource(Meter2.Name) | ||
|
||
// Rename an instrument to new name. | ||
.AddView(instrumentName: "MyCounter", name: "MyCounterRenamed") | ||
|
||
// Change Histogram bounds | ||
.AddView(instrumentName: "MyHistogram", new HistogramConfiguration() { BucketBounds = new double[] { 10, 20 }, Aggregation = Aggregation.LastValue }) | ||
|
||
// For the instrument "MyCounterCustomTags", aggregate with only the keys "tag1", "tag2". | ||
.AddView(instrumentName: "MyCounterCustomTags", new MetricStreamConfiguration() { TagKeys = new string[] { "tag1", "tag2" } }) | ||
|
||
// Drop the instrument "MyCounterDrop". | ||
.AddView(instrumentName: "MyCounterDrop", new MetricStreamConfiguration() { Aggregation = Aggregation.Drop }) | ||
|
||
// Advanced selection criteria and config via Func<Instrument, AggregationConfig> | ||
.AddView((instrument) => | ||
{ | ||
if (instrument.Meter.Name.Equals("CompanyA.ProductB.Library2") && | ||
instrument.GetType().Name.Contains("Histogram")) | ||
{ | ||
return new HistogramConfiguration() { BucketBounds = new double[] { 10, 20 } }; | ||
} | ||
|
||
return null; | ||
}) | ||
|
||
// An instrument which does not match any views | ||
// gets processed with default behavior. (SDK default) | ||
// Uncommenting the following line will | ||
// turn off the above default. i.e any | ||
// instrument which does not match any views | ||
// gets dropped. | ||
// .AddView(instrumentName: "*", new MetricStreamConfiguration() { Aggregation = Aggregation.Drop }) | ||
.AddConsoleExporter() | ||
.Build(); | ||
|
||
var random = new Random(); | ||
|
||
var counter = Meter1.CreateCounter<long>("MyCounter"); | ||
for (int i = 0; i < 20000; i++) | ||
{ | ||
counter.Add(1, new("tag1", "value1"), new("tag2", "value2")); | ||
} | ||
|
||
var histogram = Meter1.CreateHistogram<long>("MyHistogram"); | ||
for (int i = 0; i < 20000; i++) | ||
{ | ||
histogram.Record(random.Next(1, 1000), new("tag1", "value1"), new("tag2", "value2")); | ||
} | ||
|
||
var counterCustomTags = Meter1.CreateCounter<long>("MyCounterCustomTags"); | ||
for (int i = 0; i < 20000; i++) | ||
{ | ||
counterCustomTags.Add(1, new("tag1", "value1"), new("tag2", "value2"), new("tag3", "value4")); | ||
} | ||
|
||
var counterDrop = Meter1.CreateCounter<long>("MyCounterDrop"); | ||
for (int i = 0; i < 20000; i++) | ||
{ | ||
counterDrop.Add(1, new("tag1", "value1"), new("tag2", "value2")); | ||
} | ||
|
||
var histogram2 = Meter2.CreateHistogram<long>("MyHistogram2"); | ||
for (int i = 0; i < 20000; i++) | ||
{ | ||
histogram2.Record(random.Next(1, 1000), new("tag1", "value1"), new("tag2", "value2")); | ||
} | ||
} | ||
} |
This file contains 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,71 @@ | ||
# Customizing OpenTelemetry .NET SDK for Metrics | ||
|
||
## MeterProvider | ||
|
||
As shown in the [getting-started](../getting-started/README.md) doc, a valid | ||
[`MeterProvider`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#meterprovider) | ||
must be configured and built to collect metrics with OpenTelemetry .NET Sdk. | ||
`MeterProvider` holds all the configuration for tracing like metricreaders, | ||
views, etc. Naturally, almost all the customizations must be done on the | ||
`MeterProvider`. | ||
|
||
## Building a MeterProvider | ||
|
||
Building a `MeterProvider` is done using `MeterProviderBuilder` which must be | ||
obtained by calling `Sdk.CreateMeterProviderBuilder()`. `MeterProviderBuilder` | ||
exposes various methods which configures the provider it is going to build. These | ||
includes methods like `AddSource`, `AddView` etc, and are explained in | ||
subsequent sections of this document. Once configuration is done, calling | ||
`Build()` on the `MeterProviderBuilder` builds the `MeterProvider` instance. | ||
Once built, changes to its configuration is not allowed. In most cases, | ||
a single `MeterProvider` is created at the application startup, | ||
and is disposed when application shuts down. | ||
|
||
The snippet below shows how to build a basic `MeterProvider`. This will create | ||
a provider with default configuration, and is not particularly useful. The | ||
subsequent sections shows how to build a more useful provider. | ||
|
||
```csharp | ||
using OpenTelemetry; | ||
using OpenTelemetry.Metrics; | ||
|
||
using var meterProvider = Sdk.CreateMeterProviderBuilder().Build(); | ||
``` | ||
|
||
## MeterProvider configuration | ||
|
||
`MeterProvider` holds the metrics configuration, which includes the following: | ||
|
||
1. The list of `Meter`s from which measurements are collected. | ||
2. The list of instrumentations enabled via | ||
[InstrumentationLibrary](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/glossary.md#instrumentation-library). | ||
3. The list of | ||
[MetricReaders](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#metricreader), | ||
including exporting readers which exports metrics to | ||
[Exporters](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#metricexporter) | ||
4. The | ||
[Resource](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md) | ||
associated with the metrics. | ||
5. The list of | ||
[Views](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#view) | ||
to be used. | ||
|
||
### Meter | ||
|
||
// TODO | ||
|
||
### View | ||
|
||
// TODO | ||
|
||
### Instrumentation | ||
|
||
// TODO | ||
|
||
### MetricReader | ||
|
||
// TODO | ||
|
||
### Resource | ||
|
||
// TODO |
This file contains 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,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains 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 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 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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" /> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains 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 |
---|---|---|
@@ -1,8 +1,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<!--- | ||
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="$(OpenTelemetryExporterConsolePkgVer)" /> | ||
--> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains 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 |
---|---|---|
@@ -1,8 +1,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<!-- | ||
<PackageReference Include="OpenTelemetry" Version="$(OpenTelemetryPkgVer)" /> | ||
--> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains 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 |
---|---|---|
@@ -1,8 +1,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<!--- | ||
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="$(OpenTelemetryExporterConsolePkgVer)" /> | ||
--> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" /> | ||
</ItemGroup> | ||
</Project> |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
docs/trace/exception-reporting/README.md → docs/trace/reporting-exceptions/README.md
This file contains 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
Oops, something went wrong.