Skip to content

Commit

Permalink
Merge branch 'main' into DroppedSpanStatsFix
Browse files Browse the repository at this point in the history
  • Loading branch information
gregkalapos authored Sep 20, 2023
2 parents 2563cea + bacb115 commit b92c664
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 12 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/test-linux-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow sets the 'test-linux / pack' and 'test-linux / tests' status check to success in case it's a docs only PR and test-linux.yml is not triggered
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
name: test-linux # The name must be the same as in test-linux.yml

on:
pull_request:
paths-ignore: # This expression needs to match the paths ignored on test-linux.yml.
- '**'
- '!**/*.md'
- '!**/*.asciidoc'
- '!docs/**'

permissions:
contents: read

## Concurrency only allowed in the main branch.
## So old builds running for old commits within the same Pull Request are cancelled
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
# dummy steps that allow to bypass those mandatory checks for tests
pack:
runs-on: ubuntu-latest
steps:
- run: 'echo "Not required for docs"'

# dummy steps that allow to bypass those mandatory checks for tests
tests:
runs-on: ubuntu-latest
steps:
- run: 'echo "Not required for docs"'
28 changes: 28 additions & 0 deletions .github/workflows/test-windows-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This workflow sets the 'test-windows / tests' status check to success in case it's a docs only PR and test-windows.yml is not triggered
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
name: test-windows # The name must be the same as in test-windows.yml

on:
pull_request:
paths-ignore: # This expression needs to match the paths ignored on test-windows.yml.
- '**'
- '!**/*.md'
- '!**/*.asciidoc'
- '!docs/**'

permissions:
contents: read

## Concurrency only allowed in the main branch.
## So old builds running for old commits within the same Pull Request are cancelled
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:

# dummy steps that allow to bypass those mandatory checks for tests
tests:
runs-on: ubuntu-latest
steps:
- run: 'echo "Not required for docs"'
6 changes: 6 additions & 0 deletions .github/workflows/test-windows-iis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ jobs:
test-iis:
runs-on: windows-latest

# disable IIS on CI for now.
# Run locally and started failing randomly on github actions
# Could be because of plethora of reasons including no disk space
# Requires longer investigation
if: ${{ false }}

steps:
- uses: actions/checkout@v3
- name: Bootstrap Action Workspace
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ endif::[]
[[release-notes-1.x]]
=== .NET Agent version 1.x
[[release-notes-1.24.0]]
==== 1.24.0
===== Features
{pull}2157[#2157] Update and optimise OTel bridge
{pull}2140[#2140] Enable OpenTelemetryBridge by default
{pull}2147[#2147] Add Baggage support
{pull}2160[#2160] Trace in-process Azure Functions
{pull}2165[#2165] Internalize SqlClient Instrumentation
===== Bug fixes
{pull}2170[#2170] Ensure OpenTelemetryBridge respects Agents sampling decisions
{pull}2180[#2180] Change 'cloud.project.id' for GCP metadata to be the 'project-id'
{pull}2182[#2182] Handle SqlExceptions when accessing user claims
[[release-notes-1.23.0]]
==== 1.23.0
Expand Down
4 changes: 2 additions & 2 deletions build/scripts/Build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ module Build =
/// Builds the CLR profiler and supporting .NET managed assemblies
let BuildProfiler () =
dotnet "build" (Paths.ProfilerProjFile "Elastic.Apm.Profiler.Managed")
Cargo.Exec [ "make"; "build-release"; ]
Cargo.Exec [ "make"; "build-release"; "--disable-check-for-update"]

/// Publishes all projects with framework versions
let Publish targets =
Expand Down Expand Up @@ -185,7 +185,7 @@ module Build =
if isWindows && not isCI then msBuild "Clean" aspNetFullFramework

let CleanProfiler () =
Cargo.Exec ["make"; "clean"]
Cargo.ExecWithTimeout ["make"; "clean"; "--disable-check-for-update"] (TimeSpan.FromMinutes 10)

/// Restores all packages for the solution
let ToolRestore () =
Expand Down
3 changes: 1 addition & 2 deletions src/Elastic.Apm/Cloud/GcpCloudMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ internal GcpCloudMetadataProvider(IApmLogger logger, HttpMessageHandler handler)
},
Project = new CloudProject
{
Id = metadata["project"]["numericProjectId"].Value<long>().ToString(CultureInfo.InvariantCulture),
Name = metadata["project"]["projectId"].Value<string>()
Id = metadata["project"]["projectId"].Value<string>()
},
AvailabilityZone = availabilityZone,
Machine = new CloudMachine { Type = machineType },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data.SqlClient;
using System.Linq;
using System.Security.Claims;
using System.Threading;
Expand Down Expand Up @@ -460,14 +461,21 @@ private void FillSampledTransactionContextUser(HttpContext context, ITransaction

if (context.User is ClaimsPrincipal claimsPrincipal)
{
static string GetClaimWithFallbackValue(ClaimsPrincipal principal, string claimType, string fallbackClaimType)
try
{
var claim = principal.Claims.FirstOrDefault(n => n.Type == claimType || n.Type == fallbackClaimType);
return claim != null ? claim.Value : string.Empty;
}
static string GetClaimWithFallbackValue(ClaimsPrincipal principal, string claimType, string fallbackClaimType)
{
var claim = principal.Claims.FirstOrDefault(n => n.Type == claimType || n.Type == fallbackClaimType);
return claim != null ? claim.Value : string.Empty;
}

user.Email = GetClaimWithFallbackValue(claimsPrincipal, ClaimTypes.Email, OpenIdClaimTypes.Email);
user.Id = GetClaimWithFallbackValue(claimsPrincipal, ClaimTypes.NameIdentifier, OpenIdClaimTypes.UserId);
user.Email = GetClaimWithFallbackValue(claimsPrincipal, ClaimTypes.Email, OpenIdClaimTypes.Email);
user.Id = GetClaimWithFallbackValue(claimsPrincipal, ClaimTypes.NameIdentifier, OpenIdClaimTypes.UserId);
}
catch (SqlException ex)
{
_logger.Error()?.Log("Unable to access user claims due to SqlException with message: {message}", ex.Message);
}
}

transaction.Context.User = user;
Expand Down
4 changes: 2 additions & 2 deletions test/Elastic.Apm.Tests/Cloud/GcpCloudMetadataProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public async Task GetMetadataAsync_Returns_Expected_Cloud_Metadata()
metadata.Instance.Id.Should().Be(stubMetadata.instance.id.ToString());
metadata.Instance.Name.Should().Be(stubMetadata.instance.name);
metadata.Project.Should().NotBeNull();
metadata.Project.Id.Should().Be(stubMetadata.project.numericProjectId.ToString());
metadata.Project.Name.Should().Be(stubMetadata.project.projectId);
metadata.Project.Id.Should().Be(stubMetadata.project.projectId);
metadata.Project.Name.Should().BeNull();
metadata.AvailabilityZone.Should().Be("us-west3-a");
metadata.Region.Should().Be("us-west3");
metadata.Machine.Should().NotBeNull();
Expand Down

0 comments on commit b92c664

Please sign in to comment.