public TraceContext(TraceContext parent)
 {
     CallLevel = parent.CallLevel + 1;
     Timer = Stopwatch.StartNew();
     IsNested = true;
     Info = parent.Info;
 }
		public static bool ControlledExecution(IJobActivity activity, TraceContext traceContext, Action<string> audit, IDictionary<string,string> parameters)
		{
			var success = false;
			try
			{
				traceContext.ActivityStart();
                var jobContext = new JobContext(traceContext, parameters);
				activity.Execute(jobContext);
				success = true;
			    if (audit != null)
			    {
			        audit(null);
			    }
			}
			catch (Exception ex)
			{
				traceContext.Error(ex.ToString());
				if (audit != null)
					audit(ex.Message);
			}
			finally
			{
				traceContext.ActivityFinish(success);
				traceContext.FlashTraceBuffer();
			}
			return success;
		}
Esempio n. 3
0
        // Token: 0x06000847 RID: 2119 RVA: 0x0003A104 File Offset: 0x00038304
        public override bool Synchronize(MailboxSession mailboxSession, FolderRow folderRow, Deadline deadline, CalendarSyncPerformanceCountersInstance counters, CalendarSyncFolderOperationLogEntry folderOpLogEntry)
        {
            SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: InternetCalendarType.Synchronize will try to sync folder {1} with id {2} for mailbox {3}.", new object[]
            {
                TraceContext.Get(),
                folderRow.DisplayName,
                folderRow.FolderId,
                mailboxSession.DisplayName
            });
            bool flag = true;
            PublishingSubscriptionData subscriptionData = this.GetSubscriptionData(mailboxSession, folderRow);

            if (subscriptionData == null)
            {
                folderOpLogEntry.AddErrorToLog("NoSubscriptionData", null);
                return(true);
            }
            folderOpLogEntry.SubscriptionData = subscriptionData;
            folderOpLogEntry.FolderUrl        = subscriptionData.PublishingUrl.ToString();
            SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: InternetCalendarType.Synchronize will try to open URL {1} to sync folder {2} with id {3} for mailbox {4}.", new object[]
            {
                TraceContext.Get(),
                subscriptionData.PublishingUrl,
                folderRow.DisplayName,
                folderRow.FolderId,
                mailboxSession.DisplayName
            });
            try
            {
                flag = this.SyncFolder(mailboxSession, folderRow, subscriptionData, deadline, counters, folderOpLogEntry);
            }
            catch (ObjectNotFoundException ex)
            {
                SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: InternetCalendarType.Synchronize for subscription {1} folder {2} with id {3} for mailbox {4} hit exception {5}.", new object[]
                {
                    TraceContext.Get(),
                    subscriptionData,
                    folderRow.DisplayName,
                    folderRow.FolderId,
                    mailboxSession.DisplayName,
                    ex
                });
                folderOpLogEntry.AddExceptionToLog(ex);
            }
            SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: InternetCalendarType.Synchronize for folder {1} with id {2} for mailbox {3} will return {4}.", new object[]
            {
                TraceContext.Get(),
                folderRow.DisplayName,
                folderRow.FolderId,
                mailboxSession.DisplayName,
                flag
            });
            return(flag);
        }
