Skip to content

Commit

Permalink
Merge branch 'main' into ecs_detector
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Mancioppi authored Jan 9, 2023
2 parents 3a47560 + 70f9f0f commit d4334f4
Show file tree
Hide file tree
Showing 55 changed files with 459 additions and 253 deletions.
2 changes: 1 addition & 1 deletion .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ components:
test/OpenTelemetry.Extensions.Tests/:
- codeblanch
test/OpenTelemetry.Extensions.Docker.Tests/:
- swetharavichandrancisco
- iskiselev
test/OpenTelemetry.Extensions.PersistentStorage.Tests/:
- vishweshbankwar
test/OpenTelemetry.Instrumentation.AWSLambda.Tests/:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/dotnet-core-cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest]
env:
OS: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # fetching all

- uses: actions/[email protected]
- name: Setup .NET 7.0
uses: actions/[email protected]
with:
dotnet-version: '7.0.x'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v6
- uses: actions/stale@v7
with:
stale-pr-message: 'This PR was marked stale due to lack of activity. It will be closed in 7 days.'
close-pr-message: 'Closed as inactive. Feel free to reopen if this PR is still being worked on.'
Expand Down
6 changes: 3 additions & 3 deletions build/Common.nonprod.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
Please sort alphabetically.
Refer to https://docs.microsoft.com/en-us/nuget/concepts/package-versioning for semver syntax.
-->
<BenchmarkDotNetPkgVer>[0.13.2,0.14)</BenchmarkDotNetPkgVer>
<CoverletCollectorPkgVer>[3.1.2,4.0.0)</CoverletCollectorPkgVer>
<BenchmarkDotNetPkgVer>[0.13.3,0.14)</BenchmarkDotNetPkgVer>
<CoverletCollectorPkgVer>[3.2.0,4.0.0)</CoverletCollectorPkgVer>
<DotNetXUnitCliVer>[2.3.1,3.0)</DotNetXUnitCliVer>
<MicrosoftExtensionsLoggingPkgVer>[5.0.0,7.0)</MicrosoftExtensionsLoggingPkgVer>
<MicrosoftNETTestSdkPkgVer>[16.11.0,17.0)</MicrosoftNETTestSdkPkgVer>
<MicrosoftNETTestSdkPkgVer>[17.3.2,18.0)</MicrosoftNETTestSdkPkgVer>
<MoqPkgVer>[4.18.3,5.0)</MoqPkgVer>
<MoqNet45PkgVer>[4.17.2,5.0)</MoqNet45PkgVer>
<OpenTelemetryExporterInMemoryPkgVer>$(OpenTelemetryCoreLatestVersion)</OpenTelemetryExporterInMemoryPkgVer>
Expand Down
8 changes: 6 additions & 2 deletions build/process-codecoverage.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
$files = Get-ChildItem "TestResults" -Filter "*.coverage" -Recurse
[xml]$commonProps = Get-Content -Path $PSScriptRoot\Common.props
$microsoftCodeCoveragePkgVer = [string]$commonProps.Project.PropertyGroup.MicrosoftCodeCoveragePkgVer # This is collected in the format: "[16.10.0]"
$microsoftCodeCoveragePkgVer = $microsoftCodeCoveragePkgVer.Trim();
$microsoftCodeCoveragePkgVer = $microsoftCodeCoveragePkgVer.SubString(1, $microsoftCodeCoveragePkgVer.Length - 2) # Removing square brackets
$files = Get-ChildItem "TestResults" -Filter "*.coverage" -Recurse
Write-Host $env:USERPROFILE
foreach ($file in $files)
{
$command = $env:USERPROFILE+ '\.nuget\packages\microsoft.codecoverage\16.11.0\build\netstandard1.0\CodeCoverage\CodeCoverage.exe analyze /output:' + $file.DirectoryName + '\' + $file.Name + '.xml '+ $file.FullName
$command = $env:USERPROFILE+ '\.nuget\packages\microsoft.codecoverage\' + $microsoftCodeCoveragePkgVer + '\build\netstandard1.0\CodeCoverage\CodeCoverage.exe analyze /output:' + $file.DirectoryName + '\' + $file.Name + '.xml '+ $file.FullName
Write-Host $command
Invoke-Expression $command
}
6 changes: 3 additions & 3 deletions examples/AspNet/Examples.AspNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.WebHost" Version="[5.2.7,6.0)" />
<PackageReference Include="Microsoft.AspNet.Mvc" Version="[5.2.7,6.0)" />
<PackageReference Include="Microsoft.AspNet.WebPages" Version="[3.2.7,4.0)" />
<PackageReference Include="Microsoft.AspNet.WebApi.WebHost" Version="[5.2.9,6.0)" />
<PackageReference Include="Microsoft.AspNet.Mvc" Version="[5.2.9,6.0)" />
<PackageReference Include="Microsoft.AspNet.WebPages" Version="[3.2.9,4.0)" />
<PackageReference Include="OpenTelemetry" Version="$(OpenTelemetryCoreLatestVersion)" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9.4" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="$(OpenTelemetryCoreLatestVersion)" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.0.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc2" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc2" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="$(OpenTelemetryCoreLatestVersion)" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9.4" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.4" />

