Skip to content

Commit

Permalink
Merge branch 'main' into feature/prometheus-scope-info
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcoltheart committed Nov 29, 2023
2 parents 4ba86a8 + 4f73d2b commit ab9292c
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 157 deletions.
2 changes: 1 addition & 1 deletion build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- production TFMs -->
<TargetFrameworksForLibraries>net8.0;net6.0;netstandard2.0;$(NetFrameworkMinimumSupportedVersion)</TargetFrameworksForLibraries>
<TargetFrameworksForLibrariesExtended>net8.0;net6.0;netstandard2.1;netstandard2.0;$(NetFrameworkMinimumSupportedVersion)</TargetFrameworksForLibrariesExtended>
<TargetFrameworksForAspNetCoreInstrumentation>net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0</TargetFrameworksForAspNetCoreInstrumentation>
<TargetFrameworksForAspNetCoreInstrumentation>net8.0;net7.0;net6.0;netstandard2.0</TargetFrameworksForAspNetCoreInstrumentation>
<TargetFrameworksForGrpcNetClientInstrumentation>net8.0;net6.0;netstandard2.1;netstandard2.0</TargetFrameworksForGrpcNetClientInstrumentation>
<TargetFrameworksForPrometheusAspNetCore>net8.0;net6.0</TargetFrameworksForPrometheusAspNetCore>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class AspNetCoreInstrumentationOptions
/// </remarks>
public bool RecordException { get; set; }