Esempio n. 4
0
        /// <summary>
        /// Constructor of class used to create the connection to database.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="moduleName"></param>
        /// <param name="clientInfo"></param>
        /// <param name="trace"></param>
        public AutoCompleteRepository(TraceContext ctx, string connectString, string userName, string clientInfo)
        {
            var db = new OracleDatastore(ctx);

            db.CreateConnection(connectString, userName);

            db.ModuleName     = MODULE_NAME;
            db.ClientInfo     = clientInfo;
            db.DefaultMaxRows = 10000;      // Allow retrieving up to 10000 rows. Number of cartons can be huge
            _db = db;
        }
        public Hashtable InvokeFunction(
            AzFunctionInfo functionInfo,
            Hashtable triggerMetadata,
            TraceContext traceContext,
            IList <ParameterBinding> inputData,
            FunctionInvocationPerformanceStopwatch stopwatch)
        {
            var outputBindings = FunctionMetadata.GetOutputBindingHashtable(_pwsh.Runspace.InstanceId);

            var durableController = new DurableController(functionInfo.DurableFunctionInfo, _pwsh);

            try
            {
                durableController.BeforeFunctionInvocation(inputData);

                AddEntryPointInvocationCommand(functionInfo);
                stopwatch.OnCheckpoint(FunctionInvocationPerformanceStopwatch.Checkpoint.FunctionCodeReady);

                SetInputBindingParameterValues(functionInfo, inputData, durableController, triggerMetadata, traceContext);
                stopwatch.OnCheckpoint(FunctionInvocationPerformanceStopwatch.Checkpoint.InputBindingValuesReady);

                _pwsh.AddCommand("Microsoft.Azure.Functions.PowerShellWorker\\Trace-PipelineObject");

                stopwatch.OnCheckpoint(FunctionInvocationPerformanceStopwatch.Checkpoint.InvokingFunctionCode);
                Logger.Log(isUserOnlyLog: false, LogLevel.Trace, CreateInvocationPerformanceReportMessage(functionInfo.FuncName, stopwatch));

                try
                {
                    return(durableController.TryInvokeOrchestrationFunction(out var result)
                                ? result
                                : InvokeNonOrchestrationFunction(durableController, outputBindings));
                }
                catch (RuntimeException e)
                {
                    ErrorAnalysisLogger.Log(Logger, e.ErrorRecord, isException: true);
                    Logger.Log(isUserOnlyLog: true, LogLevel.Error, GetFunctionExceptionMessage(e));
                    throw;
                }
                catch (OrchestrationFailureException e)
                {
                    if (e.InnerException is IContainsErrorRecord inner)
                    {
                        Logger.Log(isUserOnlyLog: true, LogLevel.Error, GetFunctionExceptionMessage(inner));
                    }
                    throw;
                }
            }
            finally
            {
                durableController.AfterFunctionInvocation();
                outputBindings.Clear();
                ResetRunspace();
            }
        }
        public static void ControlledExecution(Func<IJobActivity> activityFactory, TraceSource traceSource, Action<string> audit, IDictionary<string, string> parameters)
		{

			var section = ConfigurationManager.GetSection("traceContextConfiguration") ??
						  new TraceContextConfigurationSection();
			var configurator = (TraceContextConfigurationSection)section;
			var activity = activityFactory();
			var contextName = new ContextName(activity.GetType().FullName, "");
			var configuration = configurator.GetDefault(contextName.Service, contextName.Method);
			var traceContext = new TraceContext(configuration, contextName, Guid.NewGuid(), traceSource);
            ControlledExecution(activity, traceContext, audit, parameters);
		}
        public void TestSubsegment()
        {
            _recorder.BeginSubsegment("subsegment1");
            Subsegment    subsegment1   = (Subsegment)TraceContext.GetEntity();
            FacadeSegment facadeSegment = (FacadeSegment)subsegment1.RootSegment;

            _recorder.EndSubsegment();

            Assert.AreEqual(facadeSegment.GetType(), typeof(FacadeSegment));
            Assert.IsFalse(facadeSegment.Subsegments.Contains(subsegment1)); // only subsegment is streamed
            Assert.IsFalse(TraceContext.IsEntityPresent());                  // facade segment is cleared from TraceContext
        }