<PackageReference Include="Grpc.Tools" Version="1.17.0" />
<PackageReference Include="Grpc" Version="[2.32.0,3.0)" />
Expand Down
4 changes: 2 additions & 2 deletions examples/owin/Examples.Owin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" Version="5.2.7" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" Version="5.2.9" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="$(OpenTelemetryCoreLatestVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions examples/wcf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

Project structure:

* Examples.Wcf.Client.Core
* Examples.Wcf.Client.DotNet

An example of how to call a WCF service with OpenTelemetry instrumentation on
.NET Core.
.NET.

* Examples.Wcf.Client.NetFramework

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.ServiceModel.Http" Version="4.7.0" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.9" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.1" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="$(OpenTelemetryCoreLatestVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net462</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.0.1" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="$(OpenTelemetryCoreLatestVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net462</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.0.1" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="$(OpenTelemetryCoreLatestVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions opentelemetry-dotnet-contrib.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{1A06E14B-DD2F-4536-9D2E-F708C0C43555}"
ProjectSection(SolutionItems) = preProject
.github\codecov.yml = .github\codecov.yml
CODEOWNERS = CODEOWNERS
.github\component_owners.yml = .github\component_owners.yml
EndProjectSection
Expand Down Expand Up @@ -106,7 +105,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wcf", "wcf", "{73474960-8F9
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Wcf.Shared", "examples\wcf\shared\Examples.Wcf.Shared.csproj", "{21716C26-3B2A-4208-BDFB-8E58E2AF49EA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Wcf.Client.Core", "examples\wcf\client-core\Examples.Wcf.Client.Core.csproj", "{3AF5D7E4-CA7D-401B-9729-A6D8F63B023C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Wcf.Client.DotNet", "examples\wcf\client-core\Examples.Wcf.Client.DotNet.csproj", "{3AF5D7E4-CA7D-401B-9729-A6D8F63B023C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Wcf.Client.NetFramework", "examples\wcf\client-netframework\Examples.Wcf.Client.NetFramework.csproj", "{2A7867E5-0FD6-42F8-B594-19E897EDA54C}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class GenevaMetricExporter : BaseExporter<Metric>

internal const int MaxDimensionValueSize = 1024;

private static readonly MetricData ulongZero = new MetricData { UInt64Value = 0 };

private readonly ushort prepopulatedDimensionsCount;

private readonly int fixedPayloadStartIndex;
Expand All @@ -55,8 +57,6 @@ public class GenevaMetricExporter : BaseExporter<Metric>

private readonly int bufferIndexForHistogramMetrics;

private static readonly MetricData ulongZero = new MetricData { UInt64Value = 0 };

private bool isDisposed;

public GenevaMetricExporter(GenevaMetricExporterOptions options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading;

Expand Down Expand Up @@ -286,7 +287,7 @@ internal int SerializeActivity(Activity activity)
}
else if (string.Equals(entry.Key, "otel.status_code", StringComparison.Ordinal))
{
if (string.Equals(entry.Value.ToString(), "ERROR", StringComparison.Ordinal))
if (string.Equals(Convert.ToString(entry.Value, CultureInfo.InvariantCulture), "ERROR", StringComparison.Ordinal))
{
isStatusSuccess = false;
}
Expand All @@ -295,7 +296,7 @@ internal int SerializeActivity(Activity activity)
}
else if (string.Equals(entry.Key, "otel.status_description", StringComparison.Ordinal))
{
statusDescription = entry.Value.ToString();
statusDescription = Convert.ToString(entry.Value, CultureInfo.InvariantCulture);
continue;
}
else if (this.m_customFields == null || this.m_customFields.ContainsKey(entry.Key))
Expand Down Expand Up @@ -400,6 +401,23 @@ public void Dispose()

private const int BUFFER_SIZE = 65360; // the maximum ETW payload (inclusive)

private static readonly string INVALID_SPAN_ID = default(ActivitySpanId).ToHexString();

private static readonly IReadOnlyDictionary<string, string> CS40_PART_B_MAPPING = new Dictionary<string, string>
{
["db.system"] = "dbSystem",
["db.name"] = "dbName",
["db.statement"] = "dbStatement",

["http.method"] = "httpMethod",
["http.url"] = "httpUrl",
["http.status_code"] = "httpStatusCode",

["messaging.system"] = "messagingSystem",
["messaging.destination"] = "messagingDestination",
["messaging.url"] = "messagingUrl",
};

private readonly ThreadLocal<byte[]> m_buffer = new(() => null);

private readonly byte[] m_bufferPrologue;
Expand All @@ -418,22 +436,5 @@ public void Dispose()

private readonly IReadOnlyDictionary<string, object> m_dedicatedFields;

private static readonly string INVALID_SPAN_ID = default(ActivitySpanId).ToHexString();

private static readonly IReadOnlyDictionary<string, string> CS40_PART_B_MAPPING = new Dictionary<string, string>
{
["db.system"] = "dbSystem",
["db.name"] = "dbName",
["db.statement"] = "dbStatement",

["http.method"] = "httpMethod",
["http.url"] = "httpUrl",
["http.status_code"] = "httpStatusCode",

["messaging.system"] = "messagingSystem",
["messaging.destination"] = "messagingDestination",
["messaging.url"] = "messagingUrl",
};

private bool isDisposed;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Description>An OpenTelemetry .NET exporter that exports to local ETW or UDS</Description>
<Authors>OpenTelemetry Authors</Authors>
<NoWarn>$(NoWarn),NU5104,CS1591,SA1123,SA1310,CA1031,CA1810,CA1822,CA2000,CA2208,SA1204,SA1201,SA1202,SA1308,SA1309,SA1311,SA1402,SA1602,SA1649</NoWarn>
<NoWarn>$(NoWarn),CS1591,SA1123,SA1310,CA1810,CA1822,CA2000,CA2208,SA1201,SA1202,SA1308,SA1309,SA1311,SA1402,SA1602,SA1649</NoWarn>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
<MinVerTagPrefix>Exporter.Geneva-</MinVerTagPrefix>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public static Span ToSpan(this Activity activity, string projectId)
{
AttributeMap =
{
activity.Tags?.ToDictionary(
activity.Tags.ToDictionary(
s => s.Key,
s => s.Value?.ToAttributeValue()),
s => s.Value.ToAttributeValue()),
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public override SamplingResult ShouldSample(in SamplingParameters samplingParame
return this.recordAndSampleSamplingResult;
}

double sampleScore = DJB2SampleScore(samplingParameters.TraceId.ToHexString().ToLowerInvariant());
double sampleScore = DJB2SampleScore(samplingParameters.TraceId.ToHexString().ToUpperInvariant());

if (sampleScore < this.samplingRatio)
{
Expand All @@ -90,7 +90,10 @@ private static double DJB2SampleScore(string traceIdHex)

for (int i = 0; i < traceIdHex.Length; i++)
{
hash = ((hash << 5) + hash) + (int)traceIdHex[i];
unchecked
{
hash = (hash << 5) + hash + (int)traceIdHex[i];
}
}

// Take the absolute value of the hash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
<TargetFrameworks Condition="'$(Configuration)' == 'Debug'">$(TargetFrameworks);net6.0</TargetFrameworks> <!-- Added just to get proper nullable analysis in IDE -->
<MinVerTagPrefix>Extensions.AzureMonitor-</MinVerTagPrefix>
<EnableAnalysis>true</EnableAnalysis>
</PropertyGroup>

<ItemGroup>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
Expand All @@ -15,4 +15,8 @@
<EnableAnalysis>true</EnableAnalysis>
</PropertyGroup>

<ItemGroup>
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Internal\NullableAttributes.cs" Link="Includes\NullableAttributes.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
Expand All @@ -14,7 +14,7 @@

<ItemGroup>
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Internal\Guard.cs" Link="Includes\Guard.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Extensions.PersistentStorage.Abstractions\NotNullWhenAttribute.cs" Link="Includes\NotNullWhenAttribute.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Internal\NullableAttributes.cs" Link="Includes\NullableAttributes.cs" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Extensions.PersistentStorage.Abstractions\OpenTelemetry.Extensions.PersistentStorage.Abstractions.csproj" />
</ItemGroup>

Expand Down
Loading

0 comments on commit d4334f4

Please sign in to comment.