Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
discostu105 committed Jun 14, 2019
2 parents 996ec40 + aec6feb commit 7e6e91f
Show file tree
Hide file tree
Showing 240 changed files with 1,733 additions and 2,806 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/test/OpenTelemetry.Collector.Dependencies.Tests/bin/Debug/netcoreapp2.0/OpenTelemetry.Collector.Dependencies.Tests.dll",
"program": "${workspaceFolder}/test/OpenTelemetry.Collector.Dependencies.Tests/bin/Debug/netcoreapp2.1/OpenTelemetry.Collector.Dependencies.Tests.dll",
"args": [],
"cwd": "${workspaceFolder}/test/OpenTelemetry.Collector.Dependencies.Tests",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ process content of "Unreleased" section content will generate release notes for
the release.

## Unreleased
- Modified Prometheus Exporter to add listening on all hostnames support.
1. Modified the content of PrometheusExporterOptions from `Uri()` to `string`.
2. `HttpListener()` can support "+" as: hostname which listens on all ports.
3. Modified samples/TestPrometheus.cs to safely use the new implementation.

- Copy from
[OpenCensus](http://github.com/census-instrumentation/opencensus-csharp) at
Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ To test from command line you need `dotnet` version `2.0+`.
dotnet test OpenTelemetry.sln
```

To see test coverage, run `dotnet test` from a console window and you will see the following output:

![image](https://user-images.githubusercontent.com/20248180/59361025-1e1e7980-8d29-11e9-8449-548caf0d7823.png)

Or, after running the tests, open the file `TestResults\Results\index.htm` in a browser.

### Proposing changes

Create a Pull Request with your changes. Please add any user-visible changes to
Expand Down
6 changes: 6 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://github.com/open-telemetry/opentelemetry-dotnet</PackageProjectUrl>
</PropertyGroup>
</Project>
7 changes: 7 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
15 changes: 9 additions & 6 deletions OpenTelemetry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Appl
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Stackdriver", "src\OpenTelemetry.Exporter.Stackdriver\OpenTelemetry.Exporter.Stackdriver.csproj", "{DE1B4783-C01F-4672-A6EB-695F1717105B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples", "src\Samples\Samples.csproj", "{C58393EB-32E2-4AC6-9170-697B36306E15}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Abstractions", "src\OpenTelemetry.Abstractions\OpenTelemetry.Abstractions.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}"
Expand All @@ -67,6 +65,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Collector.Sta
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Collector.StackExchangeRedis.Tests", "test\OpenTelemetry.Collector.StackExchangeRedis.Tests\OpenTelemetry.Collector.StackExchangeRedis.Tests.csproj", "{CA98AF29-0852-4ADD-A66B-7E96266EE7B7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{E359BB2B-9AEC-497D-B321-7DF2450C3B8E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Exporters", "samples\Exporters\Exporters.csproj", "{6EC9DEC9-086F-4F29-BF3F-5FC7253829D5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -93,10 +95,6 @@ Global
{DE1B4783-C01F-4672-A6EB-695F1717105B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE1B4783-C01F-4672-A6EB-695F1717105B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE1B4783-C01F-4672-A6EB-695F1717105B}.Release|Any CPU.Build.0 = Release|Any CPU
{C58393EB-32E2-4AC6-9170-697B36306E15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C58393EB-32E2-4AC6-9170-697B36306E15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C58393EB-32E2-4AC6-9170-697B36306E15}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C58393EB-32E2-4AC6-9170-697B36306E15}.Release|Any CPU.Build.0 = Release|Any CPU
{99F8A331-05E9-45A5-89BA-4C54E825E5B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
Expand Down Expand Up @@ -145,13 +143,18 @@ Global
{CA98AF29-0852-4ADD-A66B-7E96266EE7B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CA98AF29-0852-4ADD-A66B-7E96266EE7B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CA98AF29-0852-4ADD-A66B-7E96266EE7B7}.Release|Any CPU.Build.0 = Release|Any CPU
{6EC9DEC9-086F-4F29-BF3F-5FC7253829D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6EC9DEC9-086F-4F29-BF3F-5FC7253829D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6EC9DEC9-086F-4F29-BF3F-5FC7253829D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6EC9DEC9-086F-4F29-BF3F-5FC7253829D5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{7CB2F02E-03FA-4FFF-89A5-C51F107623FD} = {61188153-47FB-4567-AC9B-79B2435853EB}
{F2F81E76-6A0E-466B-B673-EBBF1A9ED075} = {77C7929A-2EED-4AA6-8705-B5C443C8AA0F}
{6EC9DEC9-086F-4F29-BF3F-5FC7253829D5} = {E359BB2B-9AEC-497D-B321-7DF2450C3B8E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {55639B5C-0770-4A22-AB56-859604650521}
Expand Down
24 changes: 15 additions & 9 deletions build/Common.prod.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,23 @@
</ItemGroup>

<PropertyGroup>
<!-- Optional: Declare that the Repository URL can be published to NuSpec -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<PackageTags>Tracing;OpenTelemetry;Management;Monitoring</PackageTags>
<PackageIconUrl>https://opentelemetry.io/img/logos/opentelemetry-icon-color.png</PackageIconUrl>
<PackageProjectUrl>https://OpenTelemetry.io</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Authors>OpenTelemetry authors</Authors>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
</PropertyGroup>

<!-- Optional: Embed source files that are not tracked by the source control manager to the PDB -->
<!-- This is useful if you generate files during the build -->
<PropertyGroup Label="SourceLink">
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<ItemGroup>
<!-- Required -->
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-*" PrivateAssets="All"/>
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
</Project>
29 changes: 29 additions & 0 deletions build/Common.test.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<DelaySign>false</DelaySign>
<DefineConstants>$(DefineConstants);SIGNED</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenTelemetry.sln'))\build\OpenTelemetry.test.ruleset</CodeAnalysisRuleSet>
Expand All @@ -15,4 +20,28 @@
<AdditionalFiles Include="$(MSBuildThisFileDirectory)/stylecop.json" />
</ItemGroup>

<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>

<PropertyGroup Condition="$(MSBuildProjectName.EndsWith('.Tests'))">
<IsTestProject>true</IsTestProject>
<CollectCoverage Condition="$(CollectCoverage) == ''">true</CollectCoverage>
</PropertyGroup>

<PropertyGroup>
<CollectCoverage Condition="$(CollectCoverage) == '' OR !$(TargetFramework.StartsWith('netcoreapp'))">false</CollectCoverage>
</PropertyGroup>

<PropertyGroup Label="CollectCodeCoverageResults" Condition="$(CollectCoverage)">
<CoverletOutputFormat>cobertura</CoverletOutputFormat>
<_BaseDir>..\..\TestResults\</_BaseDir>
<CoverletBaseDir>$(_BaseDir)Coverage\</CoverletBaseDir>
<CoverletResultsDir>$(_BaseDir)Results\</CoverletResultsDir>
<CoverletBaseDir Condition="$([MSBuild]::IsOSUnixLike())">$(CoverletBaseDir.Replace('\', '/'))</CoverletBaseDir>
<CoverletResultsDir Condition="$([MSBuild]::IsOSUnixLike())">$(CoverletResultsDir.Replace('\', '/'))</CoverletResultsDir>
<CoverletOutput>$(CoverletBaseDir)$(MSBuildProjectName).xml</CoverletOutput>
<Exclude>[xunit*]*,[*.Tests]*</Exclude>
<DebugType>pdbonly</DebugType> <!-- Coverlet needs full debug symbols -->
</PropertyGroup>
</Project>
24 changes: 24 additions & 0 deletions samples/Exporters/Exporters.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenTelemetry.sln'))\build\Version.props" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.3.0" />
<PackageReference Include="StackExchange.Redis" Version="2.0.519" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\OpenTelemetry.Collector.Dependencies\OpenTelemetry.Collector.Dependencies.csproj" />
<ProjectReference Include="..\..\src\OpenTelemetry.Collector.StackExchangeRedis\OpenTelemetry.Collector.StackExchangeRedis.csproj" />
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.Stackdriver\OpenTelemetry.Exporter.Stackdriver.csproj" />
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj" />
<ProjectReference Include="..\..\src\OpenTelemetry\OpenTelemetry.csproj" />
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.Zipkin\OpenTelemetry.Exporter.Zipkin.csproj" />
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.ApplicationInsights\OpenTelemetry.Exporter.ApplicationInsights.csproj" />
</ItemGroup>

</Project>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class TestApplicationInsights

private static IStatsRecorder statsRecorder = Stats.StatsRecorder;
private static readonly IMeasureLong VideoSize = MeasureLong.Create("my.org/measure/video_size", "size of processed videos", "By");
private static readonly ITagKey FrontendKey = TagKey.Create("my.org/keys/frontend");
private static readonly TagKey FrontendKey = TagKey.Create("my.org/keys/frontend");

private static long MiB = 1 << 20;

Expand All @@ -30,7 +30,7 @@ internal class TestApplicationInsights
"processed video size over time",
VideoSize,
Distribution.Create(BucketBoundaries.Create(new List<double>() { 0.0, 16.0 * MiB, 256.0 * MiB })),
new List<ITagKey>() { FrontendKey });
new List<TagKey>() { FrontendKey });

internal static object Run()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using OpenTelemetry.Collector.Dependencies;
using OpenTelemetry.Exporter.Zipkin;
using OpenTelemetry.Trace;
using OpenTelemetry.Trace.Propagation;
using OpenTelemetry.Context.Propagation;
using OpenTelemetry.Trace.Sampler;

internal class TestHttpClient
Expand All @@ -16,7 +16,7 @@ internal static object Run()
{
Console.WriteLine("Hello World!");

var collector = new DependenciesCollector(new DependenciesCollectorOptions(), tracer, Samplers.AlwaysSample, PropagationComponentBase.NoopPropagationComponent);
var collector = new DependenciesCollector(new DependenciesCollectorOptions(), tracer, Samplers.AlwaysSample);

var exporter = new ZipkinTraceExporter(
new ZipkinTraceExporterOptions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class TestPrometheus

private static IStatsRecorder statsRecorder = Stats.StatsRecorder;
private static readonly IMeasureLong VideoSize = MeasureLong.Create("my.org/measure/video_size", "size of processed videos", "By");
private static readonly ITagKey FrontendKey = TagKey.Create("my.org/keys/frontend");
private static readonly TagKey FrontendKey = TagKey.Create("my.org/keys/frontend");

private static long MiB = 1 << 20;

Expand All @@ -29,14 +29,14 @@ internal class TestPrometheus
"processed video size over time",
VideoSize,
Distribution.Create(BucketBoundaries.Create(new List<double>() { 0.0, 16.0 * MiB, 256.0 * MiB })),
new List<ITagKey>() { FrontendKey });
new List<TagKey>() { FrontendKey });

internal static object Run()
{
var exporter = new PrometheusExporter(
new PrometheusExporterOptions()
{
Url = new Uri("http://localhost:9184/metrics/")
Url = "http://localhost:9184/metrics/"
},
Stats.ViewManager);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static void DoWork(IDatabase db, int i)
// 7. Start another span. If another span was already started, it'll use that span as the parent span.
// In this example, the main method already started a span, so that'll be the parent span, and this will be
// a child span.
using (OpenTelemetry.Common.IScope scope = tracer.SpanBuilder("DoWork").StartScopedSpan())
using (OpenTelemetry.Context.IScope scope = tracer.SpanBuilder("DoWork").StartScopedSpan())
{
// Simulate some work.
ISpan span = tracer.CurrentSpan;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class TestStackdriver

private static IStatsRecorder statsRecorder = Stats.StatsRecorder;
private static readonly IMeasureDouble VideoSize = MeasureDouble.Create("my_org/measure/video_size", "size of processed videos", "MiB");
private static readonly ITagKey FrontendKey = TagKey.Create("my_org/keys/frontend");
private static readonly TagKey FrontendKey = TagKey.Create("my_org/keys/frontend");

private static long MiB = 1 << 20;

Expand All @@ -29,7 +29,7 @@ internal class TestStackdriver
description: "processed video size over time",
measure: VideoSize,
aggregation: Sum.Create(),
columns: new List<ITagKey>() { FrontendKey });
columns: new List<TagKey>() { FrontendKey });

internal static object Run(string projectId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static void DoWork(int i)
// 7. Start another span. If another span was already started, it'll use that span as the parent span.
// In this example, the main method already started a span, so that'll be the parent span, and this will be
// a child span.
using (OpenTelemetry.Common.IScope scope = tracer.SpanBuilder("DoWork").StartScopedSpan())
using (OpenTelemetry.Context.IScope scope = tracer.SpanBuilder("DoWork").StartScopedSpan())
{
// Simulate some work.
ISpan span = tracer.CurrentSpan;
Expand Down
4 changes: 4 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Project>
<Import Project="..\Directory.Build.props" Condition="Exists('..\Directory.Build.props')" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenTelemetry.sln'))\build\Common.prod.props" />
</Project>
10 changes: 10 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<Import Project="..\Directory.Build.targets" Condition="Exists('..\Directory.Build.targets')" />

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
9 changes: 5 additions & 4 deletions src/OpenTelemetry.Abstractions/Common/Duration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,24 @@
namespace OpenTelemetry.Common
{
using System;
using System.Diagnostics;

/// <summary>
/// Represents duration with the nanoseconds precition.
/// </summary>
[DebuggerDisplay("{ToString(),nq}")]
public sealed class Duration : IComparable<Duration>
{
private const long MaxSeconds = 315576000000L;
private const int MaxNanos = 999999999;
private static readonly Duration Zero = new Duration(0, 0);
private readonly string stringRepresentation;

private Duration(long seconds, int nanos)
{
this.Seconds = seconds;
this.Nanos = nanos;
this.stringRepresentation = $"Duration{{seconds={this.Seconds}, nanos={this.Nanos}}}";
}

/// <summary>
Expand Down Expand Up @@ -100,10 +104,7 @@ public int CompareTo(Duration other)
/// <inheritdoc/>
public override string ToString()
{
return "Duration{"
+ "seconds=" + this.Seconds + ", "
+ "nanos=" + this.Nanos
+ "}";
return this.stringRepresentation;
}

/// <inheritdoc/>
Expand Down
Loading

0 comments on commit 7e6e91f

Please sign in to comment.