Esempio n. 8
0
 // Token: 0x0600012A RID: 298 RVA: 0x00007404 File Offset: 0x00005604
 public static void HandleEventInternal(MailboxSession session, StoreObject storeItem)
 {
     LicensingProcessor.Tracer.TraceDebug(0L, "{0}: Calling LicensingProcessor.HandleEventInternal", new object[]
     {
         TraceContext.Get()
     });
     LicensingProcessor.ProcessSentItemMessage(session, storeItem);
     LicensingProcessor.Tracer.TraceDebug(0L, "{0}: Done LicensingProcessor.HandleEventInternal", new object[]
     {
         TraceContext.Get()
     });
 }
        public void TestLambdaVariablesNotSetCorrectly()
        {
            String invalidTraceHeader = "Root=" + TraceId + ";Parent=53995c3f42cd8ad8"; //sample decision is missing

            Environment.SetEnvironmentVariable(AWSXRayRecorder.LambdaTraceHeaderKey, invalidTraceHeader);
            _recorder.BeginSubsegment("subsegment1");
            Subsegment subsegment = (Subsegment)TraceContext.GetEntity(); //subsegment added with sample decision set to not sampled

            Assert.AreEqual(SampleDecision.NotSampled, subsegment.Sampled);
            _recorder.EndSubsegment();                      //subsegment not sampled since invalid TraceHeader value set in the lambda environment
            Assert.IsFalse(TraceContext.IsEntityPresent()); // Facade segment not present in the callcontext
        }
Esempio n. 10
0
        public void CurrentContext_property_setter_should_set_null()
        {
            var context = new TraceContext(Guid.NewGuid(), Guid.NewGuid());

            tracer.CurrentContext = context;

            tracer.CurrentContext.Should().BeEquivalentTo(context);

            tracer.CurrentContext = null;

            tracer.CurrentContext.Should().BeNull();
        }
        public void OnRequest_calls_Inject()
        {
            var tracer       = new TestTracer();
            var traceContext = new TraceContext();
            var interceptor  = GetInterceptor(tracer, traceContext);
            var request      = new HttpRequestMessage(HttpMethod.Get, new Uri("http://www.example.com/api/values"));

            // Call interceptor
            interceptor.OnRequest(request);

            Assert.True(tracer.InjectCalled);
        }
        // Token: 0x06000627 RID: 1575 RVA: 0x0002F4D8 File Offset: 0x0002D6D8
        internal void Invoke(MailboxDataForTags mailboxDataForTags, ElcParameters parameters)
        {
            SysCleanupEnforcerManager.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Invoke called.", new object[]
            {
                TraceContext.Get()
            });
            ICollection <SysCleanupEnforcerBase> collection;

            if (parameters != ElcParameters.None)
            {
                collection = new List <SysCleanupEnforcerBase>();
                if ((parameters & ElcParameters.HoldCleanup) == ElcParameters.HoldCleanup)
                {
                    collection.Add(new HoldCleanupEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant));
                }
                if ((parameters & ElcParameters.EHAHiddenFolderCleanup) == ElcParameters.EHAHiddenFolderCleanup)
                {
                    collection.Add(new EHAHiddenFolderCleanupEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant));
                }
            }
            else
            {
                collection = new List <SysCleanupEnforcerBase>(new SysCleanupEnforcerBase[]
                {
                    new MigrateToArchiveEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant),
                    new DumpsterExpirationEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant),
                    new CalendarLogExpirationEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant),
                    new AuditExpirationEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant),
                    new DumpsterQuotaEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant),
                    new AuditQuotaEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant),
                    new SupplementExpirationEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant),
                    new EHAQuotaWarningEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant),
                    new EHAMigratedMessageMoveEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant),
                    new EHAMigratedMessageDeletionEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant),
                    new DiscoveryHoldEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant)
                });
                if (mailboxDataForTags.HoldCleanupFolderType != DefaultFolderType.None)
                {
                    collection.Add(new HoldCleanupEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant));
                }
                if (mailboxDataForTags.IsEHAHiddenFolderWatermarkSet())
                {
                    collection.Add(new EHAHiddenFolderCleanupEnforcer(mailboxDataForTags, this.sysCleanupSubAssistant));
                }
            }
            foreach (SysCleanupEnforcerBase sysCleanupEnforcerBase in collection)
            {
                this.sysCleanupSubAssistant.ThrowIfShuttingDown(mailboxDataForTags.MailboxSession.MailboxOwner);
                SysCleanupEnforcerManager.Tracer.TraceDebug <object, SysCleanupEnforcerBase>((long)this.GetHashCode(), "{0}: Calling enabled enforcer '{1}'.", TraceContext.Get(), sysCleanupEnforcerBase);
                mailboxDataForTags.StatisticsLogEntry.LastProcessedEnforcer = sysCleanupEnforcerBase.GetType().Name;
                sysCleanupEnforcerBase.Invoke();
            }
        }
