Skip to content

Commit

Permalink
Merge from main.
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch committed Sep 30, 2024
2 parents 54f7d4f + 1bdbf96 commit 2e6a855
Show file tree
Hide file tree
Showing 24 changed files with 171 additions and 86 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Bug report
title: "[bug] "
description: Create a report to help us improve
labels: ["bug"]
body:
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Feature request
title: "[feature request] "
description: Suggest an idea for this project
labels: ["enhancement"]
body:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/add-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
AddLabelsOnIssuesForComponentFoundInBody `
-issueNumber ${{ github.event.issue.number }} `
-issueLabels '${{ join(github.event.issue.labels.*.name, ', ') }}' `
-issueBody $env:ISSUE_BODY
env:
GH_TOKEN: ${{ github.token }}
Expand Down
34 changes: 33 additions & 1 deletion build/scripts/add-labels.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Import-Module $PSScriptRoot\build.psm1

function AddLabelsOnIssuesForComponentFoundInBody {
param(
[Parameter(Mandatory=$true)][int]$issueNumber,
[Parameter(Mandatory=$true)][string]$issueLabels,
[Parameter(Mandatory=$true)][string]$issueBody
)

Expand All @@ -10,7 +13,36 @@ function AddLabelsOnIssuesForComponentFoundInBody {
Return
}

gh issue edit $issueNumber --add-label $("comp:" + $match.Groups[1].Value.ToLower())
$component = $match.Groups[1].Value.Trim()

gh issue edit $issueNumber --add-label $("comp:" + $component.ToLower())

if ($issueLabels.Contains('bug') -or $issueLabels.Contains('enhancement'))
{
$componentOwners = $null

FindComponentOwners `
-component "OpenTelemetry.$component" `
-componentOwners ([ref]$componentOwners)

if ($componentOwners.Count -gt 0)
{
$componentOwnerApprovers = ''
foreach ($componentOwner in $componentOwners)
{
$componentOwnerApprovers += "@$componentOwner "
}

$body =
@"
Tagging component owner(s).
$componentOwnerApprovers
"@

gh issue comment $issueNumber --body $body
}
}
}

Export-ModuleMember -Function AddLabelsOnIssuesForComponentFoundInBody
Expand Down
59 changes: 59 additions & 0 deletions build/scripts/build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,62 @@ function ResolveProject {
}

Export-ModuleMember -Function ResolveProject

function FindComponentOwners {
param(
[Parameter(Mandatory=$true)][string]$component,
[Parameter()][string]$issueNumber,
[Parameter()][ref]$componentOwners
)

$projectPath = "src/$component/$component.csproj"

if ((Test-Path -Path $projectPath) -eq $false)
{
if ([string]::IsNullOrEmpty($issueNumber) -eq $false)
{
gh issue comment $issueNumber `
--body "I couldn't find the project file for the requested component. Please create a new release request and select a valid component or edit the description and set a valid component."
}
Return
}

$projectContent = Get-Content -Path $projectPath

