void Application_Start(object sender, EventArgs e)
            {
                string projectId = "[Google Cloud Platform project ID]";

                // Trace a sampling of incoming Http requests.
                CloudTrace.Initialize(projectId, this);
            }
            public override void Init()
            {
                base.Init();
                string projectId = "[Google Cloud Platform project ID]";

                // Trace a sampling of incoming Http requests.
                CloudTrace.Initialize(this, projectId);
            }
Exemplo n.º 3
0
 public override void Init()
 {
     base.Init();
     CloudTrace.Initialize(
         this,
         Environment.GetEnvironmentVariable("GOOGLE_PROJECT_ID"),
         TraceOptions.Create(1_000_000, BufferOptions.NoBuffer()));
 }
Exemplo n.º 4
0
        public override void Init()
        {
            base.Init();
            var configurationProvider = new ConfigurationProvider();

            // Trace a sampling of incoming Http requests.
            CloudTrace.Initialize(this, configurationProvider.ProjectId);
        }
        // End sample

        public void TraceHelloWorld()
        {
            // Sample: UseTracer
            // Manually trace a specific operation.
            CloudTrace.GetCurrentTracer().StartSpan("hello-world");
            Console.Out.WriteLine("Hello, World!");
            CloudTrace.GetCurrentTracer().EndSpan();
            // End sample
        }
Exemplo n.º 6
0
        public async Task <string> TraceOutgoing(string id)
        {
            string message = EntryData.GetMessage(nameof(TraceOutgoing), id);

            using (CloudTrace.Tracer.StartSpan(message))
                using (HttpClient httpClient = new HttpClient(CloudTrace.CreateTracingHttpMessageHandler()))
                {
                    await httpClient.GetAsync("https://google.com/");
                }
            return(message);
        }
        public async Task <HttpResponseMessage> TraceOutgoing()
        {
            // Sample: TraceOutgoing
            // Add a handler to trace outgoing requests and to propagate the trace header.
            var traceHeaderHandler = CloudTrace.CreateTracingHttpMessageHandler();

            using (var httpClient = new HttpClient(traceHeaderHandler))
            {
                return(await httpClient.GetAsync("https://weather.com/"));
            }
            // End sample
        }
Exemplo n.º 8
0
        public void Trace()
        {
            using (var cloudTrace = CloudTrace.InitializeInternal(new HttpApplication(), _projectId, _noBuffer))
            {
                cloudTrace.BeginRequest(null, null);
                cloudTrace.EndRequest(null, null);
            }

            var trace = _polling.GetTrace($"/{_testId}", _startTime);

            Assert.NotNull(trace);
            Assert.Single(trace.Spans);
        }
Exemplo n.º 9
0
        public void No_Trace()
        {
            var predicate = TraceDecisionPredicate.Create((req) => false);

            using (var cloudTrace = CloudTrace.InitializeInternal(new HttpApplication(),
                                                                  projectId: _projectId, options: _noBuffer, traceFallbackPredicate: predicate))
            {
                cloudTrace.BeginRequest(null, null);
                cloudTrace.EndRequest(null, null);
            }

            var trace = _polling.GetTrace($"/{_testId}", _startTime, false);

            Assert.Null(trace);
        }
Exemplo n.º 10
0
        public void Trace_Multiple_Spans()
        {
            using (var cloudTrace = CloudTrace.InitializeInternal(new HttpApplication(), _projectId, _noBuffer))
            {
                cloudTrace.BeginRequest(null, null);
                using (CloudTrace.Tracer.StartSpan("/another-trace"))
                {
                    Thread.Sleep(TimeSpan.FromMilliseconds(10));
                }
                cloudTrace.EndRequest(null, null);
            }

            var trace = _polling.GetTrace($"/{_testId}", _startTime);

            Assert.NotNull(trace);
            Assert.Equal(2, trace.Spans.Count);
        }
Exemplo n.º 11
0
        // [START configure_services_trace]
        public override void Init()
        {
            // [START_EXCLUDE]
            string projectId = ConfigurationManager.AppSettings["projectId"];

            // Confirm that projectId has been changed from placeholder value.
            if (projectId == ("YOUR-PROJECT-ID"))
            {
                throw new Exception("Update Web.config and replace "
                                    + "YOUR-PROJECT-ID with your project id, and recompile.");
            }
            // [END_EXCLUDE]
            base.Init();
            TraceConfiguration traceConfig = TraceConfiguration
                                             .Create(bufferOptions: BufferOptions.NoBuffer());

            CloudTrace.Initialize(this, projectId, traceConfig);
        }
Exemplo n.º 12
0
 public override void Init()
 {
     base.Init();
     CloudTrace.Initialize(this, "cloudsharptest", TraceOptions.Create(1_000_000, BufferOptions.NoBuffer()));
 }
Exemplo n.º 13
0
 public override void Init()
 {
     base.Init();
     CloudTrace.Initialize("cloud-sharp-work", this);
 }