Esempio n. 13
0
        protected TestHttpContext()
            : base()
        {
            //  When overridden in a derived class, gets an array of errors (if any) that
            //     accumulated when an HTTP request was being processed.

            TestRequest  = null;
            TestResponse = null;
            TestServer   = new TestHttpServer();
            TestSession  = null;
            trace        = new TraceContext(HttpContext.Current);
        }
Esempio n. 14
0
        public void Constructor_Properties_Events()
        {
            TraceContext tc = new TraceContext(context);

            tc.IsEnabled = false;
            Assert.IsFalse(tc.IsEnabled, "IsEnabled");

            Assert.AreEqual(TraceMode.SortByTime, tc.TraceMode, "TraceMode");
            tc.TraceMode      = TraceMode.Default;
            tc.TraceFinished += new TraceContextEventHandler(Handler);
            tc.TraceFinished -= new TraceContextEventHandler(Handler);
        }
        public async Task AddsTraceKeepRateMetricToRootSpan()
        {
            // Traces should be dropped when both buffers are full
            var calculator = new MovingAverageKeepRateCalculator(windowSize: 10, Timeout.InfiniteTimeSpan);

            var tracer = new Mock <IDatadogTracer>();

            tracer.Setup(x => x.DefaultServiceName).Returns("Default");
            var traceContext    = new TraceContext(tracer.Object);
            var rootSpanContext = new SpanContext(null, traceContext, null);
            var rootSpan        = new Span(rootSpanContext, DateTimeOffset.UtcNow);
            var childSpan       = new Span(new SpanContext(rootSpanContext, traceContext, null), DateTimeOffset.UtcNow);

            traceContext.AddSpan(rootSpan);
            traceContext.AddSpan(childSpan);
            var trace       = new[] { rootSpan, childSpan };
            var sizeOfTrace = ComputeSizeOfTrace(trace);

            // Make the buffer size big enough for a single trace
            var api = new Mock <IApi>();

            api.Setup(x => x.SendTracesAsync(It.IsAny <ArraySegment <byte> >(), It.IsAny <int>()))
            .ReturnsAsync(() => true);
            var agent = new AgentWriter(api.Object, statsd: null, calculator, automaticFlush: false, maxBufferSize: (sizeOfTrace * 2) + SpanBuffer.HeaderSize - 1, batchInterval: 100);

            // Fill both buffers
            agent.WriteTrace(trace);
            agent.WriteTrace(trace);

            // Drop one
            agent.WriteTrace(trace);
            await agent.FlushTracesAsync(); // Force a flush to make sure the trace is written to the API

            // Write another one
            agent.WriteTrace(trace);
            await agent.FlushTracesAsync(); // Force a flush to make sure the trace is written to the API

            api.Verify();
            api.Invocations.Clear();

            // Write trace and update keep rate
            calculator.UpdateBucket();
            agent.WriteTrace(trace);
            await agent.FlushTracesAsync(); // Force a flush to make sure the trace is written to the API

            const double expectedTraceKeepRate = 0.75;

            rootSpan.SetMetric(Metrics.TracesKeepRate, expectedTraceKeepRate);
            var expectedData = Vendors.MessagePack.MessagePackSerializer.Serialize(trace, new FormatterResolverWrapper(SpanFormatterResolver.Instance));
            await agent.FlushAndCloseAsync();

            api.Verify(x => x.SendTracesAsync(It.Is <ArraySegment <byte> >(y => Equals(y, expectedData)), It.Is <int>(i => i == 1)), Times.Once);
        }
