Пример #1
0
 public Tracer(IApmLogger logger, Service service, IPayloadSender payloadSender, IConfigurationReader configurationReader)
 {
     _logger  = logger?.Scoped(nameof(Tracer));
     _service = service;
     _sender  = payloadSender;
     Sampler  = new Sampler(configurationReader.TransactionSampleRate);
 }
Пример #2
0
        public async Task Run(
            [BlobTrigger("pictures/{name}", Connection = "AzureWebJobsStorage")]
            Stream picture,
            [CosmosDB(
                 databaseName: Constants.CosmosDbDatabaseName,
                 collectionName: Constants.CosmosDbFacesCollectionName,
                 ConnectionStringSetting = Constants.CosmosDbConnectionName)]
            IAsyncCollector <JObject> facesCollection,
            string name,
            ILogger logger)
        {
            using var scopedLogger = new ScopedLogger(logger, $"C# Blob trigger function analyzing the new {name} image and store results");
            try
            {
                var analysisResult = await _pictureAnalyzer.ProcessAsync(picture);

                var postedOn = _postedOnDateProvider.Get();

                var newFaceDocument = JObject.FromObject(
                    new FacesAnalysisResult
                {
                    PostedOn    = postedOn,
                    Descriptors = JArray.Parse(analysisResult)
                });
                await facesCollection.AddAsync(newFaceDocument);
            }
            catch (Exception ex)
            {
                logger.LogError(null, ex);
            }
        }
Пример #3
0
 public Transaction(IApmLogger logger, string name, string type, IPayloadSender sender)
 {
     _logger = logger?.Scoped(nameof(Transaction));
     _sender = sender;
     Start   = DateTimeOffset.UtcNow;
     Name    = name;
     Type    = type;
     Id      = Guid.NewGuid();
 }
Пример #4
0
        public async Task SaveAsync(Stream picture)
        {
            using var scopedLogger = new ScopedLogger(_logger, "Uploading picture to blob storage.");

            var blobContainerClient = _blobServiceClient.GetBlobContainerClient(_picturesStorageOptions.ContainerName);
            await blobContainerClient.CreateIfNotExistsAsync();

            await blobContainerClient.UploadBlobAsync(Guid.NewGuid().ToString(), picture);
        }
