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

Can't use OtlpExporter in an Alpine docker image #1251

Closed
damonbarry opened this issue Sep 9, 2020 · 4 comments · Fixed by #1671
Closed

Can't use OtlpExporter in an Alpine docker image #1251

damonbarry opened this issue Sep 9, 2020 · 4 comments · Fixed by #1671
Labels
bug Something isn't working pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package

Comments

@damonbarry
Copy link

damonbarry commented Sep 9, 2020

Bug Report

List of NuGet packages and version that you are using:

  • OpenTelemetry.Exporter.OpenTelemetryProtocol 0.5.0-beta.2

Runtime version:

  • netcoreapp3.1

Symptom

When I run a .NET Core application in an Alpine-based docker image, and the app calls

Sdk.CreateTracerProviderBuilder()
    .AddSource("test.app")
    .AddOtlpExporter()
    .Build();

I get an exception because GRPC is missing a native dependency. It seems to be looking for a glibc library instead of the musl equivalent.

Unhandled exception. System.IO.IOException: Error loading native library "/App/runtimes/linux/native/libgrpc_csharp_ext.x64.so". Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /App/runtimes/linux/native/libgrpc_csharp_ext.x64.so)
   at Grpc.Core.Internal.UnmanagedLibrary..ctor(String[] libraryPathAlternatives)
   at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary()
   at Grpc.Core.Internal.NativeExtension.LoadNativeMethods()
   at Grpc.Core.Internal.NativeExtension.Get()
   at Grpc.Core.Internal.NativeMethods.Get()
   at Grpc.Core.GrpcEnvironment.GrpcNativeInit()
   at Grpc.Core.GrpcEnvironment..ctor()
   at Grpc.Core.GrpcEnvironment.AddRef()
   at Grpc.Core.Channel..ctor(String target, ChannelCredentials credentials, IEnumerable`1 options)
   at OpenTelemetry.Exporter.OpenTelemetryProtocol.OtlpExporter..ctor(OtlpExporterOptions options)
   at OpenTelemetry.Trace.OtlpExporterHelperExtensions.AddOtlpExporter(TracerProviderBuilder builder, Action`1 configure)
   at otlp_exporter_sample.Program.Main(String[] args) in C:\Users\damonb\projects\otlp-exporter-sample\Program.cs:line 11

What is the expected behavior?

The opentelemetry-dotnet libraries should work in an Alpine-based docker image (ideally in the dotnet/core Alpine image). I'd like to instrument the .NET code my team ships as docker images.

Reproduce

otlp-exporter-sample.csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RootNamespace>otlp_exporter_sample</RootNamespace>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="0.5.0-beta.2" />
  </ItemGroup>
</Project>

Program.cs:

using System;
using OpenTelemetry;
using OpenTelemetry.Trace;

namespace otlp_exporter_sample
{
    class Program
    {
        static void Main(string[] args)
        {
            using var tracerProvider = Sdk.CreateTracerProviderBuilder()
                .AddSource("test.app")
                .AddOtlpExporter()
                .Build();

            Console.WriteLine(tracerProvider.ToString());
        }
    }
}

Dockerfile:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.8-alpine3.12
COPY bin/Release/netcoreapp3.1/publish/ App/
WORKDIR /App
ENTRYPOINT ["dotnet", "otlp-exporter-sample.dll"]

Save the above three files in a directory, cd to that directory, and run the following commands to reproduce the bug:

dotnet publish -c Release
docker build -t otlp-exporter-sample -f Dockerfile .
docker run -it --rm otlp-exporter-sample
@damonbarry damonbarry added the bug Something isn't working label Sep 9, 2020
@reyang reyang added area:exporter pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package labels Sep 10, 2020
@cijothomas
Copy link
Member

@eddynaka Do you have free cycles to investigate this issue?

@eddynaka
Copy link
Contributor

eddynaka commented Oct 1, 2020

Hi @damonbarry , after some research, it looks like we have to add an step:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.8-alpine3.12 AS base
WORKDIR /app
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.8/main' >> /etc/apk/repositories
RUN apk update && apk add --no-cache bash libc6-compat=1.1.19-r11

After I added this, the docker ran normally.

It's a known issue: grpc/grpc#21446

@eddynaka
Copy link
Contributor

eddynaka commented Oct 1, 2020

Let us know if you face any other issue. We are closing this for now.

@eddynaka eddynaka closed this as completed Oct 1, 2020
@damonbarry
Copy link
Author

@eddynaka I rebuilt my container with the workaround, and it seems to have worked, thanks!

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

Successfully merging a pull request may close this issue.

4 participants