#if NETSTANDARD2_1 || NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
/// <summary>
/// Gets or sets a value indicating whether RPC attributes are added to an Activity when using Grpc.AspNetCore. Default is true.
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
semantic conventions.
([#5066](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5066))

* Removed `netstandard2.1` target.
([#5094](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5094))

## 1.6.0-beta.3

Released 2023-Nov-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,51 +344,6 @@ static bool TryFetchException(object payload, out Exception exc)
=> ExceptionPropertyFetcher.TryFetch(payload, out exc) && exc != null;
}

private static string GetUri(HttpRequest request)
{
// this follows the suggestions from https://github.com/dotnet/aspnetcore/issues/28906
var scheme = request.Scheme ?? string.Empty;

// HTTP 1.0 request with NO host header would result in empty Host.
// Use placeholder to avoid incorrect URL like "http:///"
var host = request.Host.Value ?? UnknownHostName;
var pathBase = request.PathBase.Value ?? string.Empty;
var path = request.Path.Value ?? string.Empty;
var queryString = request.QueryString.Value ?? string.Empty;
var length = scheme.Length + Uri.SchemeDelimiter.Length + host.Length + pathBase.Length
+ path.Length + queryString.Length;

#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
return string.Create(length, (scheme, host, pathBase, path, queryString), (span, parts) =>
{
CopyTo(ref span, parts.scheme);
CopyTo(ref span, Uri.SchemeDelimiter);
CopyTo(ref span, parts.host);
CopyTo(ref span, parts.pathBase);
CopyTo(ref span, parts.path);
CopyTo(ref span, parts.queryString);
static void CopyTo(ref Span<char> buffer, ReadOnlySpan<char> text)
{
if (!text.IsEmpty)
{
text.CopyTo(buffer);
buffer = buffer.Slice(text.Length);
}
}
});
#else
return new System.Text.StringBuilder(length)
.Append(scheme)
.Append(Uri.SchemeDelimiter)
.Append(host)
.Append(pathBase)
.Append(path)
.Append(queryString)
.ToString();
#endif
}

#if !NETSTANDARD2_0
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool TryGetGrpcMethod(Activity activity, out string grpcMethod)
Expand Down
8 changes: 8 additions & 0 deletions src/OpenTelemetry.Instrumentation.GrpcNetClient/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

* **Breaking Change** :
[SuppressDownstreamInstrumentation](https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/src/OpenTelemetry.Instrumentation.GrpcNetClient#suppressdownstreaminstrumentation)
option will no longer be supported when used with certain versions of
`OpenTelemetry.Instrumentation.Http` package. Check out this
[issue](https://github.com/open-telemetry/opentelemetry-dotnet/issues/5092)
for details and workaround.
([#5077](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5077))

## 1.6.0-beta.3

Released 2023-Nov-17
Expand Down
8 changes: 8 additions & 0 deletions src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
* Update activity DisplayName as per the specification.
([#5078](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5078))

* Removed reference to `OpenTelemetry` package. This is a **breaking change**
for users relying on
[SuppressDownstreamInstrumentation](https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/src/OpenTelemetry.Instrumentation.GrpcNetClient#suppressdownstreaminstrumentation)
option in `OpenTelemetry.Instrumentation.GrpcNetClient`. For details, check
out this
[issue](https://github.com/open-telemetry/opentelemetry-dotnet/issues/5092).
([#5077](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5077))

## 1.6.0-beta.3

Released 2023-Nov-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
using System.Net.Http;
#endif
using System.Runtime.CompilerServices;
using Microsoft.Extensions.Configuration;
using OpenTelemetry.Instrumentation.Http.Implementation;
using static OpenTelemetry.Internal.HttpSemanticConventionHelper;

namespace OpenTelemetry.Instrumentation.Http;

Expand All @@ -31,23 +29,6 @@ namespace OpenTelemetry.Instrumentation.Http;
/// </summary>
public class HttpClientInstrumentationOptions
{
internal readonly HttpSemanticConvention HttpSemanticConvention;

/// <summary>
/// Initializes a new instance of the <see cref="HttpClientInstrumentationOptions"/> class.
/// </summary>
public HttpClientInstrumentationOptions()
: this(new ConfigurationBuilder().AddEnvironmentVariables().Build())
{
}

internal HttpClientInstrumentationOptions(IConfiguration configuration)
{
Debug.Assert(configuration != null, "configuration was null");

this.HttpSemanticConvention = GetSemanticConventionOptIn(configuration);
}

/// <summary>
/// Gets or sets a filter function that determines whether or not to
/// collect telemetry on a per request basis.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ public void OnStartActivity(Activity activity, object payload)
// By this time, samplers have already run and
// activity.IsAllDataRequested populated accordingly.

if (Sdk.SuppressInstrumentation)
{
return;
}

if (!TryFetchRequest(payload, out HttpRequestMessage request))
{
HttpInstrumentationEventSource.Log.NullPayload(nameof(HttpHandlerDiagnosticListener), nameof(this.OnStartActivity));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ public override void OnEventWritten(string name, object payload)

public void OnStopEventWritten(Activity activity, object payload)
{
if (Sdk.SuppressInstrumentation)
{
return;
}

if (TryFetchRequest(payload, out HttpRequestMessage request))
{
// see the spec https://github.com/open-telemetry/semantic-conventions/blob/v1.23.0/docs/http/http-metrics.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,22 @@

<ItemGroup>
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" />
<Compile Include="$(RepoRoot)\src\Shared\EnvironmentVariables\*.cs" Link="Includes\EnvironmentVariables\%(Filename).cs" />
<Compile Include="$(RepoRoot)\src\Shared\HttpSemanticConventionHelper.cs" Link="Includes\HttpSemanticConventionHelper.cs" />
<Compile Include="$(RepoRoot)\src\Shared\Options\*.cs" Link="Includes\Options\%(Filename).cs" />
<Compile Include="$(RepoRoot)\src\Shared\Shims\NullableAttributes.cs" Link="Includes\Shims\NullableAttributes.cs" />
<Compile Include="$(RepoRoot)\src\Shared\RequestMethodHelper.cs" Link="Includes\RequestMethodHelper.cs" />
</ItemGroup>

<ItemGroup Condition="'$(RunningDotNetPack)' != 'true'">
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Api.ProviderBuilderExtensions\OpenTelemetry.Api.ProviderBuilderExtensions.csproj" />
</ItemGroup>

<!-- Instrumentation packages when published should take a dependency only on the latest stable version of the API/SDK. -->
<ItemGroup Condition="'$(RunningDotNetPack)' == 'true'">
<PackageReference Include="OpenTelemetry" />
<PackageReference Include="OpenTelemetry.Api.ProviderBuilderExtensions" />
</ItemGroup>

<ItemGroup>
<Reference Include="System.Net.Http" Condition="'$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'" />
<PackageReference Include="Microsoft.Extensions.Options" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ public static TracerProviderBuilder AddHttpClientInstrumentation(this TracerProv
{
services.Configure(name, configureHttpClientInstrumentationOptions);
}
services.RegisterOptionsFactory(configuration => new HttpClientInstrumentationOptions(configuration));
});

#if NETFRAMEWORK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public void GrpcAndHttpClientInstrumentationIsInvoked(bool shouldEnrich)
Assert.Equal(shouldEnrich ? "yes" : "no", grpcSpan.Tags.Where(tag => tag.Key == "enrichedWithHttpResponseMessage").FirstOrDefault().Value);
}

[Fact]
[Fact(Skip = "https://github.com/open-telemetry/opentelemetry-dotnet/issues/5092")]
public void GrpcAndHttpClientInstrumentationWithSuppressInstrumentation()
{
var uri = new Uri($"http://localhost:{this.server.Port}");
Expand Down Expand Up @@ -443,7 +443,7 @@ public void GrpcAndHttpClientInstrumentationWithSuppressInstrumentation()
Assert.Equal(0, grpcSpan4.GetTagValue(SemanticConventions.AttributeRpcGrpcStatusCode));
}

[Fact]
[Fact(Skip = "https://github.com/open-telemetry/opentelemetry-dotnet/issues/5092")]
public void GrpcPropagatesContextWithSuppressInstrumentationOptionSetToTrue()
{
try
Expand Down Expand Up @@ -586,7 +586,7 @@ public void GrpcDoesNotPropagateContextWithSuppressInstrumentationOptionSetToFal
}
}

[Fact]
[Fact(Skip = "https://github.com/open-telemetry/opentelemetry-dotnet/issues/5092")]
public void GrpcClientInstrumentationRespectsSdkSuppressInstrumentation()
{
try
Expand Down
Loading

0 comments on commit ab9292c

Please sign in to comment.