Esempio n. 16
0
        public void ValidateTraceParentWithFutureVersion()
        {
            const string traceParent = "99-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01";

            //Best attempt, even if it's a future version we still try to read the traceId and parentId
            var res = TraceContext.TryExtractTracingData(traceParent);

            res.Should().NotBeNull();
            res.TraceId.Should().Be("0af7651916cd43dd8448eb211c80319c");
            res.ParentId.Should().Be("b7ad6b7169203331");
            res.FlagRecorded.Should().BeTrue();
        }
Esempio n. 17
0
 public override string ToString()
 {
     return(string.Concat(new object[]
     {
         "ProxyWebRequest ",
         this.requestType,
         " from ",
         TraceContext.Get(),
         " to ",
         this.url
     }));
 }
Esempio n. 18
0
        public HomeService(TraceContext ctx, string connectString, string userName, string clientInfo)
        {
            _userName = userName;
#if DEBUG
            if (userName.StartsWith("_"))
            {
                // This is a dummy user. Don't let the repository know about this
                userName = "";
            }
#endif
            _repos = new HomeRepository(ctx, connectString, userName, clientInfo);
        }
        public void Using_pops_span_from_stack()
        {
            var traceContext = new TraceContext();
            var span         = GetSpan();

            using (traceContext.Push(span))
            {
                Assert.Equal(span, traceContext.CurrentSpan);
            }

            Assert.Null(traceContext.CurrentSpan);
        }
        public void WithAnnotation_should_return_a_tracer_that_forwards_context_property_access_to_base_tracer()
        {
            enrichedTracer = baseTracer.WithAnnotation("key", "value");

            enrichedTracer.CurrentContext.Should().BeSameAs(baseTracer.CurrentContext);

            var newContext = new TraceContext(Guid.NewGuid(), Guid.NewGuid());

            enrichedTracer.CurrentContext = newContext;

            baseTracer.Received().CurrentContext = newContext;
        }
        public static void ControlledExecution(Func <IJobActivity> activityFactory, TraceSource traceSource, Action <string> audit, IDictionary <string, string> parameters)
        {
            var section = ConfigurationManager.GetSection("traceContextConfiguration") ??
                          new TraceContextConfigurationSection();
            var configurator  = (TraceContextConfigurationSection)section;
            var activity      = activityFactory();
            var contextName   = new ContextName(activity.GetType().FullName, "");
            var configuration = configurator.GetDefault(contextName.Service, contextName.Method);
            var traceContext  = new TraceContext(configuration, contextName, Guid.NewGuid(), traceSource);

            ControlledExecution(activity, traceContext, audit, parameters);
        }
Esempio n. 22
0
        public void OnBeginRequest(HttpContext httpContext)
        {
            Execute(() =>
            {
                var extractedSpanContext = TryExtractSpanContext(httpContext.Request);

                ISpan span = StartSpan(extractedSpanContext, httpContext.Request);

                // Push span to stack for in-process propagation.
                TraceContext.Push(span);
            });
        }
