public OpenTracingSendTracesToAgent() { var uri = new Uri("http://localhost:8126"); _httpRecorder = new RecordHttpHandler(); _tracer = OpenTracingTracerFactory.CreateTracer(uri, null, _httpRecorder); }
public static IServiceCollection AddDataDogTracer(this IServiceCollection services) { ITracer tracer = OpenTracingTracerFactory.WrapTracer(Datadog.Trace.Tracer.Instance); GlobalTracer.Register(tracer); services.TryAddSingleton(tracer); return(services); }
public static void ConfigureDataDogTracing(IServiceCollection services) { // Add DataDog Tracing services.AddSingleton <ITracer>(sp => { return(OpenTracingTracerFactory.CreateTracer().WithScopeManager(new ActorScopeManager())); }); }
public void SetDefaultServiceName() { ITracer tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: "DefaultServiceName"); var scope = tracer.BuildSpan("Operation") .StartActive(); var otSpan = (OpenTracingSpan)scope.Span; var ddSpan = otSpan.Span; Assert.Equal("DefaultServiceName", ddSpan.ServiceName); }
public void OverrideDefaultServiceName_SetTag() { ITracer tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: "DefaultServiceName"); var scope = tracer.BuildSpan("Operation") .StartActive(); scope.Span.SetTag(DatadogTags.ServiceName, "MyAwesomeService"); var otSpan = (OpenTracingSpan)scope.Span; var ddSpan = otSpan.Span; Assert.Equal("MyAwesomeService", ddSpan.ServiceName); }
public void ConfigureServices(IServiceCollection services) { services.AddMvc(o => { o.Filters.Add(new ModelAttributeValidationFilter()); }) .SetCompatibilityVersion(CompatibilityVersion.Latest); // Demo data creation services services.AddSingleton <IDemoDataService, DemoDataService>(); // Open tracing... services.AddSingleton(OpenTracingTracerFactory.CreateTracer()); services.AddSingleton <IConfigurationDecorationService>(EnvironmentVariableConfigurationDecorationService.Instance); services.AddSingleton <SqlServerDbProvider>(); services.AddSingleton <MySqlDbProvider>(); services.AddSingleton <IDbFactory>(s => new SimpleDbFactory(GetDbProvidersMap(s))); services.AddSingleton <IRedisClientsManager>( s => new RedisManagerPool( EnvironmentVariableConfigurationDecorationService.Instance .Get("REDIS_HOST") .DefaultIfNullOrEmpty(_configuration.GetSection("DbConnection.Redis")?.Value) .DefaultIfNullOrEmpty("localhost:6379"), new RedisPoolConfig { MaxPoolSize = 150 })); // Repos services.AddSingleton <SqlUserRepository>(); services.AddSingleton <SqlOrderRepository>(); services.AddSingleton <SqlOrderItemRepository>(); services.AddSingleton <MySqlProductRepository>(); // Manual trace the user repo... services.AddSingleton <IUserRepository, ManualTracedSqlUserRepository>(s => new ManualTracedSqlUserRepository(new CachedSqlUserRepository(s.GetRequiredService <IRedisClientsManager>(), s.GetRequiredService <SqlUserRepository>()))); services.AddSingleton <IOrderRepository, CachedSqlOrderRepository>(s => new CachedSqlOrderRepository(s.GetRequiredService <IRedisClientsManager>(), s.GetRequiredService <SqlOrderRepository>())); services.AddSingleton <IOrderItemRepository, CachedSqlOrderItemRepository>(s => new CachedSqlOrderItemRepository(s.GetRequiredService <IRedisClientsManager>(), s.GetRequiredService <SqlOrderItemRepository>())); // Open trace the product repo... services.AddSingleton <IProductRepository, OpenTracedMySqlProductRepository>(s => new OpenTracedMySqlProductRepository(s.GetRequiredService <ITracer>(), new CachedMySqlProductRepository(s.GetRequiredService <IRedisClientsManager>(), s.GetRequiredService <MySqlProductRepository>()))); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Create an OpenTracing ITracer with the default setting OpenTracing.ITracer tracer = OpenTracingTracerFactory.CreateTracer(); // Use the tracer with ASP.NET Core dependency injection services.AddSingleton <ITracer>(tracer); // Use the tracer with OpenTracing.GlobalTracer.Instance GlobalTracer.Register(tracer); services.AddControllersWithViews(); services.AddDbContext <ProductsContext>(options => options.UseSqlServer(Configuration.GetConnectionString("ProductsContext"))); }
public void Parent_OverrideDefaultServiceName_WithTag() { ITracer tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: "DefaultServiceName"); var parentScope = tracer.BuildSpan("ParentOperation") .WithTag(DatadogTags.ServiceName, "MyAwesomeService") .StartActive(); var childScope = tracer.BuildSpan("ChildOperation") .AsChildOf(parentScope.Span) .StartActive(); var otSpan = (OpenTracingSpan)childScope.Span; var ddSpan = otSpan.Span; Assert.Equal("MyAwesomeService", ddSpan.ServiceName); }
public void Parent_OverrideDefaultServiceName_SetTag() { const string defaultServiceName = "DefaultServiceName"; var tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: defaultServiceName); var parentScope = tracer.BuildSpan("ParentOperation") .StartActive(); parentScope.Span.SetTag(DatadogTags.ServiceName, "MyAwesomeService"); var childScope = tracer.BuildSpan("ChildOperation") .AsChildOf(parentScope.Span) .StartActive(); Assert.Equal("MyAwesomeService", ((OpenTracingSpan)parentScope.Span).Span.ServiceName); Assert.NotEqual("MyAwesomeService", ((OpenTracingSpan)childScope.Span).Span.ServiceName); Assert.Equal(defaultServiceName, ((OpenTracingSpan)childScope.Span).Span.ServiceName); }
public void RegisteredAsGlobalTracer_OnlyOnce() { Assert.False(OpenTracingTracerFactory.RegisterGlobalTracer(_datadogTracer)); }