Esempio n. 1
0
        public async Task FlushTwice()
        {
            var w = new CIAgentWriter(_api.Object);
            await w.FlushAndCloseAsync();

            await w.FlushAndCloseAsync();
        }
Esempio n. 2
0
        public CIAgentWriterTests()
        {
            var tracer = new Mock <IDatadogTracer>();

            tracer.Setup(x => x.DefaultServiceName).Returns("Default");
            _settings = new Configuration.ImmutableTracerSettings(Ci.Configuration.CIVisibilitySettings.FromDefaultSources().TracerSettings);

            _api           = new Mock <IApi>();
            _ciAgentWriter = new CIAgentWriter(_api.Object);
        }
Esempio n. 3
0
        public static async Task <bool> CheckAgentConnectionAsync(string agentUrl)
        {
            var env = new NameValueCollection();

            if (!string.IsNullOrWhiteSpace(agentUrl))
            {
                env["DD_TRACE_AGENT_URL"] = agentUrl;
            }

            var globalSettings = GlobalSettings.CreateDefaultConfigurationSource();

            globalSettings.Add(new NameValueConfigurationSource(env));
            var tracerSettings = new TracerSettings(globalSettings);
            var agentWriter    = new CIAgentWriter(tracerSettings.Build(), new CISampler());

            try
            {
                if (!await agentWriter.Ping().ConfigureAwait(false))
                {
                    WriteError($"Error connecting to the Datadog Agent at {tracerSettings.Exporter.AgentUri}.");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                WriteError($"Error connecting to the Datadog Agent at {tracerSettings.Exporter.AgentUri}.");
                AnsiConsole.WriteException(ex);
                return(false);
            }
            finally
            {
                await agentWriter.FlushAndCloseAsync().ConfigureAwait(false);
            }

            return(true);
        }