public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddAuthentication(AzureADDefaults.AuthenticationScheme) .AddAzureAD(options => Configuration.Bind("AzureAd", options)); services.AddMvc(options => { var policy = new AuthorizationPolicyBuilder() .RequireAuthenticatedUser() .Build(); options.Filters.Add(new AuthorizeFilter(policy)); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); var loggerFactory = new LoggerFactory().AddConsole(); var tracer = JaegerTracer.CreateTracer("web-app", loggerFactory); services.AddOpenTracing(); GlobalTracer.Register(tracer); services.AddHttpClient <IDoughnutClient, DoughnutClient>(); services.AddHttpClient <IUserClient, UserClient>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); var loggerFactory = new LoggerFactory().AddConsole(); var tracer = JaegerTracer.CreateTracer("doughnuts-api", loggerFactory); services.AddOpenTracing(); GlobalTracer.Register(tracer); }
public void ConfigureServices(IServiceCollection services) { services.AddDbContext <UserContext>(opt => opt.UseSqlite("Data Source=Users.db")); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); var loggerFactory = new LoggerFactory().AddConsole(); var logger = loggerFactory.CreateLogger <Program>(); var tracer = JaegerTracer.CreateTracer("users-api", loggerFactory); services.AddOpenTracing(); GlobalTracer.Register(tracer); }
public static void Bootstrap(bool useOpenTracingCollector = false, IEpsagonConfiguration configuration = null) { var levelSwitch = new LoggingLevelSwitch(LogEventLevel.Error); if ((Environment.GetEnvironmentVariable("EPSAGON_DEBUG") ?? "").ToLower() == "true") { levelSwitch.MinimumLevel = LogEventLevel.Debug; } var loggerConfig = new LoggerConfiguration() .MinimumLevel.ControlledBy(levelSwitch) .Enrich.FromLogContext() .WriteTo.Console(); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { loggerConfig.WriteTo.EventLog("Epsagon"); } var logConfig = configuration?.LogFile ?? Environment.GetEnvironmentVariable("EPSAGON_LOG_FILE"); if (!string.IsNullOrWhiteSpace(logConfig)) { loggerConfig.WriteTo.File(logConfig); } Log.Logger = loggerConfig.CreateLogger(); if ((Environment.GetEnvironmentVariable("DISABLE_EPSAGON") ?? "").ToUpper() != "TRUE") { if (configuration != null) { Utils.RegisterConfiguration(configuration); } else { Utils.RegisterConfiguration(LoadConfiguration()); } CustomizePipeline(); // Use either legacy tracer or opentracing tracer if (useOpenTracingCollector) { Utils.DebugLogIfEnabled("remote"); JaegerTracer.CreateRemoteTracer(); } else { JaegerTracer.CreateTracer(); } Utils.DebugLogIfEnabled("finished bootstraping epsagon"); } }
static void Main(string[] args) { var loggerFactory = new LoggerFactory().AddConsole(); var logger = loggerFactory.CreateLogger <Program>(); logger.LogInformation("Starting app"); var tracer = JaegerTracer.CreateTracer("console-app", loggerFactory); GlobalTracer.Register(tracer); var doughnutCollection = DoughnutCollectionHelper.GetTracingMongoClient(); doughnutCollection.InsertOne(new Doughnut { Price = 1, Color = "Red" }); using (var scope = tracer.BuildSpan("custom-span").StartActive(finishSpanOnDispose: true)) { try { var doughnuts = doughnutCollection.Find(a => true).ToList(); doughnutCollection.FindOneAndDelete(a => a.Id == ObjectId.GenerateNewId()); throw new Exception("Some exception"); } catch (Exception e) { scope.Span.SetTag(Tags.Error, true); scope.Span.Log(new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("message", e.Message), new KeyValuePair <string, object>("stack.trace", e.StackTrace), new KeyValuePair <string, object>("source", e.Source) }); } } System.Console.ReadKey(); }
public static void Bootstrap() { var levelSwitch = new LoggingLevelSwitch(LogEventLevel.Error); if ((System.Environment.GetEnvironmentVariable("EPSAGON_DEBUG") ?? "").ToLower() == "true") { levelSwitch.MinimumLevel = LogEventLevel.Debug; } Log.Logger = new LoggerConfiguration() .MinimumLevel.ControlledBy(levelSwitch) .Enrich.FromLogContext() .WriteTo.Console() .CreateLogger(); if ((Environment.GetEnvironmentVariable("DISABLE_EPSAGON") ?? "").ToUpper() != "TRUE") { JaegerTracer.CreateTracer(); CustomizePipeline(); Utils.RegisterConfiguration(LoadConfiguration()); Utils.DebugLogIfEnabled("finished bootstraping epsagon"); } }