This line
private static readonly string FileVersion = FileVersionInfo.GetVersionInfo(typeof(Resource).Assembly.Location).FileVersion;
at https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry/Resources/ResourceBuilderExtensions.cs#L28
fails on application startup inside an AWS Lambda as the assemblies required are not loaded from disk.
Example stack trace:
System.TypeInitializationException: The type initializer for 'OpenTelemetry.Resources.ResourceBuilderExtensions' threw an exception.
---> System.ArgumentException: The path is empty. (Parameter 'path')
at System.IO.Path.GetFullPath(String path)
at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
at OpenTelemetry.Resources.ResourceBuilderExtensions..cctor()
Reproduction / suggestion:
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
// Adjust as necessary
var ot = @"opentelemetry\1.0.1\lib\netstandard2.0\OpenTelemetry.dll";
var assemblyLoadFile = Assembly.LoadFile(ot);
var assemblyLoad = Assembly.Load(File.ReadAllBytes(ot));
Console.WriteLine($"Assembly.LoadFile, proposed method: {assemblyLoadFile.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version}");
Console.WriteLine($"Assembly.LoadFile, current method: {FileVersionInfo.GetVersionInfo(assemblyLoadFile.Location).FileVersion}");
Console.WriteLine($"Assembly.Load, proposed method: {assemblyLoad.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version}");
Console.WriteLine($"Assembly.Load, current method (fails): {FileVersionInfo.GetVersionInfo(assemblyLoad.Location).FileVersion}");
This line
at https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry/Resources/ResourceBuilderExtensions.cs#L28
fails on application startup inside an AWS Lambda as the assemblies required are not loaded from disk.
Example stack trace:
Reproduction / suggestion: