public string GetTestApplicationExecutionSource() { string executor; if (_testApplicationDirectory.Contains("aspnet")) { executor = $"C:\\Program Files{(Environment.Is64BitProcess ? string.Empty : " (x86)")}\\IIS Express\\iisexpress.exe"; } else if (IsCoreClr()) { executor = EnvironmentTools.IsWindows() ? "dotnet.exe" : "dotnet"; } else { var appFileName = $"{FullTestApplicationName}.exe"; executor = Path.Combine(GetTestApplicationApplicationOutputDirectory(), appFileName); if (!File.Exists(executor)) { throw new Exception($"Unable to find executing assembly at {executor}"); } } return(executor); }
public string GetProfilerPath() { if (_profilerFileLocation != null) { return(_profilerFileLocation); } string extension = EnvironmentTools.GetOS() switch { "win" => "dll", "linux" => "so", "osx" => "dylib", _ => throw new PlatformNotSupportedException() }; string fileName = $"OpenTelemetry.AutoInstrumentation.Native.{extension}"; string nukeOutput = GetNukeBuildOutput(); string profilerPath = EnvironmentTools.IsWindows() ? Path.Combine(nukeOutput, $"win-{EnvironmentTools.GetPlatform().ToLower()}", fileName) : Path.Combine(nukeOutput, fileName); if (File.Exists(profilerPath)) { _profilerFileLocation = profilerPath; _output?.WriteLine($"Found profiler at {_profilerFileLocation}."); return(_profilerFileLocation); } throw new Exception($"Unable to find profiler at: {profilerPath}"); }
public void NoExceptions() { if (EnvironmentTools.IsWindows()) { Output.WriteLine("Ignored for Windows"); return; } CheckForSmoke(shouldDeserializeTraces: false); }
private async Task <TestcontainersContainer> LaunchMongoContainerAsync(int port) { var waitOS = EnvironmentTools.IsWindows() ? Wait.ForWindowsContainer() : Wait.ForUnixContainer(); var mongoContainersBuilder = new TestcontainersBuilder <TestcontainersContainer>() .WithImage(MongoDbImage) .WithName($"mongo-db-{port}") .WithPortBinding(port, MongoDbPort) .WithWaitStrategy(waitOS.UntilPortIsAvailable(MongoDbPort)); var container = mongoContainersBuilder.Build(); await container.StartAsync(); return(container); }
public async Task Http_Headers_Contain_ContainerId() { string expectedContainedId = ContainerMetadata.GetContainerId(); string actualContainerId = null; var agentPort = TcpPortProvider.GetOpenPort(); using (var agent = new MockTracerAgent(agentPort)) { agent.RequestReceived += (sender, args) => { actualContainerId = args.Value.Request.Headers[AgentHttpHeaderNames.ContainerId]; }; var settings = new TracerSettings { Exporter = new ExporterSettings() { AgentUri = new Uri($"http://localhost:{agent.Port}"), } }; var tracer = new Tracer(settings, agentWriter: null, sampler: null, scopeManager: null, statsd: null); using (var scope = tracer.StartActive("operationName")) { scope.Span.ResourceName = "resourceName"; } await tracer.FlushAsync(); var spans = agent.WaitForSpans(1); Assert.Equal(1, spans.Count); Assert.Equal(expectedContainedId, actualContainerId); if (EnvironmentTools.IsWindows()) { // we don't extract the containerId on Windows (yet?) Assert.Null(actualContainerId); } } }