Esempio n. 1
0
 public SpanBuilderDecorator(ISpanBuilder spanBuilder, ITracer tracer, string operationName, BuildersDecoratorHooks hooks)
 {
     _spanBuilder   = spanBuilder;
     _tracer        = tracer;
     _operationName = operationName;
     _hooks         = hooks;
 }
 public SpanDecoratorHooks(BuildersDecoratorHooks mainHooks, OnSpanFinished callBack)
 {
     OnSpanStarted   = mainHooks.OnSpanStarted;
     OnSpanActivated = mainHooks.OnSpanActivated;
     OnSpanFinished  = (OnSpanFinished)Delegate.Combine(mainHooks.OnSpanFinished, callBack);
     OnSpanLog       = mainHooks.OnSpanLog;
     OnSpanSetTag    = mainHooks.OnSpanSetTag;
 }
 public ScopeManagerDecorator(IScopeManager scopeManager, ITracer tracer, BuildersDecoratorHooks hooks)
 {
     _scopeManager = scopeManager;
     _tracer       = tracer;
     _hooks        = hooks;
 }
Esempio n. 4
0
        public ITracer Build()
        {
            var hooks = new BuildersDecoratorHooks();

            if (_onSpanStarteds.Count != 0)
            {
                var delegates = _onSpanStarteds.ToArray();
                hooks.OnSpanStarted = (span, operationName) =>
                {
                    foreach (var d in delegates)
                    {
                        d(span, operationName);
                    }
                };
            }

            if (_onSpanActivateds.Count != 0)
            {
                var delegates = _onSpanActivateds.ToArray();
                hooks.OnSpanActivated = (span, operationName) =>
                {
                    foreach (var d in delegates)
                    {
                        d(span, operationName);
                    }
                };
            }

            if (_onSpanFinisheds.Count != 0)
            {
                var delegates = _onSpanFinisheds.ToArray();
                hooks.OnSpanFinished = (span, operationName) =>
                {
                    foreach (var d in delegates)
                    {
                        d(span, operationName);
                    }
                };
            }

            if (_onSpanStartedWithCallbacks.Count != 0)
            {
                var delegates = _onSpanStartedWithCallbacks.ToArray();
                hooks.OnSpanStartedWithFinishCallback = (span, operationName) =>
                {
                    var callBacks = delegates.Select(d => d(span, operationName)).ToArray();
                    return((sp, op) =>
                    {
                        foreach (var callBack in callBacks)
                        {
                            callBack(sp, op);
                        }
                    });
                };
            }

            if (_onSpanLogs.Count != 0)
            {
                var delegates = _onSpanLogs.ToArray();
                hooks.OnSpanLog = (span, operationName, timestamp, fields) =>
                {
                    foreach (var d in delegates)
                    {
                        d(span, operationName, timestamp, fields);
                    }
                };
            }

            if (_onSpanSetTags.Count != 0)
            {
                var delegates = _onSpanSetTags.ToArray();
                hooks.OnSpanSetTag = (span, operationName, tagKeyValue) =>
                {
                    foreach (var d in delegates)
                    {
                        d(span, operationName, tagKeyValue);
                    }
                };
            }

            return(new TracerDecorator(_tracer, hooks));
        }
Esempio n. 5
0
 public TracerDecorator(ITracer tracer, BuildersDecoratorHooks hooks)
 {
     _tracer      = tracer;
     _hooks       = hooks;
     ScopeManager = new ScopeManagerDecorator(tracer.ScopeManager, this, _hooks);
 }