Esempio n. 23
0
        // Token: 0x06000125 RID: 293 RVA: 0x00007278 File Offset: 0x00005478
        internal void LoadData(MailboxSession session)
        {
            if (this.sentItemsFolderId == null)
            {
                StoreObjectId defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.SentItems);
                if (defaultFolderId != null)
                {
                    this.sentItemsFolderId = defaultFolderId.ProviderLevelItemId;
                }
                else
                {
                    MailboxData.Tracer.TraceError((long)this.GetHashCode(), "{0}: Sent items folder id is null", new object[]
                    {
                        TraceContext.Get()
                    });
                }
            }
            if (this.outboxFolderId == null)
            {
                StoreObjectId defaultFolderId2 = session.GetDefaultFolderId(DefaultFolderType.Outbox);
                if (defaultFolderId2 != null)
                {
                    this.outboxFolderId = defaultFolderId2.ProviderLevelItemId;
                }
                else
                {
                    MailboxData.Tracer.TraceError((long)this.GetHashCode(), "{0}: Outbox folder id is null", new object[]
                    {
                        TraceContext.Get()
                    });
                }
            }
            if (this.inboxFolderId == null)
            {
                StoreObjectId defaultFolderId3 = session.GetDefaultFolderId(DefaultFolderType.Inbox);
                if (defaultFolderId3 != null)
                {
                    this.inboxFolderId = defaultFolderId3.ProviderLevelItemId;
                }
                else
                {
                    MailboxData.Tracer.TraceError((long)this.GetHashCode(), "{0}: Inbox folder id is null", new object[]
                    {
                        TraceContext.Get()
                    });
                }
            }
            int totalActionItemCount;

            ConversationActionItem.QueryConversationActionsFolder(session, null, 0, out totalActionItemCount);
            this.UpdateConversationActionsEnabledStatus(totalActionItemCount);
        }
Esempio n. 24
0
        public async Task TestTraceMethodAsyncReturnVoid()
        {
            _recorder.BeginSegment("test", TraceId);

            int count = 0;
            await _recorder.TraceMethodAsync("PlusOneNoReturnAsync", () => PlusOneNoReturnAsync <int>(count));

            var subsegment = TraceContext.GetEntity().Subsegments[0];

            Assert.AreEqual("PlusOneNoReturnAsync", subsegment.Name);

            _recorder.EndSegment();
        }
Esempio n. 25
0
        /// <summary>
        /// Begin a tracing segment. A new tracing segment will be created and started.
        /// </summary>
        /// <param name="name">The name of the segment.</param>
        /// <param name="traceId">Trace id of the segment.</param>
        /// <param name="parentId">Unique id of the upstream remote segment or subsegment where the downstream call originated from.</param>
        /// <param name="sampleDecision">Sample decision for the segment from upstream service.</param>
        /// <exception cref="ArgumentNullException">The argument has a null value.</exception>
        public override void BeginSegment(string name, string traceId = null, string parentId = null, SampleDecision sampleDecision = SampleDecision.Sampled)
        {
            Segment newSegment = new Segment(name, traceId, parentId);

            if (!IsTracingDisabled())
            {
                newSegment.SetStartTimeToNow(); //sets current timestamp
                PopulateNewSegmentAttributes(newSegment);
            }

            newSegment.Sampled = sampleDecision;
            TraceContext.SetEntity(newSegment);
        }
Esempio n. 26
0
 // Token: 0x060002D1 RID: 721 RVA: 0x00011000 File Offset: 0x0000F200
 internal bool IsPolicyValid(ProvisionedFolder provisionedFolder, ContentSetting policy, string itemClass, MailboxDataForFolders mailboxData)
 {
     if (!ElcPolicySettings.ArePolicyPropertiesValid(policy, TraceContext.Get(), this.mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()))
     {
         return(false);
     }
     FolderProcessor.CircularPolicyType circularPolicyType = this.LookForCircularPolicies(provisionedFolder, policy, itemClass, mailboxData);
     if (circularPolicyType == FolderProcessor.CircularPolicyType.BadCycle)
     {
         throw new SkipException(Strings.descCycleInPolicies(this.mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), policy.Name));
     }
     return(true);
 }
Esempio n. 27
0
    protected void Method(TraceContext Context)
    {
// <Snippet1>
        if (Context.IsEnabled)
        {
            for (int i = 0; i < DS.Tables["Categories"].Rows.Count; i++)
            {
                Trace.Write("ProductCategory", DS.Tables["Categories"].Rows[i][0].ToString());
            }
        }

// </Snippet1>
    }
