Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…etry-dotnet into metrics
  • Loading branch information
victlu committed May 4, 2021
2 parents 71c2dab + 9d415bf commit 6e6ff21
Show file tree
Hide file tree
Showing 216 changed files with 2,108 additions and 7,393 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
*.user
*.userosscache
*.sln.docstates
.vscode/solution-explorer
.vscode/
.devcontainer/

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
21 changes: 8 additions & 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 @@ -207,7 +203,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Shared", "src
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp.AspNetCore.5.0", "test\TestApp.AspNetCore.5.0\TestApp.AspNetCore.5.0.csproj", "{972396A8-E35B-499C-9BA1-765E9B8822E1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "exception-handling", "docs\trace\exception-handling\exception-handling.csproj", "{08D29501-F0A3-468F-B18D-BD1821A72383}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "exception-reporting", "docs\trace\exception-reporting\exception-reporting.csproj", "{08D29501-F0A3-468F-B18D-BD1821A72383}"
EndProject
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 @@ -231,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 @@ -283,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 Expand Up @@ -411,6 +401,10 @@ Global
{08D29501-F0A3-468F-B18D-BD1821A72383}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08D29501-F0A3-468F-B18D-BD1821A72383}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08D29501-F0A3-468F-B18D-BD1821A72383}.Release|Any CPU.Build.0 = Release|Any CPU
{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -442,6 +436,7 @@ Global
{13C10C9A-07E8-43EB-91F5-C2B116FBE0FC} = {3862190B-E2C5-418E-AFDC-DB281FB5C705}
{972396A8-E35B-499C-9BA1-765E9B8822E1} = {77C7929A-2EED-4AA6-8705-B5C443C8AA0F}
{08D29501-F0A3-468F-B18D-BD1821A72383} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {55639B5C-0770-4A22-AB56-859604650521}
Expand Down
9 changes: 8 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 Expand Up @@ -114,6 +113,14 @@ Maintainers
*Find more about the maintainer role in [community
repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer).*

Triager
([@open-telemetry/dotnet-triagers](https://github.com/orgs/open-telemetry/teams/dotnet-triagers)):

* [Victor Lu](https://github.com/victlu), Microsoft

*Find more about the triager role in [community
repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#triager).*

### Thanks to all the people who have contributed

[![contributors](https://contributors-img.web.app/image?repo=open-telemetry/opentelemetry-dotnet)](https://github.com/open-telemetry/opentelemetry-dotnet/graphs/contributors)
Expand Down
2 changes: 1 addition & 1 deletion build/Common.nonprod.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<BenchmarkDotNetPkgVer>[0.12.1,0.13)</BenchmarkDotNetPkgVer>
<CommandLineParserPkgVer>[2.3.0,3.0)</CommandLineParserPkgVer>
<DotNetXUnitCliVer>[2.3.1,3.0)</DotNetXUnitCliVer>
<GoogleProtobufPkgVer>[3.13.0,4.0)</GoogleProtobufPkgVer>
<GoogleProtobufPkgVer>[3.15.5,4.0)</GoogleProtobufPkgVer>
<GrpcAspNetCorePkgVer>[2.27.0,3.0)</GrpcAspNetCorePkgVer>
<GrpcAspNetCoreServerPkgVer>[2.30.0, 3.0)</GrpcAspNetCoreServerPkgVer>
<GrpcToolsPkgVer>[2.25.0,3.0)</GrpcToolsPkgVer>
Expand Down
2 changes: 1 addition & 1 deletion build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Refer to https://docs.microsoft.com/en-us/nuget/concepts/package-versioning for semver syntax.
-->
<MinVerPkgVer>[2.3.0,3.0)</MinVerPkgVer>
<GoogleProtobufPkgVer>[3.6.1,4.0)</GoogleProtobufPkgVer>
<GoogleProtobufPkgVer>[3.15.5,4.0)</GoogleProtobufPkgVer>
<GrpcPkgVer>[2.23.0,3.0)</GrpcPkgVer>
<GrpcNetClientPkgVer>[2.32.0,3.0)</GrpcNetClientPkgVer>
<GrpcToolsPkgVer>[2.25.0,3.0)</GrpcToolsPkgVer>
Expand Down
6 changes: 5 additions & 1 deletion build/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Only for Maintainers.
$ended = $false
foreach ($line in $lines)
{
if($line -like "## *" -and $started -ne $true)
if($line -like "## Unreleased" -and $started -ne $true)
{
$started = $true
}
Expand Down Expand Up @@ -121,3 +121,7 @@ and contents of combinedchangelog from Step2.

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

16.Update the OpenTelemetry.io document
[here](https://github.com/open-telemetry/opentelemetry.io/tree/main/content/en/docs/net)
by sending a Pull Request.
2 changes: 1 addition & 1 deletion docs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- https://dotnet.microsoft.com/download/dotnet-core -->
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
<!-- https://dotnet.microsoft.com/download/dotnet-framework -->
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net461;net462;net47;net471;net472;net48</TargetFrameworks>
</PropertyGroup>
Expand Down
12 changes: 0 additions & 12 deletions docs/logs/extending-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
// </copyright>

using System.Collections.Generic;
#if NETCOREAPP2_1
using Microsoft.Extensions.DependencyInjection;
#endif
using Microsoft.Extensions.Logging;
using OpenTelemetry;
using OpenTelemetry.Logs;
Expand All @@ -26,11 +23,7 @@ public class Program
{
public static void Main()
{
#if NETCOREAPP2_1
var serviceCollection = new ServiceCollection().AddLogging(builder =>
#else
using var loggerFactory = LoggerFactory.Create(builder =>
#endif
builder.AddOpenTelemetry(options =>
{
options.IncludeScopes = true;
Expand All @@ -40,12 +33,7 @@ public static void Main()
.AddMyExporter();
}));

#if NETCOREAPP2_1
using var serviceProvider = serviceCollection.BuildServiceProvider();
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();
#else
var logger = loggerFactory.CreateLogger<Program>();
#endif

// unstructured log
logger.LogInformation("Hello, World!");
Expand Down
7 changes: 1 addition & 6 deletions docs/logs/extending-the-sdk/extending-the-sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp2.1'">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPkgVer)" />
</ItemGroup>
</Project>
13 changes: 0 additions & 13 deletions docs/logs/getting-started/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,20 @@
// limitations under the License.
// </copyright>

#if NETCOREAPP2_1
using Microsoft.Extensions.DependencyInjection;
#endif
using Microsoft.Extensions.Logging;
using OpenTelemetry.Logs;

public class Program
{
public static void Main()
{
#if NETCOREAPP2_1
var serviceCollection = new ServiceCollection().AddLogging(builder =>
#else
using var loggerFactory = LoggerFactory.Create(builder =>
#endif
{
builder.AddOpenTelemetry(options => options
.AddConsoleExporter());
});

#if NETCOREAPP2_1
using var serviceProvider = serviceCollection.BuildServiceProvider();
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();
#else
var logger = loggerFactory.CreateLogger<Program>();
#endif

logger.LogInformation("Hello from {name} {price}.", "tomato", 2.99);
}
}
23 changes: 7 additions & 16 deletions docs/logs/getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,15 @@ You should see the following output:
Hello World!
```

Let's install the packages to get started with logging. If your ConsoleApp
targets `netcoreapp2.1` install the version `2.1.1` of
`Microsoft.Extensions.Logging` and `Microsoft.Extensions.DependencyInjection`
packages:

```sh
dotnet add package Microsoft.Extensions.Logging -v 2.1.1
```

```sh
dotnet add package Microsoft.Extensions.DependencyInjection -v 2.1.1
```

If your ConsoleApp targets a framework other than `netcoreapp2.1`, install the
latest Microsoft.Extensions.Logging package:
Install the latest `Microsoft.Extensions.Logging` package:

```sh
dotnet add package Microsoft.Extensions.Logging
```

Install the
[OpenTelemetry.Exporter.Console](../../../src/OpenTelemetry.Exporter.Console/README.md)
package (Use the latest version):
package:

```sh
dotnet add package OpenTelemetry.Exporter.Console
Expand Down Expand Up @@ -72,3 +58,8 @@ API to log a formatted string with a severity level of Information. Click
for more information on the different logs levels. Opentelemetry captures this
and sends it to `ConsoleExporter`. `ConsoleExporter` simply displays it on the
console.

## Learn more

* If you want to build a custom exporter/processor/sampler, refer to [extending
the SDK](../extending-the-sdk/README.md).
7 changes: 1 addition & 6 deletions docs/logs/getting-started/getting-started.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp2.1'">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPkgVer)" />
</ItemGroup>
</Project>
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.
78 changes: 78 additions & 0 deletions docs/trace/customizing-the-sdk/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// <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.Diagnostics;
using OpenTelemetry;
using OpenTelemetry.Trace;

public class Program
{
private static readonly ActivitySource MyLibraryActivitySource = new ActivitySource(
"MyCompany.MyProduct.MyLibrary");

private static readonly ActivitySource ComponentAActivitySource = new ActivitySource(
"AbcCompany.XyzProduct.ComponentA");

private static readonly ActivitySource ComponentBActivitySource = new ActivitySource(
"AbcCompany.XyzProduct.ComponentB");

private static readonly ActivitySource SomeOtherActivitySource = new ActivitySource(
"SomeCompany.SomeProduct.SomeComponent");

public static void Main()
{
using var tracerProvider = Sdk.CreateTracerProviderBuilder()

// The following adds subscription to activities from Activity Source
// named "MyCompany.MyProduct.MyLibrary" only.
.AddSource("MyCompany.MyProduct.MyLibrary")

// The following adds subscription to activities from all Activity Sources
// whose name starts with "AbcCompany.XyzProduct.".
.AddSource("AbcCompany.XyzProduct.*")
.AddConsoleExporter()
.Build();

// This activity source is enabled.
using (var activity = MyLibraryActivitySource.StartActivity("SayHello"))
{
activity?.SetTag("foo", 1);
activity?.SetTag("bar", "Hello, World!");
}

// This activity source is enabled through wild card "AbcCompany.XyzProduct.*"
using (var activity = ComponentAActivitySource.StartActivity("SayHello"))
{
activity?.SetTag("foo", 1);
activity?.SetTag("bar", "Hello, World!");
}

// This activity source is enabled through wild card "AbcCompany.XyzProduct.*"
using (var activity = ComponentBActivitySource.StartActivity("SayHello"))
{
activity?.SetTag("foo", 1);
activity?.SetTag("bar", "Hello, World!");
}

// This activity source is not enabled, so activity will
// be null here.
using (var activity = SomeOtherActivitySource.StartActivity("SayHello"))
{
activity?.SetTag("foo", 1);
activity?.SetTag("bar", "Hello, World!");
}
}
}
Loading

0 comments on commit 6e6ff21

Please sign in to comment.