Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Exporting using gRPC doesn't work in net48 projects #6067

Open
AB027PS opened this issue Jan 16, 2025 · 4 comments
Open

[bug] Exporting using gRPC doesn't work in net48 projects #6067

AB027PS opened this issue Jan 16, 2025 · 4 comments
Assignees
Labels
bug Something isn't working pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package

Comments

@AB027PS
Copy link
Contributor

AB027PS commented Jan 16, 2025

Package

OpenTelemetry.Exporter.OpenTelemetryProtocol

Package Version

Package Name Version
OpenTelemetry.Exporter.OpenTelemetryProtocol 1.11.0

Runtime Version

net48

Description

I'm not able to export logs/metrics/traces using gRPC in net48 projects .

Steps to Reproduce

using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleAppFramework
{
    internal class Program
    {
        static void Main(string[] args)
        {
            using (var provider = Sdk
                .CreateTracerProviderBuilder()
                .AddSource("test")
                .SetResourceBuilder(ResourceBuilder
                    .CreateEmpty()
                    .AddService("ConsoleAppFramework"))
                .AddOtlpExporter()
                .Build())
            {
                var source = new ActivitySource("test");

                while (true)
                {
                    using (var activity = source.StartActivity("testing"))
                    {
                        Thread.Sleep(1000);
                    }
                }
            }
        }

    }
}

Expected Result

Traces get successfully exported

Actual Result

An exception is thrown at line 42 here

/// <inheritdoc/>
public override ExportClientResponse SendExportRequest(byte[] buffer, int contentLength, DateTime deadlineUtc, CancellationToken cancellationToken = default)
{
try
{
using var httpRequest = this.CreateHttpRequest(buffer, contentLength);
using var httpResponse = this.SendHttpRequest(httpRequest, cancellationToken);
httpResponse.EnsureSuccessStatusCode();

The exception message is Only HTTP/1.0 and HTTP/1.1 version requests are currently supported. Parameter name: value

Additional Context

Exporting via HTTP works fine.

@AB027PS AB027PS added bug Something isn't working needs-triage New issues which have not been classified or triaged by a community member labels Jan 16, 2025
@github-actions github-actions bot added the pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package label Jan 16, 2025
@alanwest
Copy link
Member

@rajkumar-rangaraj I did some investigation in to .NET Framework support awhile back. I did it in the context of removing the old gRPC library and supporting .NET Framework with the newer Grpc.Net.Client library. There are some notes in the description of this PR #4860.

Now that the dependency for both gRPC libraries have been removed, maybe we can support .NET Framework with the WinHttpHandler? It would require a new dependency only for the .NET Framework build.

@CraigN
Copy link

CraigN commented Jan 17, 2025

A workaround of rolling back package OpenTelemetry.Exporter.OpenTelemetryProtocol to 1.10.0 resolves the issue whilst continuing to use all other packages on 1.11.0.

@romerod romerod marked this as a duplicate of #6066 Jan 17, 2025
@romerod
Copy link

romerod commented Jan 17, 2025

Tried the workaround of using WinHttpHandler which supports HTTP/2 results in a System.Net.Http.HttpRequestException with BadRequest 400.
exporterOptions.HttpClientFactory = () => new HttpClient(new WinHttpHandler());

Tried this with aspire as collector:
docker run --rm -it -p 18888:18888 -p 4317:18889 -e DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS=true -d --name aspire-dashboard mcr.microsoft.com/dotnet/aspire-dashboard:9.0

I closed #6066 as it's the same bug. Small repro project can be found there.

@rajkumar-rangaraj rajkumar-rangaraj self-assigned this Jan 17, 2025
@rajkumar-rangaraj rajkumar-rangaraj removed the needs-triage New issues which have not been classified or triaged by a community member label Jan 17, 2025
@rajkumar-rangaraj
Copy link
Contributor

rajkumar-rangaraj commented Jan 18, 2025

Adding a WinHttpHandler as shown below will work only if an HTTPS URL is used as the endpoint. For example: https://localhost:4317/.

exporterOptions.HttpClientFactory = () => new HttpClient(new WinHttpHandler());

I'm working on further to find the complete fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package
Projects
None yet
Development

No branches or pull requests

5 participants