diff --git a/OpenTelemetry.ClrProfiler.sln b/OpenTelemetry.ClrProfiler.sln index 9f50ca278b..a729476bd8 100644 --- a/OpenTelemetry.ClrProfiler.sln +++ b/OpenTelemetry.ClrProfiler.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28803.452 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32112.339 MinimumVisualStudioVersion = 15.0.26124.0 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenTelemetry.ClrProfiler.Native", "src\OpenTelemetry.ClrProfiler.Native\OpenTelemetry.ClrProfiler.Native.vcxproj", "{91B6272F-5780-4C94-8071-DBBA7B4F67F3}" ProjectSection(ProjectDependencies) = postProject @@ -129,7 +129,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests.StartupHoo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.StartupHook", "test\test-applications\integrations\Samples.StartupHook\Samples.StartupHook.csproj", "{FF665CC4-6643-4614-A1A0-FA182E3AF37C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.Instrumentation.AdditionalDeps", "src\OpenTelemetry.Instrumentation.AdditionalDeps\OpenTelemetry.Instrumentation.AdditionalDeps.csproj", "{E026D9FA-FBD5-4066-AF6A-FB63DE28521F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.AdditionalDeps", "src\OpenTelemetry.Instrumentation.AdditionalDeps\OpenTelemetry.Instrumentation.AdditionalDeps.csproj", "{E026D9FA-FBD5-4066-AF6A-FB63DE28521F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.ClrProfiler.Managed.Tests", "test\OpenTelemetry.ClrProfiler.Managed.Tests\OpenTelemetry.ClrProfiler.Managed.Tests.csproj", "{065FEB4E-A99E-4A59-8112-1CB30CF794F9}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -499,6 +501,18 @@ Global {E026D9FA-FBD5-4066-AF6A-FB63DE28521F}.Release|x64.Build.0 = Release|Any CPU {E026D9FA-FBD5-4066-AF6A-FB63DE28521F}.Release|x86.ActiveCfg = Release|Any CPU {E026D9FA-FBD5-4066-AF6A-FB63DE28521F}.Release|x86.Build.0 = Release|Any CPU + {065FEB4E-A99E-4A59-8112-1CB30CF794F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {065FEB4E-A99E-4A59-8112-1CB30CF794F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {065FEB4E-A99E-4A59-8112-1CB30CF794F9}.Debug|x64.ActiveCfg = Debug|Any CPU + {065FEB4E-A99E-4A59-8112-1CB30CF794F9}.Debug|x64.Build.0 = Debug|Any CPU + {065FEB4E-A99E-4A59-8112-1CB30CF794F9}.Debug|x86.ActiveCfg = Debug|Any CPU + {065FEB4E-A99E-4A59-8112-1CB30CF794F9}.Debug|x86.Build.0 = Debug|Any CPU + {065FEB4E-A99E-4A59-8112-1CB30CF794F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {065FEB4E-A99E-4A59-8112-1CB30CF794F9}.Release|Any CPU.Build.0 = Release|Any CPU + {065FEB4E-A99E-4A59-8112-1CB30CF794F9}.Release|x64.ActiveCfg = Release|Any CPU + {065FEB4E-A99E-4A59-8112-1CB30CF794F9}.Release|x64.Build.0 = Release|Any CPU + {065FEB4E-A99E-4A59-8112-1CB30CF794F9}.Release|x86.ActiveCfg = Release|Any CPU + {065FEB4E-A99E-4A59-8112-1CB30CF794F9}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -542,6 +556,7 @@ Global {0584ADC1-956E-49B0-A46F-8405AA2AD207} = {357C3F25-98CA-41C6-BA2C-20968695D026} {FF665CC4-6643-4614-A1A0-FA182E3AF37C} = {E409ADD3-9574-465C-AB09-4324D205CC7C} {E026D9FA-FBD5-4066-AF6A-FB63DE28521F} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB} + {065FEB4E-A99E-4A59-8112-1CB30CF794F9} = {5C915382-C886-457D-8641-9E766D8E5A17} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F} diff --git a/build/nuke/Build.Steps.cs b/build/nuke/Build.Steps.cs index 60ad4674e2..8d6c5f8a57 100644 --- a/build/nuke/Build.Steps.cs +++ b/build/nuke/Build.Steps.cs @@ -125,6 +125,11 @@ partial class Build .SetConfiguration(BuildConfiguration) .SetNoRestore(true)); + DotNetBuild(x => x + .SetProjectFile(Solution.GetProject(Projects.Tests.ClrProfilerManagedTests)) + .SetConfiguration(BuildConfiguration) + .SetNoRestore(true)); + DotNetMSBuild(x => x .SetTargetPath(MsBuildProject) .SetTargetPlatform(Platform) @@ -265,7 +270,8 @@ partial class Build var unitTestProjects = new[] { - Solution.GetProject(Projects.Tests.ClrProfilerManagedLoaderTests) + Solution.GetProject(Projects.Tests.ClrProfilerManagedLoaderTests), + Solution.GetProject(Projects.Tests.ClrProfilerManagedTests) }; DotNetTest(config => config diff --git a/build/nuke/Projects.cs b/build/nuke/Projects.cs index 9d656d9b87..6a98853d1b 100644 --- a/build/nuke/Projects.cs +++ b/build/nuke/Projects.cs @@ -12,6 +12,7 @@ public static class Tests public const string ClrProfilerNativeTests = "OpenTelemetry.ClrProfiler.Native.Tests"; public const string ClrProfilerManagedLoaderTests = "OpenTelemetry.ClrProfiler.Managed.Loader.Tests"; public const string ClrProfilerManagedBootstrappingTests = "OpenTelemetry.ClrProfiler.Managed.Bootstrapping.Tests"; + public const string ClrProfilerManagedTests = "OpenTelemetry.ClrProfiler.Managed.Tests"; public const string IntegrationTestsHelpers = "IntegrationTests.Helpers"; } diff --git a/dev/docker-compose.yaml b/dev/docker-compose.yaml index f66dc7535b..a599d3693d 100644 --- a/dev/docker-compose.yaml +++ b/dev/docker-compose.yaml @@ -20,7 +20,7 @@ services: - "8888:8888" # Prometheus metrics exposed by the collector - "8889:8889" # Prometheus exporter metrics - "13133:13133" # health_check extension - - "4317:4317" # OTLP gRPC receiver + - "4318:4318" # OTLP http/protobuf receiver - "55679:55679" # zpages extension - "9411:9411" # zipkin receiver depends_on: diff --git a/dev/envvars.sh b/dev/envvars.sh index bef71ea56f..7eac896b94 100644 --- a/dev/envvars.sh +++ b/dev/envvars.sh @@ -59,7 +59,6 @@ export DOTNET_STARTUP_HOOKS="${CURDIR}/bin/tracer-home/netcoreapp3.1/OpenTelemet export OTEL_DOTNET_TRACER_HOME="${CURDIR}/bin/tracer-home" export OTEL_INTEGRATIONS="${CURDIR}/bin/tracer-home/integrations.json" export OTEL_TRACE_DEBUG="1" -export OTEL_EXPORTER="zipkin" export OTEL_DUMP_ILREWRITE_ENABLED="0" export OTEL_CLR_ENABLE_INLINING="1" export OTEL_PROFILER_EXCLUDE_PROCESSES="dotnet.exe,dotnet" diff --git a/docs/USAGE.md b/docs/USAGE.md index 150f6f6768..0363be0e20 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -65,13 +65,13 @@ The exporter is used to output the telemetry. | Environment variable | Description | Default | |-|-|-| -| `OTEL_EXPORTER` | The exporter to be used. The Tracer uses it to encode and dispatch traces. Available values are: `zipkin`, `jeager`, `otlp`. | | +| `OTEL_EXPORTER` | The exporter to be used. The Tracer uses it to encode and dispatch traces. Available values are: `zipkin`, `jeager`, `otlp`. | `otlp` | | `OTEL_EXPORTER_JAEGER_AGENT_HOST` | Hostname for the Jaeger agent. | `localhost` | | `OTEL_EXPORTER_JAEGER_AGENT_PORT` | Port for the Jaeger agent. | `6831` | -| `OTEL_EXPORTER_OTLP_ENDPOINT` | Target endpoint for OTLP exporter. More details [here](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md). | `http://localhost:4318` | +| `OTEL_EXPORTER_OTLP_ENDPOINT` | Target endpoint for OTLP exporter. More details [here](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md). | `http://localhost:4318` for `http/protobuf` protocol, `http://localhost:4317` for `grpc` protocol | | `OTEL_EXPORTER_OTLP_HEADERS` | Key-value pairs to be used as headers associated with gRPC or HTTP requests. More details [here](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md). | | | `OTEL_EXPORTER_OTLP_TIMEOUT` | Maximum time the OTLP exporter will wait for each batch export. | `1000` (ms) | -| `OTEL_EXPORTER_OTLP_PROTOCOL` | The OTLP expoter transport protocol. Supported values: `grpc`, `http/protobuf`. [1] | `grpc` | +| `OTEL_EXPORTER_OTLP_PROTOCOL` | The OTLP expoter transport protocol. Supported values: `grpc`, `http/protobuf`. [1] | `http/protobuf` | | `OTEL_EXPORTER_ZIPKIN_ENDPOINT` | Zipkin URL. | `http://localhost:8126` | **[1]**: `OTEL_EXPORTER_OTLP_PROTOCOL` remarks: diff --git a/src/OpenTelemetry.ClrProfiler.Managed/Configuration/ConfigurationKeys.cs b/src/OpenTelemetry.ClrProfiler.Managed/Configuration/ConfigurationKeys.cs index 63e2e866f7..0f7dc208f5 100644 --- a/src/OpenTelemetry.ClrProfiler.Managed/Configuration/ConfigurationKeys.cs +++ b/src/OpenTelemetry.ClrProfiler.Managed/Configuration/ConfigurationKeys.cs @@ -22,10 +22,21 @@ public class ConfigurationKeys /// /// Configuration key for the exporter to be used. The Tracer uses it to encode and /// dispatch traces. - /// Default is "Zipkin". + /// Default is "otlp". /// public const string Exporter = "OTEL_EXPORTER"; + /// + /// Configuration key for the otlp protocol to be used. + /// Default is "http/protobuf". + /// + public const string ExporterOtlpProtocol = "OTEL_EXPORTER_OTLP_PROTOCOL"; + + /// + /// Configuration key for the otlp exporter endpoint to be used. + /// + public const string ExporterOtlpEndpoint = "OTEL_EXPORTER_OTLP_ENDPOINT"; + /// /// Configuration key for whether the console exporter is enabled. /// @@ -42,7 +53,7 @@ public class ConfigurationKeys public const string DisabledInstrumentations = "OTEL_DOTNET_TRACER_DISABLED_INSTRUMENTATIONS"; /// - /// Configuration key for colon (:) separated list of plugins repesented by . + /// Configuration key for colon (:) separated list of plugins represented by . /// public const string ProviderPlugins = "OTEL_DOTNET_TRACER_INSTRUMENTATION_PLUGINS"; diff --git a/src/OpenTelemetry.ClrProfiler.Managed/Configuration/EnvironmentConfigurationHelper.cs b/src/OpenTelemetry.ClrProfiler.Managed/Configuration/EnvironmentConfigurationHelper.cs index 4d5abeb8f7..34d70ca0c2 100644 --- a/src/OpenTelemetry.ClrProfiler.Managed/Configuration/EnvironmentConfigurationHelper.cs +++ b/src/OpenTelemetry.ClrProfiler.Managed/Configuration/EnvironmentConfigurationHelper.cs @@ -1,8 +1,9 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; -using System.Reflection; +#if NETCOREAPP3_1 +using OpenTelemetry.Exporter; +#endif using OpenTelemetry.Resources; using OpenTelemetry.Trace; @@ -70,21 +71,32 @@ private static TracerProviderBuilder SetExporter(this TracerProviderBuilder buil break; case "otlp": #if NETCOREAPP3_1 - // Adding the OtlpExporter creates a GrpcChannel. - // This switch must be set before creating a GrpcChannel/HttpClient when calling an insecure gRPC service. - // See: https://docs.microsoft.com/aspnet/core/grpc/troubleshoot#call-insecure-grpc-services-with-net-core-client - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); + if (!settings.OtlpExportProtocol.HasValue || settings.OtlpExportProtocol != OtlpExportProtocol.HttpProtobuf) + { + // Adding the OtlpExporter creates a GrpcChannel. + // This switch must be set before creating a GrpcChannel/HttpClient when calling an insecure gRPC service. + // See: https://docs.microsoft.com/aspnet/core/grpc/troubleshoot#call-insecure-grpc-services-with-net-core-client + AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); + } #endif builder.AddOtlpExporter(options => { - options.ExportProcessorType = ExportProcessorType.Simple; // workaround for https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/issues/290 + if (settings.OtlpExportProtocol.HasValue) + { + options.Protocol = settings.OtlpExportProtocol.Value; + } + + if (settings.OtlpExportEndpoint != null) + { + options.Endpoint = settings.OtlpExportEndpoint; + } }); break; case "": case null: break; default: - throw new ArgumentOutOfRangeException("The exporter name is not recognised"); + throw new FormatException($"The exporter name '{settings.Exporter}' is not recognized"); } return builder; diff --git a/src/OpenTelemetry.ClrProfiler.Managed/Configuration/Settings.cs b/src/OpenTelemetry.ClrProfiler.Managed/Configuration/Settings.cs index 7606383e67..dd513f31a1 100644 --- a/src/OpenTelemetry.ClrProfiler.Managed/Configuration/Settings.cs +++ b/src/OpenTelemetry.ClrProfiler.Managed/Configuration/Settings.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using OpenTelemetry.Exporter; namespace OpenTelemetry.ClrProfiler.Managed.Configuration { @@ -23,7 +24,10 @@ private Settings(IConfigurationSource source) throw new ArgumentNullException(nameof(source)); } - Exporter = source.GetString(ConfigurationKeys.Exporter); + Exporter = source.GetString(ConfigurationKeys.Exporter) ?? "otlp"; + OtlpExportProtocol = GetExporterOtlpProtocol(source); + OtlpExportEndpoint = GetExporterOtlpEndpoint(source, OtlpExportProtocol); + LoadTracerAtStartup = source.GetBool(ConfigurationKeys.LoadTracerAtStartup) ?? true; ConsoleExporterEnabled = source.GetBool(ConfigurationKeys.ConsoleExporterEnabled) ?? true; @@ -89,16 +93,11 @@ private Settings(IConfigurationSource source) } /// - /// Gets or sets a value indicating whether tracing is enabled. + /// Gets a value indicating whether tracing is enabled. /// Default is true. /// /// - public bool TraceEnabled { get; set; } - - /// - /// Gets the version of the service - /// - public string ServiceVersion { get; } + public bool TraceEnabled { get; } /// /// Gets a value indicating whether the tracer should be loaded by the profiler. Default is true. @@ -111,14 +110,16 @@ private Settings(IConfigurationSource source) public string Exporter { get; } /// - /// Gets jaeger exporter agent host. + /// Gets the the OTLP transport protocol. Supported values: Grpc and HttpProtobuf. /// - public string JaegerExporterAgentHost { get; } + public OtlpExportProtocol? OtlpExportProtocol { get; } /// - /// Gets jaeger exporter agent port. + /// Gets the the OTLP exporter endpoint. + /// Will be removed when https://github.com/open-telemetry/opentelemetry-dotnet/pull/2868 is released. /// - public int JaegerExporterAgentPort { get; } + // TODO: To be removed when https://github.com/open-telemetry/opentelemetry-dotnet/pull/2868 is released. + public Uri OtlpExportEndpoint { get; } /// /// Gets a value indicating whether the console exporter is enabled. @@ -131,12 +132,12 @@ private Settings(IConfigurationSource source) public IList EnabledInstrumentations { get; } /// - /// Gets the list of plugins repesented by . + /// Gets the list of plugins represented by . /// public IList TracerPlugins { get; } = new List(); /// - /// Gets the list of activitysources to be added to the tracer at the startup. + /// Gets the list of activity sources to be added to the tracer at the startup. /// public IList ActivitySources { get; } = new List { "OpenTelemetry.ClrProfiler.*" }; @@ -164,5 +165,35 @@ internal static Settings FromDefaultSources() return new Settings(configurationSource); } + + private static OtlpExportProtocol? GetExporterOtlpProtocol(IConfigurationSource source) + { + // the defualt in SDK is grpc. http/protobuf should be default for our purposes + var exporterOtlpProtocol = source.GetString(ConfigurationKeys.ExporterOtlpProtocol); + + if (string.IsNullOrEmpty(exporterOtlpProtocol) || exporterOtlpProtocol == "http/protobuf") + { + // override settings only for http/protobuf + // the second part of the condition is needed to override default endpoint as long as https://github.com/open-telemetry/opentelemetry-dotnet/pull/2868 is not fixed + return OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf; + } + + // null value here means that it will be handled by OTEL .NET SDK + return null; + } + + private static Uri GetExporterOtlpEndpoint(IConfigurationSource source, OtlpExportProtocol? otlpExportProtocol) + { + var exporterOtlpEndpoint = source.GetString(ConfigurationKeys.ExporterOtlpEndpoint); + + if (otlpExportProtocol == OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf && string.IsNullOrWhiteSpace(exporterOtlpEndpoint)) + { + // override endpoint only for otlp over http/protobuf + return new Uri("http://localhost:4318/v1/traces"); + } + + // null value here means that it will be handled by OTEL .NET SDK + return null; + } } } diff --git a/src/OpenTelemetry.ClrProfiler.Managed/Properties/AssemblyInfo.cs b/src/OpenTelemetry.ClrProfiler.Managed/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..574f638662 --- /dev/null +++ b/src/OpenTelemetry.ClrProfiler.Managed/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("OpenTelemetry.ClrProfiler.Managed.Tests")] diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 2071bed771..93e5f3f915 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -15,7 +15,14 @@ - + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/test/OpenTelemetry.ClrProfiler.Managed.Bootstrapping.Tests/OpenTelemetry.ClrProfiler.Managed.Bootstrapping.Tests.csproj b/test/OpenTelemetry.ClrProfiler.Managed.Bootstrapping.Tests/OpenTelemetry.ClrProfiler.Managed.Bootstrapping.Tests.csproj index 1a410582d1..889ff0d2e8 100644 --- a/test/OpenTelemetry.ClrProfiler.Managed.Bootstrapping.Tests/OpenTelemetry.ClrProfiler.Managed.Bootstrapping.Tests.csproj +++ b/test/OpenTelemetry.ClrProfiler.Managed.Bootstrapping.Tests/OpenTelemetry.ClrProfiler.Managed.Bootstrapping.Tests.csproj @@ -1,18 +1,4 @@ - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - diff --git a/test/OpenTelemetry.ClrProfiler.Managed.Loader.Tests/OpenTelemetry.ClrProfiler.Managed.Loader.Tests.csproj b/test/OpenTelemetry.ClrProfiler.Managed.Loader.Tests/OpenTelemetry.ClrProfiler.Managed.Loader.Tests.csproj index 28c5e4e10b..c667743e56 100644 --- a/test/OpenTelemetry.ClrProfiler.Managed.Loader.Tests/OpenTelemetry.ClrProfiler.Managed.Loader.Tests.csproj +++ b/test/OpenTelemetry.ClrProfiler.Managed.Loader.Tests/OpenTelemetry.ClrProfiler.Managed.Loader.Tests.csproj @@ -1,18 +1,4 @@  - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - diff --git a/test/OpenTelemetry.ClrProfiler.Managed.Tests/Configuration/SettingsTests.cs b/test/OpenTelemetry.ClrProfiler.Managed.Tests/Configuration/SettingsTests.cs new file mode 100644 index 0000000000..31d22dfda4 --- /dev/null +++ b/test/OpenTelemetry.ClrProfiler.Managed.Tests/Configuration/SettingsTests.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using FluentAssertions; +using FluentAssertions.Execution; +using OpenTelemetry.ClrProfiler.Managed.Configuration; +using OpenTelemetry.Exporter; +using Xunit; + +namespace OpenTelemetry.ClrProfiler.Managed.Tests.Configuration +{ + public class SettingsTests : IDisposable + { + public SettingsTests() + { + ClearEnvVars(); + } + + public void Dispose() + { + ClearEnvVars(); + } + + [Fact] + public void FromDefaultSources_DefaultValues() + { + var settings = Settings.FromDefaultSources(); + + using (new AssertionScope()) + { + settings.TraceEnabled.Should().BeTrue(); + settings.LoadTracerAtStartup.Should().BeTrue(); + settings.Exporter.Should().Be("otlp"); + settings.OtlpExportProtocol.Should().Be(OtlpExportProtocol.HttpProtobuf); + settings.OtlpExportEndpoint.Should().Be(new Uri("http://localhost:4318/v1/traces")); + settings.ConsoleExporterEnabled.Should().BeTrue(); + settings.EnabledInstrumentations.Should().BeEmpty(); + settings.TracerPlugins.Should().BeEmpty(); + settings.ActivitySources.Should().BeEquivalentTo(new List { "OpenTelemetry.ClrProfiler.*" }); + settings.LegacySources.Should().BeEmpty(); + settings.Integrations.Should().NotBeNull(); + } + } + + [Theory] + [InlineData("", OtlpExportProtocol.HttpProtobuf, "http://localhost:4318/v1/traces")] + [InlineData(null, OtlpExportProtocol.HttpProtobuf, "http://localhost:4318/v1/traces")] + [InlineData("http/protobuf", OtlpExportProtocol.HttpProtobuf, "http://localhost:4318/v1/traces")] + [InlineData("grpc", null, null)] + [InlineData("nonExistingProtocol", null, null)] + + public void FromDefaultSources_OtlpExporterPropertiesDependsOnCorrespondingEnvVariables(string otlpProtocol, OtlpExportProtocol? expectedOtlpExportProtocol, string expectedOtlpExportEndpoint) + { + Environment.SetEnvironmentVariable(ConfigurationKeys.ExporterOtlpProtocol, otlpProtocol); + + var settings = Settings.FromDefaultSources(); + + using (new AssertionScope()) + { + // null values for expected data will be handled by OTel .NET SDK + settings.OtlpExportProtocol.Should().Be(expectedOtlpExportProtocol); + settings.OtlpExportEndpoint.Should().Be(expectedOtlpExportEndpoint != null ? new Uri(expectedOtlpExportEndpoint) : null); + } + } + + [Theory] + [InlineData("")] + [InlineData(null)] + [InlineData("http/protobuf")] + [InlineData("grpc")] + [InlineData("nonExistingProtocol")] + public void FromDefaultSources_OtlpExportEndpointIsNullWhenCorrespondingEnvVarIsSet(string otlpProtocol) + { + Environment.SetEnvironmentVariable(ConfigurationKeys.ExporterOtlpProtocol, otlpProtocol); + Environment.SetEnvironmentVariable(ConfigurationKeys.ExporterOtlpEndpoint, "http://customurl:1234"); + + var settings = Settings.FromDefaultSources(); + + settings.OtlpExportEndpoint.Should().BeNull("leaving as null as SDK will handle it"); + } + + private static void ClearEnvVars() + { + Environment.SetEnvironmentVariable(ConfigurationKeys.ExporterOtlpProtocol, null); + Environment.SetEnvironmentVariable(ConfigurationKeys.ExporterOtlpEndpoint, null); + } + } +} diff --git a/test/OpenTelemetry.ClrProfiler.Managed.Tests/OpenTelemetry.ClrProfiler.Managed.Tests.csproj b/test/OpenTelemetry.ClrProfiler.Managed.Tests/OpenTelemetry.ClrProfiler.Managed.Tests.csproj new file mode 100644 index 0000000000..1e06f8e1ed --- /dev/null +++ b/test/OpenTelemetry.ClrProfiler.Managed.Tests/OpenTelemetry.ClrProfiler.Managed.Tests.csproj @@ -0,0 +1,7 @@ + + + + + + + diff --git a/test/integration-tests/IntegrationTests.GraphQL/IntegrationTests.GraphQL.csproj b/test/integration-tests/IntegrationTests.GraphQL/IntegrationTests.GraphQL.csproj index b3c7f540e3..9c81dc287d 100644 --- a/test/integration-tests/IntegrationTests.GraphQL/IntegrationTests.GraphQL.csproj +++ b/test/integration-tests/IntegrationTests.GraphQL/IntegrationTests.GraphQL.csproj @@ -1,17 +1,5 @@  - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - diff --git a/test/integration-tests/IntegrationTests.Helpers/IntegrationTests.Helpers.csproj b/test/integration-tests/IntegrationTests.Helpers/IntegrationTests.Helpers.csproj index 9326efeef4..3167138a9f 100644 --- a/test/integration-tests/IntegrationTests.Helpers/IntegrationTests.Helpers.csproj +++ b/test/integration-tests/IntegrationTests.Helpers/IntegrationTests.Helpers.csproj @@ -7,7 +7,6 @@ - diff --git a/test/integration-tests/IntegrationTests.MongoDB/IntegrationTests.MongoDB.csproj b/test/integration-tests/IntegrationTests.MongoDB/IntegrationTests.MongoDB.csproj index 22966df2bd..bccb9c4490 100644 --- a/test/integration-tests/IntegrationTests.MongoDB/IntegrationTests.MongoDB.csproj +++ b/test/integration-tests/IntegrationTests.MongoDB/IntegrationTests.MongoDB.csproj @@ -2,15 +2,6 @@ - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - diff --git a/test/integration-tests/IntegrationTests.StartupHook/IntegrationTests.StartupHook.csproj b/test/integration-tests/IntegrationTests.StartupHook/IntegrationTests.StartupHook.csproj index d1705f3a32..6696c2a582 100644 --- a/test/integration-tests/IntegrationTests.StartupHook/IntegrationTests.StartupHook.csproj +++ b/test/integration-tests/IntegrationTests.StartupHook/IntegrationTests.StartupHook.csproj @@ -6,15 +6,6 @@ - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all -