$match = [regex]::Match($projectContent, '<MinVerTagPrefix>(.*)<\/MinVerTagPrefix>')
if ($match.Success -eq $false)
{
if ([string]::IsNullOrEmpty($issueNumber) -eq $false)
{
gh issue comment $issueNumber `
--body "I couldn't find ``MinVerTagPrefix`` in the project file for the requested component. Please create a new release request and select a valid component or edit the description and set a valid component."
}
Return
}

$minVerTagPrefix = $match.Groups[1].Value

$projectDirs = Get-ChildItem -Path src/**/*.csproj | Select-String "<MinVerTagPrefix>$minVerTagPrefix</MinVerTagPrefix>" -List | Select Path | Split-Path -Parent

$componentOwnersContent = Get-Content '.github/component_owners.yml' -Raw

$componentOwners.Value = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase)

foreach ($projectDir in $projectDirs)
{
$projectName = [System.IO.Path]::GetFileName($projectDir)

$match = [regex]::Match($componentOwnersContent, "src\/$projectName\/:([\w\W\s]*?)src")
if ($match.Success -eq $true)
{
$matches = [regex]::Matches($match.Groups[1].Value, "-\s*(.*)")
foreach ($match in $matches)
{
$owner = $match.Groups[1].Value
$_ = $componentOwners.Value.Add($owner.Trim())
}
}
}
}

Export-ModuleMember -Function FindComponentOwners
48 changes: 7 additions & 41 deletions build/scripts/prepare-release.psm1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Import-Module $PSScriptRoot\build.psm1

function CreatePullRequestToUpdateChangelogsAndPublicApis {
param(
[Parameter(Mandatory=$true)][string]$gitRepository,
Expand Down Expand Up @@ -354,48 +356,12 @@ function TagCodeOwnersOnOrRunWorkflowForRequestReleaseIssue {
Return
}

$projectPath = "src/$component/$component.csproj"

if ((Test-Path -Path $projectPath) -eq $false)
{
gh issue comment $issueNumber `
--body "I couldn't find the project file for the requested component. Please create a new release request and select a valid component or edit the description and set a valid component."
Return
}

$projectContent = Get-Content -Path $projectPath

$match = [regex]::Match($projectContent, '<MinVerTagPrefix>(.*)<\/MinVerTagPrefix>')
if ($match.Success -eq $false)
{
gh issue comment $issueNumber `
--body "I couldn't find ``MinVerTagPrefix`` in the project file for the requested component. Please create a new release request and select a valid component or edit the description and set a valid component."
Return
}

$minVerTagPrefix = $match.Groups[1].Value

$projectDirs = Get-ChildItem -Path src/**/*.csproj | Select-String "<MinVerTagPrefix>$minVerTagPrefix</MinVerTagPrefix>" -List | Select Path | Split-Path -Parent

$componentOwnersContent = Get-Content '.github/component_owners.yml' -Raw

$componentOwners = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase)

foreach ($projectDir in $projectDirs)
{
$projectName = [System.IO.Path]::GetFileName($projectDir)
$componentOwners = $null

$match = [regex]::Match($componentOwnersContent, "src\/$projectName\/:([\w\W\s]*?)src")
if ($match.Success -eq $true)
{
$matches = [regex]::Matches($match.Groups[1].Value, "-\s*(.*)")
foreach ($match in $matches)
{
$owner = $match.Groups[1].Value
$_ = $componentOwners.Add($owner.Trim())
}
}
}
FindComponentOwners `
-component $component `
-issueNumber $issueNumber `
-componentOwners ([ref]$componentOwners)

$requestedByUserPermission = gh api "repos/$gitRepository/collaborators/$requestedByUserName/permission" | ConvertFrom-Json

Expand Down
3 changes: 3 additions & 0 deletions src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Drop support for .NET 6 as this target is no longer supported.
([#2117](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2117))

## 1.9.0

Released 2024-Jun-21
Expand Down
19 changes: 19 additions & 0 deletions src/OpenTelemetry.Exporter.Geneva/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:OpenTelemetry.Exporter.Geneva.EventNameExportMode</Target>
<Left>lib/net6.0/OpenTelemetry.Exporter.Geneva.dll</Left>
<Right>lib/netstandard2.0/OpenTelemetry.Exporter.Geneva.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:OpenTelemetry.Exporter.Geneva.ExceptionStackExportMode</Target>
<Left>lib/net6.0/OpenTelemetry.Exporter.Geneva.dll</Left>
<Right>lib/netstandard2.0/OpenTelemetry.Exporter.Geneva.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
</Suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#nullable enable

#if NET8_0_OR_GREATER
#if NET
using System.Collections.Frozen;
#endif

Expand Down Expand Up @@ -33,7 +33,7 @@ internal abstract class MsgPackExporter
[Schema.V40.PartA.Extensions.Os.Ver] = "env_os_ver",
};

#if NET8_0_OR_GREATER
#if NET
internal static readonly IReadOnlyDictionary<string, string> V40_PART_A_MAPPING = PART_A_MAPPING_DICTIONARY.ToFrozenDictionary();
#else
internal static readonly IReadOnlyDictionary<string, string> V40_PART_A_MAPPING = PART_A_MAPPING_DICTIONARY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#nullable enable

#if NET8_0_OR_GREATER
#if NET
using System.Collections.Frozen;
#endif
using System.Diagnostics;
Expand Down Expand Up @@ -33,7 +33,7 @@ internal sealed class MsgPackLogExporter : MsgPackExporter, IDisposable
private readonly bool shouldExportEventName;
private readonly TableNameSerializer tableNameSerializer;

#if NET8_0_OR_GREATER
#if NET
private readonly FrozenSet<string>? customFields;
private readonly FrozenDictionary<string, object>? prepopulatedFields;
#else
Expand Down Expand Up @@ -94,7 +94,7 @@ public MsgPackLogExporter(GenevaExporterOptions options)
this.prepopulatedFieldKeys.Add(kv.Key);
}

#if NET8_0_OR_GREATER
#if NET
this.prepopulatedFields = tempPrepopulatedFields.ToFrozenDictionary(StringComparer.Ordinal);
#else
this.prepopulatedFields = tempPrepopulatedFields;
Expand All @@ -110,7 +110,7 @@ public MsgPackLogExporter(GenevaExporterOptions options)
customFields.Add(name);
}

#if NET8_0_OR_GREATER
#if NET
this.customFields = customFields.ToFrozenSet(StringComparer.Ordinal);
#else
this.customFields = customFields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#nullable enable

#if NET8_0_OR_GREATER
#if NET
using System.Collections.Frozen;
#endif
using System.Diagnostics;
Expand Down Expand Up @@ -34,15 +34,15 @@ internal sealed class MsgPackTraceExporter : MsgPackExporter, IDisposable
["messaging.url"] = "messagingUrl",
};

