Skip to content

Commit

Permalink
Merge branch 'main' into AddSelfDiagnosticsLogging
Browse files Browse the repository at this point in the history
  • Loading branch information
ejsmith authored Aug 23, 2021
2 parents 2955cf9 + d649b3d commit f12ae02
Show file tree
Hide file tree
Showing 142 changed files with 6,824 additions and 1,064 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: markdownlint
on:
push:
branches: [ main, metrics ]
paths-ignore:
paths:
- '**.md'
pull_request:
branches: [ main, metrics ]
Expand Down
22 changes: 21 additions & 1 deletion OpenTelemetry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "metrics", "metrics", "{3277B1C0-BDFE-4460-9B0D-D9A661FB48DB}"
ProjectSection(SolutionItems) = preProject
docs\metrics\building-your-own-exporter.md = docs\metrics\building-your-own-exporter.md
docs\metrics\README.md = docs\metrics\README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "logs", "logs", "{3862190B-E2C5-418E-AFDC-DB281FB5C705}"
Expand Down Expand Up @@ -207,7 +208,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "customizing-the-sdk", "docs
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "getting-started", "docs\metrics\getting-started\getting-started.csproj", "{DFB0AD2F-11BE-4BCD-A77B-1018C3344FA8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.Exporter.Prometheus", "src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj", "{52158A12-E7EF-45A1-859F-06F9B17410CB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Prometheus", "src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj", "{52158A12-E7EF-45A1-859F-06F9B17410CB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule", "src\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj", "{F38E511B-1877-4E8A-8051-7879FC7DF8A4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests", "test\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj", "{4D7201BC-7124-4401-AD65-FAB58A053D45}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "getting-started-histogram", "docs\metrics\getting-started-histogram\getting-started-histogram.csproj", "{92ED77A6-37B4-447D-B4C4-15DB005A589C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -411,6 +418,18 @@ Global
{52158A12-E7EF-45A1-859F-06F9B17410CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52158A12-E7EF-45A1-859F-06F9B17410CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52158A12-E7EF-45A1-859F-06F9B17410CB}.Release|Any CPU.Build.0 = Release|Any CPU
{F38E511B-1877-4E8A-8051-7879FC7DF8A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F38E511B-1877-4E8A-8051-7879FC7DF8A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F38E511B-1877-4E8A-8051-7879FC7DF8A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F38E511B-1877-4E8A-8051-7879FC7DF8A4}.Release|Any CPU.Build.0 = Release|Any CPU
{4D7201BC-7124-4401-AD65-FAB58A053D45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D7201BC-7124-4401-AD65-FAB58A053D45}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D7201BC-7124-4401-AD65-FAB58A053D45}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D7201BC-7124-4401-AD65-FAB58A053D45}.Release|Any CPU.Build.0 = Release|Any CPU
{92ED77A6-37B4-447D-B4C4-15DB005A589C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92ED77A6-37B4-447D-B4C4-15DB005A589C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92ED77A6-37B4-447D-B4C4-15DB005A589C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92ED77A6-37B4-447D-B4C4-15DB005A589C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -443,6 +462,7 @@ Global
{08D29501-F0A3-468F-B18D-BD1821A72383} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
{DFB0AD2F-11BE-4BCD-A77B-1018C3344FA8} = {3277B1C0-BDFE-4460-9B0D-D9A661FB48DB}
{92ED77A6-37B4-447D-B4C4-15DB005A589C} = {3277B1C0-BDFE-4460-9B0D-D9A661FB48DB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {55639B5C-0770-4A22-AB56-859604650521}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Packages shipped from this repository generally support all the officially
supported versions of [.NET
Core](https://dotnet.microsoft.com/download/dotnet-core), and [.NET
Framework](https://dotnet.microsoft.com/download/dotnet-framework) except for
`.NET Framework 3.5 SP1`. Any exceptions to this are noted in the individual
`README.md` files.
versions lower than `.NET Framework 4.6.1`.
Any exceptions to this are noted in the individual `README.md` files.

## Getting Started

Expand Down
11 changes: 5 additions & 6 deletions build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@
<GrpcToolsPkgVer>[2.25.0,3.0)</GrpcToolsPkgVer>
<MicrosoftAspNetCoreHttpAbstractionsPkgVer>[2.1.1,6.0)</MicrosoftAspNetCoreHttpAbstractionsPkgVer>
<MicrosoftAspNetCoreHttpFeaturesPkgVer>[2.1.1,6.0)</MicrosoftAspNetCoreHttpFeaturesPkgVer>
<MicrosoftAspNetTelemetryCorrelationPkgVer>[1.0.7,2.0)</MicrosoftAspNetTelemetryCorrelationPkgVer>
<MicrosoftCodeAnalysisAnalyzersPkgVer>[3.3.1]</MicrosoftCodeAnalysisAnalyzersPkgVer>
<MicrosoftCodeCoveragePkgVer>[16.10.0]</MicrosoftCodeCoveragePkgVer>
<MicrosoftExtensionsHostingAbstractionsPkgVer>[2.1.0,6.0)</MicrosoftExtensionsHostingAbstractionsPkgVer>
<MicrosoftExtensionsLoggingPkgVer>[2.1.0,6.0)</MicrosoftExtensionsLoggingPkgVer>
<MicrosoftExtensionsLoggingConfigurationPkgVer>[2.1.0,6.0)</MicrosoftExtensionsLoggingConfigurationPkgVer>
<MicrosoftExtensionsOptionsPkgVer>[2.1.0,6.0)</MicrosoftExtensionsOptionsPkgVer>
<MicrosoftExtensionsHostingAbstractionsPkgVer>[2.1.0,)</MicrosoftExtensionsHostingAbstractionsPkgVer>
<MicrosoftExtensionsLoggingPkgVer>[2.1.0,)</MicrosoftExtensionsLoggingPkgVer>
<MicrosoftExtensionsLoggingConfigurationPkgVer>[2.1.0,)</MicrosoftExtensionsLoggingConfigurationPkgVer>
<MicrosoftExtensionsOptionsPkgVer>[2.1.0,)</MicrosoftExtensionsOptionsPkgVer>
<MicrosoftNETFrameworkReferenceAssembliesPkgVer>[1.0.0,2.0)</MicrosoftNETFrameworkReferenceAssembliesPkgVer>
<MicrosoftSourceLinkGitHubPkgVer>[1.0.0,2.0)</MicrosoftSourceLinkGitHubPkgVer>
<OpenTracingPkgVer>[0.12.1,0.13)</OpenTracingPkgVer>
Expand All @@ -57,7 +56,7 @@
<PackageReference Include="StyleCop.Analyzers" Version="$(StyleCopAnalyzersPkgVer)" Condition="'$(SkipAnalysis)'!='true'">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeCoverage" Version="$(MicrosoftCodeCoveragePkgVer)" Condition="'$(Configuration)'=='Release'"/>
<PackageReference Include="Microsoft.CodeCoverage" Version="$(MicrosoftCodeCoveragePkgVer)" PrivateAssets="All" Condition="'$(Configuration)'=='Release'" />
<!--<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="$(MicrosoftCodeAnalysisAnalyzersPkgVer)" Condition="'$(SkipAnalysis)'!='true'">
<PrivateAssets>all</PrivateAssets>
</PackageReference>-->
Expand Down
196 changes: 98 additions & 98 deletions build/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,130 +2,130 @@

Only for Maintainers.

1.Decide the tag name (version name) to be released.
eg: 1.0.0-rc2, 1.0.0 etc.

2.Run the following PowerShell from the root of the
repo to get combined changelog (to be used later).

```powershell
$changelogs = Get-ChildItem -Path . -Recurse -Filter changelog.md
foreach ($changelog in $changelogs)
{
Add-Content -Path .\combinedchangelog.md -Value "**$($changelog.Directory.Name)**"
$lines = Get-Content -Path $changelog.FullName
$started = $false
$ended = $false
foreach ($line in $lines)
{
if($line -like "## Unreleased" -and $started -ne $true)
{
$started = $true
}
elseif($line -like "## *" -and $started -eq $true)
{
$ended = $true
break
}
else
{
if ($started -eq $true)
1. Decide the tag name (version name) to be released.
eg: 1.0.0-rc2, 1.0.0 etc.

2. Run the following PowerShell from the root of the
repo to get combined changelog (to be used later).

```powershell
$changelogs = Get-ChildItem -Path . -Recurse -Filter changelog.md
foreach ($changelog in $changelogs)
{
Add-Content -Path .\combinedchangelog.md -Value "**$($changelog.Directory.Name)**"
$lines = Get-Content -Path $changelog.FullName
$started = $false
$ended = $false
foreach ($line in $lines)
{
if($line -like "## Unreleased" -and $started -ne $true)
{
Add-Content -Path .\combinedchangelog.md $line
$started = $true
}
}
}
}
```
elseif($line -like "## *" -and $started -eq $true)
{
$ended = $true
break
}
else
{
if ($started -eq $true)
{
Add-Content -Path .\combinedchangelog.md $line
}
}
}
}
```

This generates combined changelog to be used in Github release.
Once contents of combined changelog is saved somewhere,
delete the file.
This generates combined changelog to be used in Github release.
Once contents of combined changelog is saved somewhere,
delete the file.

3.Run the following PowerShell script from the root of the repo.
This updates all the changelog to have release date for the
current version being released.
Replace the version with actual version.
The actual version would be the tag name from step1.
3. Run the following PowerShell script from the root of the repo.
This updates all the changelog to have release date for the
current version being released.
Replace the version with actual version.
The actual version would be the tag name from step1.

```powershell
$changelogs = Get-ChildItem -Path . -Recurse -Filter changelog.md
foreach ($changelog in $changelogs)
{
(Get-Content -Path $changelog.FullName) -replace "Unreleased", "Unreleased
```powershell
$changelogs = Get-ChildItem -Path . -Recurse -Filter changelog.md
foreach ($changelog in $changelogs)
{
(Get-Content -Path $changelog.FullName) -replace "Unreleased", "Unreleased
## 1.0.0-rc2
## 1.0.0-rc2
Released $(Get-Date -UFormat '%Y-%b-%d')" | Set-Content -Path $changelog.FullName
}
```
Released $(Get-Date -UFormat '%Y-%b-%d')" | Set-Content -Path $changelog.FullName
}
```

4.Submit PR with the above changes, and get it merged.
4. Submit PR with the above changes, and get it merged.

5.Tag Git with version to be released e.g.:
5. Tag Git with version to be released e.g.:

```sh
git tag -a 1.0.0-rc2 -m "1.0.0-rc2"
git push origin 1.0.0-rc2
```
```sh
git tag -a 1.0.0-rc2 -m "1.0.0-rc2"
git push origin 1.0.0-rc2
```

We use [MinVer](https:/adamralph/minver) to do versioning,
which produces version numbers based on git tags.
We use [MinVer](https:/adamralph/minver) to do versioning,
which produces version numbers based on git tags.

Note:
If releasing only core components, prefix the tag
with "core-". For example:
git tag -a core-1.1.0-beta1 -m "1.1.0-beta1 of all core components"
Note:
If releasing only core components, prefix the tag
with "core-". For example:
git tag -a core-1.1.0-beta1 -m "1.1.0-beta1 of all core components"

If releasing only non-core components, use tags without
prefix. For example:
git tag -a 1.0.0-rc3 -m "1.0.0-rc3 of all non-core components"
If releasing only non-core components, use tags without
prefix. For example:
git tag -a 1.0.0-rc3 -m "1.0.0-rc3 of all non-core components"

If releasing both, push both tags above.
If releasing both, push both tags above.

6.Open [Pack and publish to MyGet
workflow](https:/open-telemetry/opentelemetry-dotnet/actions/workflows/publish-packages-1.0.yml)
and manually trigger a build. At the end of this, MyGet will have the
packages. The package name will be the tag name used in step 5.
6. Open [Pack and publish to MyGet
workflow](https:/open-telemetry/opentelemetry-dotnet/actions/workflows/publish-packages-1.0.yml)
and manually trigger a build. At the end of this, MyGet will have the
packages. The package name will be the tag name used in step 5.

7.Validate using MyGet packages. Basic sanity checks :)
7. Validate using MyGet packages. Basic sanity checks :)

