Exemplo n.º 1
0
        public OwinHostingObserver(IMetricsOptions options, IStats censusStats, ITags censusTags, ILogger <OwinHostingObserver> logger)
            : base(OBSERVER_NAME, DIAGNOSTIC_NAME, options, censusStats, censusTags, logger)
        {
            PathMatcher = new Regex(options.IngressIgnorePattern);

            responseTimeMeasure = MeasureDouble.Create("server.owin.totalTime", "Total request time", MeasureUnit.MilliSeconds);
            serverCountMeasure  = MeasureLong.Create("server.owin.totalRequests", "Total request count", "count");

            var view = View.Create(
                ViewName.Create("http.server.request.time"),
                "Total request time",
                responseTimeMeasure,
                Distribution.Create(BucketBoundaries.Create(new List <double>()
            {
                0.0, 1.0, 5.0, 10.0, 100.0
            })),
                new List <ITagKey>()
            {
                statusTagKey, exceptionTagKey, methodTagKey, uriTagKey
            });

            ViewManager.RegisterView(view);

            view = View.Create(
                ViewName.Create("http.server.request.count"),
                "Total request counts",
                serverCountMeasure,
                Sum.Create(),
                new List <ITagKey>()
            {
                statusTagKey, exceptionTagKey, methodTagKey, uriTagKey
            });

            ViewManager.RegisterView(view);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Get Tag by id
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// Id of entity to retrieve
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task <object> GetAsyncByidAsync(this ITags operations, int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     using (var _result = await operations.GetAsyncByidWithHttpMessagesAsync(id, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 3
0
        public static void MergeTags(this ITags resource, IDictionary <string, string> tags, bool overwriteExistingValues = true)
        {
            if (resource is null)
            {
                throw new ArgumentNullException(nameof(resource));
            }

            if (resource.Tags is null)
            {
                resource.Tags = new Dictionary <string, string>();
            }

            if (overwriteExistingValues)
            {
                tags.ToList().ForEach(t => resource.Tags[t.Key] = t.Value);
            }
            else
            {
                var keyValuePairs = resource.Tags
                                    .Concat(tags);

                resource.Tags = keyValuePairs
                                .GroupBy(kvp => kvp.Key)
                                .Where(kvp => kvp.First().Value != null)
                                .ToDictionary(kvp => kvp.Key, kvp => kvp.First().Value);
            }
        }
 /// <summary>
 /// メモタグ一覧の取得
 /// </summary>
 /// <remarks>
 /// 指定した事業所のメモタグ一覧を取得する
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='companyId'>
 /// 事業所ID
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <TagsIndexResponse> ListAsync(this ITags operations, int companyId, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.ListWithHttpMessagesAsync(companyId, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 5
0
 public TweetResults(ITags tagData, ITweetData tweetData,
                     ITweetsByOfficialData tweetPlusOfficial)
 {
     _tagData          = tagData;
     _tweetData        = tweetData;
     _tweetsByOfficial = tweetPlusOfficial;
 }
 /// <summary>
 /// メモタグの作成
 /// </summary>
 /// <remarks>
 /// 指定した事業所のメモタグを作成する
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='parameters'>
 /// メモタグの作成
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <TagsCreateResponse> CreateAsync(this ITags operations, Parameters parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 7
0
        private int SerializeTags(ref byte[] bytes, int offset, Span span, ITags tags, ITagProcessor[] tagProcessors)
        {
            int originalOffset = offset;

            offset += WriteTags(ref bytes, offset, span, tags, tagProcessors);
            offset += WriteMetrics(ref bytes, offset, span, tags, tagProcessors);

            return(offset - originalOffset);
        }
Exemplo n.º 8
0
 public TagsController(
     ITags api,
     IAppSettings appSettings,
     ILogger <TagsController> logger) : base()
 {
     this.api         = api;
     this.appSettings = appSettings;
     this.logger      = logger;
 }
Exemplo n.º 9
0
 public static void SetTag(this ITags tags, string tag, bool onOff)
 {
     if (onOff)
     {
         tags.AddTag(tag);
     }
     else
     {
         tags.RemoveTag(tag);
     }
 }
Exemplo n.º 10
0
        internal Span(SpanContext context, DateTimeOffset?start, ITags tags)
        {
            Tags      = tags ?? new CommonTags();
            Context   = context;
            StartTime = start ?? Context.TraceContext.UtcNow;

            Log.Debug(
                "Span started: [s_id: {SpanID}, p_id: {ParentId}, t_id: {TraceId}]",
                SpanId,
                Context.ParentId,
                TraceId);
        }
Exemplo n.º 11
0
        public static void Parse(this ITags tags, string str)
        {
            if (string.IsNullOrEmpty(str))
            {
                return;
            }

            var split = str.Split(separators, StringSplitOptions.RemoveEmptyEntries);

            foreach (var tag in split)
            {
                tags.AddTag(tag);
            }
        }
Exemplo n.º 12
0
        public CLRRuntimeObserver(IMetricsOptions options, IStats censusStats, ITags censusTags, ILogger <CLRRuntimeObserver> logger)
            : base(OBSERVER_NAME, DIAGNOSTIC_NAME, options, censusStats, censusTags, logger)
        {
            memoryUsedMeasure      = MeasureLong.Create("memory.used.value", "Current CLR memory usage", MeasureUnit.Bytes);
            collectionCountMeasure = MeasureLong.Create("collection.count", "Garbage collection count", "count");
            activeThreadsMeasure   = MeasureLong.Create("active.thread.value", "Active thread count", "count");
            availThreadsMeasure    = MeasureLong.Create("avail.thread.value", "Available thread count", "count");

            memoryTagValues             = Tagger.CurrentBuilder.Put(memoryAreaKey, heapArea).Build();
            threadPoolWorkerTagValues   = Tagger.CurrentBuilder.Put(threadKindKey, threadPoolWorkerKind).Build();
            threadPoolCompPortTagValues = Tagger.CurrentBuilder.Put(threadKindKey, threadPoolComppKind).Build();

            RegisterViews();
        }
Exemplo n.º 13
0
        // TAGS

        private int WriteTags(ref byte[] bytes, int offset, Span span, ITags tags, ITagProcessor[] tagProcessors)
        {
            int originalOffset = offset;

            // Start of "meta" dictionary. Do not add any string tags before this line.
            offset += MessagePackBinary.WriteStringBytes(ref bytes, offset, _metaBytes);

            int count = 0;

            // We don't know the final count yet, write a fixed-size header and note the offset
            var countOffset = offset;

            offset += MessagePackBinary.WriteMapHeaderForceMap32Block(ref bytes, offset, 0);

            // add "language=dotnet" tag to all spans, except those that
            // represents a downstream service or external dependency
            if (tags is not InstrumentationTags {
                SpanKind : SpanKinds.Client or SpanKinds.Producer
            })
Exemplo n.º 14
0
        internal Span StartSpan(string operationName, ITags tags, ISpanContext parent = null, string serviceName = null, DateTimeOffset?startTime = null, bool ignoreActiveScope = false, ulong?spanId = null)
        {
            var spanContext = CreateSpanContext(parent, serviceName, ignoreActiveScope, spanId);

            var span = new Span(spanContext, startTime, tags)
            {
                OperationName = operationName,
            };

            // Apply any global tags
            if (Settings.GlobalTags.Count > 0)
            {
                foreach (var entry in Settings.GlobalTags)
                {
                    span.SetTag(entry.Key, entry.Value);
                }
            }

            // automatically add the "env" tag if defined, taking precedence over an "env" tag set from a global tag
            var env = Settings.Environment;

            if (!string.IsNullOrWhiteSpace(env))
            {
                span.SetTag(Tags.Env, env);
            }

            // automatically add the "version" tag if defined, taking precedence over an "version" tag set from a global tag
            var version = Settings.ServiceVersion;

            if (!string.IsNullOrWhiteSpace(version) && string.Equals(spanContext.ServiceName, DefaultServiceName))
            {
                span.SetTag(Tags.Version, version);
            }

            spanContext.TraceContext.AddSpan(span);
            return(span);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Add Metrics actuator endpoint to OWIN Pipeline
        /// </summary>
        /// <param name="builder">OWIN <see cref="IAppBuilder" /></param>
        /// <param name="config"><see cref="IConfiguration"/> of application for configuring metrics endpoint</param>
        /// <param name="stats">Class for recording statistics - See also: <seealso cref="OpenCensusStats"/></param>
        /// <param name="tags">Class using for recording statistics</param>
        /// <param name="loggerFactory">For logging within the middleware</param>
        /// <returns>OWIN <see cref="IAppBuilder" /> with Metrics Endpoint added</returns>
        public static IAppBuilder UseMetricsActuator(this IAppBuilder builder, IConfiguration config, IStats stats, ITags tags, ILoggerFactory loggerFactory = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            if (stats == null)
            {
                throw new ArgumentNullException(nameof(stats));
            }

            if (tags == null)
            {
                throw new ArgumentNullException(nameof(tags));
            }

            IMetricsOptions options     = new MetricsEndpointOptions(config);
            var             mgmtOptions = ManagementOptions.Get(config);

            foreach (var mgmt in mgmtOptions)
            {
                mgmt.EndpointOptions.Add(options);
            }

            var hostObserver = new OwinHostingObserver(options, stats, tags, loggerFactory?.CreateLogger <OwinHostingObserver>());
            var clrObserver  = new CLRRuntimeObserver(options, stats, tags, loggerFactory?.CreateLogger <CLRRuntimeObserver>());

            DiagnosticsManager.Instance.Observers.Add(hostObserver);
            DiagnosticsManager.Instance.Observers.Add(clrObserver);

            var clrSource = new CLRRuntimeSource();

            DiagnosticsManager.Instance.Sources.Add(clrSource);

            var endpoint = new MetricsEndpoint(options, stats, loggerFactory?.CreateLogger <MetricsEndpoint>());
            var logger   = loggerFactory?.CreateLogger <MetricsEndpointOwinMiddleware>();

            return(builder.Use <MetricsEndpointOwinMiddleware>(endpoint, mgmtOptions, logger));
        }
Exemplo n.º 16
0
 /// <summary>
 /// Get Tag by id
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// Id of entity to retrieve
 /// </param>
 public static object GetAsyncByid(this ITags operations, int id)
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((ITags)s).GetAsyncByidAsync(id), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Exemplo n.º 17
0
 public TestObserver(IMetricsOptions options, IStats censusStats, ITags censusTags, ILogger logger)
     : base("TestObserver", DIAGNOSTIC_NAME, options, censusStats, censusTags, logger)
 {
 }
Exemplo n.º 18
0
        public HttpClientDesktopObserver(IMetricsOptions options, IStats censusStats, ITags censusTags, ILogger <HttpClientDesktopObserver> logger)
            : base(OBSERVER_NAME, DIAGNOSTIC_NAME, options, censusStats, censusTags, logger)
        {
            PathMatcher = new Regex(options.EgressIgnorePattern);

            clientTimeMeasure  = MeasureDouble.Create("client.desk.totalTime", "Total request time", MeasureUnit.MilliSeconds);
            clientCountMeasure = MeasureLong.Create("client.core.totalRequests", "Total request count", "count");

            var view = View.Create(
                ViewName.Create("http.desktop.client.request.time"),
                "Total request time",
                clientTimeMeasure,
                Distribution.Create(BucketBoundaries.Create(new List <double>()
            {
                0.0, 1.0, 5.0, 10.0, 100.0
            })),
                new List <ITagKey>()
            {
                statusTagKey, uriTagKey, methodTagKey, clientTagKey
            });

            ViewManager.RegisterView(view);

            view = View.Create(
                ViewName.Create("http.desktop.client.request.count"),
                "Total request counts",
                clientCountMeasure,
                Sum.Create(),
                new List <ITagKey>()
            {
                statusTagKey, uriTagKey, methodTagKey, clientTagKey
            });
            ViewManager.RegisterView(view);
        }
Exemplo n.º 19
0
 /// <summary>
 /// Get all Tags
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='orderby'>
 /// &lt;p&gt;&lt;a href='#queryoptions'&gt;Sorts&lt;/a&gt; the result in
 /// ascending order by the supplied property.&lt;/p&gt;&lt;p&gt;Valid values
 /// are: &lt;strong&gt;TagId&lt;/strong&gt; (default),
 /// &lt;strong&gt;Text&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;Note:
 /// &lt;strong&gt;orderby&lt;/strong&gt; and
 /// &lt;strong&gt;orderbydesc&lt;/strong&gt; are mutually exclusive.&lt;/p&gt;
 /// </param>
 /// <param name='orderbydesc'>
 /// &lt;p&gt;&lt;a href='#queryoptions'&gt;Sorts&lt;/a&gt; the result in
 /// descending order by the supplied property.&lt;/p&gt;&lt;p&gt;Valid values
 /// are: &lt;strong&gt;TagId&lt;/strong&gt; (default),
 /// &lt;strong&gt;Text&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;Note:
 /// &lt;strong&gt;orderby&lt;/strong&gt; and
 /// &lt;strong&gt;orderbydesc&lt;/strong&gt; are mutually exclusive.&lt;/p&gt;
 /// </param>
 /// <param name='accountAccountId'>
 /// &lt;p&gt;&lt;a href="#queryoptions"&gt;Filters&lt;/a&gt; the result by
 /// Account.AccountId using the supplied operation and
 /// value.&lt;/p&gt;&lt;p&gt;Valid operations are:
 /// &lt;strong&gt;eq(int)&lt;/strong&gt;&lt;/p&gt;
 /// </param>
 /// <param name='top'>
 /// &lt;a href="#queryoptions"&gt;Query paging&lt;/a&gt; Returns the maximum
 /// number of entities. Default and max value is 10000
 /// </param>
 /// <param name='skip'>
 /// &lt;a href="#queryoptions"&gt;Query paging&lt;/a&gt; Skips this number of
 /// entities
 /// </param>
 public static object GetCollectionAsyncByqueryOptions(this ITags operations, string orderby = "TagId", string orderbydesc = default(string), string accountAccountId = default(string), int?top = 10000, int?skip = default(int?))
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((ITags)s).GetCollectionAsyncByqueryOptionsAsync(orderby, orderbydesc, accountAccountId, top, skip), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Exemplo n.º 20
0
 public TagsManager(ITags tagsRepository)
 {
     Repo = tagsRepository;
 }
Exemplo n.º 21
0
        internal Span StartSpan(string operationName, ITags tags, ISpanContext parent = null, string serviceName = null, DateTimeOffset?startTime = null, bool ignoreActiveScope = false)
        {
            if (parent == null && !ignoreActiveScope)
            {
                parent = _scopeManager.Active?.Span?.Context;
            }

            ITraceContext traceContext;

            // try to get the trace context (from local spans) or
            // sampling priority (from propagated spans),
            // otherwise start a new trace context
            if (parent is SpanContext parentSpanContext)
            {
                traceContext = parentSpanContext.TraceContext ??
                               new TraceContext(this)
                {
                    SamplingPriority = parentSpanContext.SamplingPriority
                };
            }
            else
            {
                traceContext = new TraceContext(this);
            }

            var finalServiceName = serviceName ?? parent?.ServiceName ?? DefaultServiceName;
            var spanContext      = new SpanContext(parent, traceContext, finalServiceName);

            var span = new Span(spanContext, startTime, tags)
            {
                OperationName = operationName,
            };

            // Apply any global tags
            if (Settings.GlobalTags.Count > 0)
            {
                foreach (var entry in Settings.GlobalTags)
                {
                    span.SetTag(entry.Key, entry.Value);
                }
            }

            // automatically add the "env" tag if defined, taking precedence over an "env" tag set from a global tag
            var env = Settings.Environment;

            if (!string.IsNullOrWhiteSpace(env))
            {
                span.SetTag(Tags.Env, env);
            }

            // automatically add the "version" tag if defined, taking precedence over an "version" tag set from a global tag
            var version = Settings.ServiceVersion;

            if (!string.IsNullOrWhiteSpace(version) && string.Equals(finalServiceName, DefaultServiceName))
            {
                span.SetTag(Tags.Version, version);
            }

            traceContext.AddSpan(span);
            return(span);
        }
Exemplo n.º 22
0
        internal Scope StartActiveWithTags(string operationName, ISpanContext parent = null, string serviceName = null, DateTimeOffset?startTime = null, bool ignoreActiveScope = false, bool finishOnClose = true, ITags tags = null)
        {
            var span = StartSpan(operationName, tags, parent, serviceName, startTime, ignoreActiveScope);

            return(_scopeManager.Activate(span, finishOnClose));
        }
Exemplo n.º 23
0
 public void Init(ITags view, bool IsPostBack)
 {
     _view = view;
     DetermineClientState();
 }
Exemplo n.º 24
0
 public MetricsObserver(string observerName, string diagnosticName, IMetricsOptions options, IStats censusStats, ITags censusTags, ILogger logger = null)
     : base(observerName, diagnosticName, logger)
 {
     ViewManager   = censusStats.ViewManager;
     StatsRecorder = censusStats.StatsRecorder;
     Tagger        = censusTags.Tagger;
     Options       = options;
 }
Exemplo n.º 25
0
    public static Activity StartActivityWithTags(this ActivitySource activitySource, string operationName, ITags tags)
    {
        var activity = activitySource.StartActivity(operationName);

        // Apply tags
        if (tags != null)
        {
            foreach (var entry in tags.GetAllTags())
            {
                activity.SetTag(entry.Key, entry.Value);
            }
        }

        return(activity);
    }
Exemplo n.º 26
0
 public void Init(ITags view, bool IsPostBack)
 {
     _view = view;
     _view.SetTitle(Tag.GetTagByID(_webContext.TagID).Name);
     _view.LoadUI(SystemObjectTag.GetSystemObjectsByTagID(_webContext.TagID));
 }
Exemplo n.º 27
0
 /// <summary>
 /// Get all Tags
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='orderby'>
 /// &lt;p&gt;&lt;a href='#queryoptions'&gt;Sorts&lt;/a&gt; the result in
 /// ascending order by the supplied property.&lt;/p&gt;&lt;p&gt;Valid values
 /// are: &lt;strong&gt;TagId&lt;/strong&gt; (default),
 /// &lt;strong&gt;Text&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;Note:
 /// &lt;strong&gt;orderby&lt;/strong&gt; and
 /// &lt;strong&gt;orderbydesc&lt;/strong&gt; are mutually exclusive.&lt;/p&gt;
 /// </param>
 /// <param name='orderbydesc'>
 /// &lt;p&gt;&lt;a href='#queryoptions'&gt;Sorts&lt;/a&gt; the result in
 /// descending order by the supplied property.&lt;/p&gt;&lt;p&gt;Valid values
 /// are: &lt;strong&gt;TagId&lt;/strong&gt; (default),
 /// &lt;strong&gt;Text&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;Note:
 /// &lt;strong&gt;orderby&lt;/strong&gt; and
 /// &lt;strong&gt;orderbydesc&lt;/strong&gt; are mutually exclusive.&lt;/p&gt;
 /// </param>
 /// <param name='accountAccountId'>
 /// &lt;p&gt;&lt;a href="#queryoptions"&gt;Filters&lt;/a&gt; the result by
 /// Account.AccountId using the supplied operation and
 /// value.&lt;/p&gt;&lt;p&gt;Valid operations are:
 /// &lt;strong&gt;eq(int)&lt;/strong&gt;&lt;/p&gt;
 /// </param>
 /// <param name='top'>
 /// &lt;a href="#queryoptions"&gt;Query paging&lt;/a&gt; Returns the maximum
 /// number of entities. Default and max value is 10000
 /// </param>
 /// <param name='skip'>
 /// &lt;a href="#queryoptions"&gt;Query paging&lt;/a&gt; Skips this number of
 /// entities
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task <object> GetCollectionAsyncByqueryOptionsAsync(this ITags operations, string orderby = "TagId", string orderbydesc = default(string), string accountAccountId = default(string), int?top = 10000, int?skip = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     using (var _result = await operations.GetCollectionAsyncByqueryOptionsWithHttpMessagesAsync(orderby, orderbydesc, accountAccountId, top, skip, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 28
0
 public TagsController(ITags tags, ILogger <TagsController> logger)
 {
     this.tags   = tags;
     this.logger = logger;
 }
Exemplo n.º 29
0
 public HomeController(ITags tags)
 {
     _tags = tags;
 }