Пример #5
0
 public static IActionResult Run(
     [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req,
     [CosmosDB(
          databaseName: Constants.CosmosDbDatabaseName,
          collectionName: Constants.CosmosDbHappinessPerDayCollectionName,
          ConnectionStringSetting = Constants.CosmosDbConnectionName,
          SqlQuery = AllHappinessPerDayQuery)]
     IEnumerable <Document> happinessPerDayCollection,
     ILogger logger)
 {
     using var scopedLogger = new ScopedLogger(logger, "C# Http trigger function fetching all documents from happiness per day projection");
     return(new OkObjectResult(happinessPerDayCollection));
 }
Пример #6
0
 public Tracer(
     IApmLogger logger,
     Service service,
     IPayloadSender payloadSender,
     IConfigSnapshotProvider configProvider,
     ICurrentExecutionSegmentsContainer currentExecutionSegmentsContainer
     )
 {
     _logger         = logger?.Scoped(nameof(Tracer));
     _service        = service;
     _sender         = payloadSender.ThrowIfArgumentNull(nameof(payloadSender));
     _configProvider = configProvider.ThrowIfArgumentNull(nameof(configProvider));
     CurrentExecutionSegmentsContainer = currentExecutionSegmentsContainer.ThrowIfArgumentNull(nameof(currentExecutionSegmentsContainer));
 }
Пример #7
0
 public Tracer(
     IApmLogger logger,
     Service service,
     IPayloadSender payloadSender,
     IConfigurationReader configurationReader,
     ICurrentExecutionSegmentsContainer currentExecutionSegmentsContainer
     )
 {
     _logger              = logger?.Scoped(nameof(Tracer));
     _service             = service;
     _sender              = payloadSender.ThrowIfArgumentNull(nameof(payloadSender));
     _configurationReader = configurationReader.ThrowIfArgumentNull(nameof(configurationReader));
     Sampler              = new Sampler(configurationReader.TransactionSampleRate);
     CurrentExecutionSegmentsContainer = currentExecutionSegmentsContainer.ThrowIfArgumentNull(nameof(currentExecutionSegmentsContainer));
 }
Пример #8
0
 public Tracer(
     IApmLogger logger,
     Service service,
     IPayloadSender payloadSender,
     IConfigurationSnapshotProvider configurationProvider,
     ICurrentExecutionSegmentsContainer currentExecutionSegmentsContainer,
     IApmServerInfo apmServerInfo,
     BreakdownMetricsProvider breakdownMetricsProvider
     )
 {
     _logger  = logger?.Scoped(nameof(Tracer));
     _service = service;
     _sender  = payloadSender.ThrowIfArgumentNull(nameof(payloadSender));
     _configurationProvider            = configurationProvider.ThrowIfArgumentNull(nameof(configurationProvider));
     CurrentExecutionSegmentsContainer = currentExecutionSegmentsContainer.ThrowIfArgumentNull(nameof(currentExecutionSegmentsContainer));
     DbSpanCommon              = new DbSpanCommon(logger);
     _apmServerInfo            = apmServerInfo;
     _breakdownMetricsProvider = breakdownMetricsProvider;
 }
 public async Task Run(
     [CosmosDBTrigger(
          databaseName: Constants.CosmosDbDatabaseName,
          collectionName: Constants.CosmosDbFacesCollectionName,
          ConnectionStringSetting = Constants.CosmosDbConnectionName,
          LeaseCollectionName = Constants.CosmosLeaseCollectionName,
          CreateLeaseCollectionIfNotExists = true)]
     IReadOnlyList <Document> changedFaces,
     ILogger logger)
 {
     using var scopedLogger = new ScopedLogger(logger, "C# CosmosDB trigger function processed changes feed and updating happiness per day projection.");
     try
     {
         await _happinessPerDayProjectionService.UpdateAsync(changedFaces);
     }
     catch (Exception ex)
     {
         logger.LogError(null, ex);
     }
 }
 protected HttpDiagnosticListenerImplBase(IApmAgent agent)
 {
     _agent = agent;
     Logger = _agent.Logger?.Scoped("HttpDiagnosticListenerImplBase");
 }
Пример #11
0
 internal DiagnosticInitializer(IApmLogger baseLogger, IEnumerable <IDiagnosticListener> listeners)
 {
     _logger    = baseLogger.Scoped(nameof(DiagnosticInitializer));
     _listeners = listeners;
 }
Пример #12
0
 public Tracer(IApmLogger logger, Service service, IPayloadSender payloadSender)
 {
     _logger  = logger?.Scoped(nameof(Tracer));
     _service = service;
     _sender  = payloadSender;
 }
 protected HttpDiagnosticListenerImplBase(IApmAgent components)
 {
     _logger = components.Logger?.Scoped("HttpDiagnosticListenerImplBase");
     _configurationReader = components.ConfigurationReader;
 }
 internal DiagnosticInitializer(IApmAgent agent, IEnumerable <IDiagnosticListener> listeners)
 {
     _agent     = agent as ApmAgent;
     _logger    = agent.Logger.Scoped(nameof(DiagnosticInitializer));
     _listeners = listeners;
 }
 internal DiagnosticInitializer(IApmAgent agent, IDiagnosticListener listener)
 {
     _agent    = agent as ApmAgent;
     _logger   = agent.Logger.Scoped(nameof(DiagnosticInitializer));
     _listener = listener;
 }
 public AspNetCoreDiagnosticListener(IApmAgent agent)
 {
     _agent              = agent;
     _logger             = agent.Logger?.Scoped(nameof(AspNetCoreDiagnosticListener));
     _confgurationReader = agent.ConfigurationReader;
 }
Пример #17
0
 internal DiagnosticInitializer(IApmLogger baseLogger, IDiagnosticListener listener)
 {
     _logger   = baseLogger.Scoped(nameof(DiagnosticInitializer));
     _listener = listener;
 }
 internal DiagnosticInitializer(IApmLogger baseLogger, IEnumerable <IDiagnosticListener> listeners)
 {
     _logger             = baseLogger.Scoped(nameof(DiagnosticInitializer));
     _listeners          = listeners;
     _sourceSubscription = new CompositeDisposable();
 }