8.From the above build, get the artifacts from the drop, which has all the
NuGet packages.
8. From the above build, get the artifacts from the drop, which has all the
NuGet packages.

9.Copy all the NuGet files and symbols into a local folder. If only
releasing core packages, only copy them over.
9. Copy all the NuGet files and symbols into a local folder. If only
releasing core packages, only copy them over.

10.Download latest [nuget.exe](https://www.nuget.org/downloads) into
the same folder from step 9.
10. Download latest [nuget.exe](https://www.nuget.org/downloads) into
the same folder from step 9.

11.Obtain the API key from nuget.org (Only maintainers have access)
11. Obtain the API key from nuget.org (Only maintainers have access)

12.Run the following commands from PowerShell from local folder used in step 9:
12. Run the following commands from PowerShell from local folder used in step 9:

```powershell
.\nuget.exe setApiKey <actual api key>
```powershell
.\nuget.exe setApiKey <actual api key>
get-childitem -Recurse | where {$_.extension -eq
".nupkg"} | foreach ($_) {.\nuget.exe push $_.fullname -Source
https://api.nuget.org/v3/index.json}
```
get-childitem -Recurse | where {$_.extension -eq
".nupkg"} | foreach ($_) {.\nuget.exe push $_.fullname -Source
https://api.nuget.org/v3/index.json}
```

13.Packages would be available in nuget.org in few minutes.
Validate that the package is uploaded.
13. Packages would be available in nuget.org in few minutes.
Validate that the package is uploaded.

14.Delete the API key generated in step 11.
14. Delete the API key generated in step 11.

15.Make the Github release with tag from Step5
and contents of combinedchangelog from Step2.
15. Make the Github release with tag from Step5
and contents of combinedchangelog from Step2.

TODO: Add tagging for Metrics release.
TODO: Separate version for instrumention/hosting/OTshim package.
TODO: Add tagging for Metrics release.
TODO: Separate version for instrumention/hosting/OTshim package.

16.Update the OpenTelemetry.io document
[here](https:/open-telemetry/opentelemetry.io/tree/main/content/en/docs/net)
by sending a Pull Request.
16. Update the OpenTelemetry.io document
[here](https:/open-telemetry/opentelemetry.io/tree/main/content/en/docs/net)
by sending a Pull Request.

17.If a new stable version of the core packages were released,
update `OTelPreviousStableVer` in Common.props
to the just released stable version.
17. If a new stable version of the core packages were released,
update `OTelPreviousStableVer` in Common.props
to the just released stable version.
4 changes: 4 additions & 0 deletions docs/metrics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Getting Started with OpenTelemetry .NET Metrics in 5 Minutes

* [Getting started with Counter](.\getting-started\README.md)
* [Getting started with Histogram](.\getting-started-histogram\README.md)
55 changes: 55 additions & 0 deletions docs/metrics/getting-started-histogram/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// <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.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Threading;
using System.Threading.Tasks;
using OpenTelemetry;
using OpenTelemetry.Metrics;

public class Program
{
private static readonly Meter MyMeter = new Meter("TestMeter", "0.0.1");
private static readonly Histogram<long> MyHistogram = MyMeter.CreateHistogram<long>("histogram");
private static readonly Random RandomGenerator = new Random();

public static async Task Main(string[] args)
{
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddSource("TestMeter")
.AddConsoleExporter()
.Build();

using var token = new CancellationTokenSource();
Task writeMetricTask = new Task(() =>
{
while (!token.IsCancellationRequested)
{
MyHistogram.Record(
RandomGenerator.Next(1, 1000),
new KeyValuePair<string, object>("tag1", "value1"),
new KeyValuePair<string, object>("tag2", "value2"));
Task.Delay(10).Wait();
}
});
writeMetricTask.Start();

token.CancelAfter(10000);
await writeMetricTask;
}
}
Loading

0 comments on commit f12ae02

Please sign in to comment.