Esempio n. 28
0
        public void TestServiceContext()
        {
            _recorder.BeginSegment("test", TraceId);
            var segment = (Segment)TraceContext.GetEntity();

            _recorder.EndSegment();
#if NET45
            Assert.AreEqual(".NET Framework", segment.Service["runtime"]);
#else
            Assert.AreEqual(".NET Core Framework", segment.Service["runtime"]);
#endif
            Assert.AreEqual(Environment.Version.ToString(), segment.Service["runtime_version"]);
        }
Esempio n. 29
0
        public void TestAddMetadata()
        {
            _recorder.BeginSegment("metadata", TraceId);
            _recorder.AddMetadata("key1", "value1");
            _recorder.AddMetadata("aws", "key2", "value2");

            var segment = TraceContext.GetEntity();

            _recorder.EndSegment();

            Assert.AreEqual("value1", segment.Metadata["default"]["key1"]);
            Assert.AreEqual("value2", segment.Metadata["aws"]["key2"]);
        }
Esempio n. 30
0
        /// <summary>
        /// Constructor of class used to create the connection to database.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="moduleName"></param>
        /// <param name="clientInfo"></param>
        /// <param name="trace"></param>
        public ReqRepository(string userName, string moduleName, string clientInfo, TraceContext trace)
        {
            const string MODULE_CODE = "REQ2";

            Contract.Assert(ConfigurationManager.ConnectionStrings["dcms8"] != null);
            var store = new OracleDatastore(trace);

            store.CreateConnection(ConfigurationManager.ConnectionStrings["dcms8"].ConnectionString,
                                   userName);
            store.ModuleName = MODULE_CODE;
            store.ClientInfo = clientInfo;
            _db = store;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        public void BeginRequest(IDictionary environment)
        {
            //var scopeContext = new RequestScopeContext(environment);
            //RequestScopeContext.Current = scopeContext;

            var context = new TraceContext();

            //var environment = System.Web.HttpContext.Current.Request.ServerVariables;

            //res = environment["LOCAL_ADDR"] + System.Web.HttpContext.Current.Request.Url.Port;
            context.Items[TraceContext.SERVER_ADDRESS_KEY] = string.Concat(environment["LOCAL_ADDR"], ":", environment["SERVER_PORT"]);
            environment[TraceContext.TRACE_CONTEXT_KEY]    = context;
        }
Esempio n. 32
0
        public TraceContextStack(int trackingId, bool traceLayout, bool traceText, bool tracePath, bool traceOutline)
        {
            TraceContext context = new TraceContext
            {
                OwnerTrackingId = trackingId,
                TraceLayout     = traceLayout,
                TraceText       = traceText,
                TracePath       = tracePath,
                TraceOutline    = traceOutline
            };

            _stack.Push(context);
        }
Esempio n. 33
0
        public void TraceWrite(string category, string message)
        {
            if (context == null && HttpContext.Current == null)
            {
                return;
            }
            TraceContext Trace = (Context != null) ? Context.Trace : null;

            if (Trace != null)
            {
                Trace.Write(category, message);
            }
        }
Esempio n. 34
0
		/// <summary>
		/// Starts a new TraceContext scope.
		/// </summary>
		/// <returns>The new TraceContext that can be filled in.</returns>
		public static TraceContext Begin()
		{
			var data = (TraceContext)CallContext.LogicalGetData(_slot);
			TraceContext context = null;
			try
			{
				context = new TraceContext(data);
				CallContext.LogicalSetData(_slot, context);
			}
			catch
			{
				context.Dispose();
				throw;
			}

			return context;
		}
Esempio n. 35
0
		/// <summary>
		/// Initializes a new instance of the TraceContext class.
		/// </summary>
		/// <param name="baseContext">The base context.</param>
		private TraceContext(TraceContext baseContext)
		{
			_baseContext = baseContext;
		}