#if NET8_0_OR_GREATER
#if NET
internal static readonly FrozenDictionary<string, string> CS40_PART_B_MAPPING = CS40_PART_B_MAPPING_DICTIONARY.ToFrozenDictionary();
#else
internal static readonly Dictionary<string, string> CS40_PART_B_MAPPING = CS40_PART_B_MAPPING_DICTIONARY;
#endif

internal readonly ThreadLocal<byte[]> Buffer = new();

#if NET8_0_OR_GREATER
#if NET
internal readonly FrozenSet<string>? CustomFields;

internal readonly FrozenSet<string>? DedicatedFields;
Expand Down Expand Up @@ -123,7 +123,7 @@ public MsgPackTraceExporter(GenevaExporterOptions options)
dedicatedFields.Add(name);
}

#if NET8_0_OR_GREATER
#if NET
this.CustomFields = customFields.ToFrozenSet(StringComparer.Ordinal);
#else
this.CustomFields = customFields;
Expand All @@ -137,7 +137,7 @@ public MsgPackTraceExporter(GenevaExporterOptions options)
dedicatedFields.Add("otel.status_code");
dedicatedFields.Add("otel.status_description");

#if NET8_0_OR_GREATER
#if NET
this.DedicatedFields = dedicatedFields.ToFrozenSet(StringComparer.Ordinal);
#else
this.DedicatedFields = dedicatedFields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public unsafe override int GetChars(byte[] bytes, int byteIndex, int byteCount,

public override unsafe int GetBytes(char* charPtr, int charCount, byte* bytePtr, int byteCount)
{
#if NET8_0_OR_GREATER
#if NET
ArgumentOutOfRangeException.ThrowIfLessThan(byteCount, charCount);
#else
if (byteCount < charCount)
Expand All @@ -102,7 +102,7 @@ public override unsafe int GetBytes(char* charPtr, int charCount, byte* bytePtr,

public override unsafe int GetChars(byte* bytePtr, int byteCount, char* charPtr, int charCount)
{
#if NET8_0_OR_GREATER
#if NET
ArgumentOutOfRangeException.ThrowIfLessThan(charCount, byteCount);
#else
if (charCount < byteCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}

#if NET8_0_OR_GREATER
#if NET
[GeneratedRegex(DisableRegexPattern)]
private static partial Regex GetDisableRegexPattern();
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public OtlpProtobufMetricExporter(Func<Resource> getResource, ConnectionStringBu

this.getResource = getResource;

this.otlpProtobufSerializer = new OtlpProtobufSerializer(MetricEtwDataTransport.Instance, connectionStringBuilder, prepopulatedMetricDimensions);
this.otlpProtobufSerializer = new OtlpProtobufSerializer(MetricWindowsEventTracingDataTransport.Instance, connectionStringBuilder, prepopulatedMetricDimensions);
}

public ExportResult Export(in Batch<Metric> batch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ internal TlvMetricExporter(ConnectionStringBuilder connectionStringBuilder, IRea
}

var unixDomainSocketPath = connectionStringBuilder.ParseUnixDomainSocketPath();
this.metricDataTransport = new MetricUnixDataTransport(unixDomainSocketPath);
this.metricDataTransport = new MetricUnixDomainSocketDataTransport(unixDomainSocketPath);
break;
case TransportProtocol.Unspecified:
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
this.metricDataTransport = MetricEtwDataTransport.Instance;
this.metricDataTransport = MetricWindowsEventTracingDataTransport.Instance;
break;
}
else
Expand Down Expand Up @@ -77,7 +77,7 @@ public void Dispose()
{
// The ETW data transport singleton on Windows should NOT be disposed.
// On Linux, Unix Domain Socket is used and should be disposed.
if (this.metricDataTransport != MetricEtwDataTransport.Instance)
if (this.metricDataTransport != MetricWindowsEventTracingDataTransport.Instance)
{
this.metricDataTransport.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

namespace OpenTelemetry.Exporter.Geneva;

internal sealed class MetricUnixDataTransport : IMetricDataTransport
internal sealed class MetricUnixDomainSocketDataTransport : IMetricDataTransport
{
private readonly int fixedPayloadLength;
private readonly UnixDomainSocketDataTransport udsDataTransport;
private bool isDisposed;

public MetricUnixDataTransport(
public MetricUnixDomainSocketDataTransport(
string unixDomainSocketPath,
int timeoutMilliseconds = UnixDomainSocketDataTransport.DefaultTimeoutMilliseconds)
{
Expand Down
Loading

0 comments on commit 2e6a855

Please sign in to comment.