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); }
/// <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); } }
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); } }
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); } }
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); }
public TagsController( ITags api, IAppSettings appSettings, ILogger <TagsController> logger) : base() { this.api = api; this.appSettings = appSettings; this.logger = logger; }
public static void SetTag(this ITags tags, string tag, bool onOff) { if (onOff) { tags.AddTag(tag); } else { tags.RemoveTag(tag); } }
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); }
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); } }
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(); }
// 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 })
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); }
/// <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)); }
/// <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()); }
public TestObserver(IMetricsOptions options, IStats censusStats, ITags censusTags, ILogger logger) : base("TestObserver", DIAGNOSTIC_NAME, options, censusStats, censusTags, logger) { }
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); }
/// <summary> /// Get all Tags /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='orderby'> /// <p><a href='#queryoptions'>Sorts</a> the result in /// ascending order by the supplied property.</p><p>Valid values /// are: <strong>TagId</strong> (default), /// <strong>Text</strong>.</p><p>Note: /// <strong>orderby</strong> and /// <strong>orderbydesc</strong> are mutually exclusive.</p> /// </param> /// <param name='orderbydesc'> /// <p><a href='#queryoptions'>Sorts</a> the result in /// descending order by the supplied property.</p><p>Valid values /// are: <strong>TagId</strong> (default), /// <strong>Text</strong>.</p><p>Note: /// <strong>orderby</strong> and /// <strong>orderbydesc</strong> are mutually exclusive.</p> /// </param> /// <param name='accountAccountId'> /// <p><a href="#queryoptions">Filters</a> the result by /// Account.AccountId using the supplied operation and /// value.</p><p>Valid operations are: /// <strong>eq(int)</strong></p> /// </param> /// <param name='top'> /// <a href="#queryoptions">Query paging</a> Returns the maximum /// number of entities. Default and max value is 10000 /// </param> /// <param name='skip'> /// <a href="#queryoptions">Query paging</a> 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()); }
public TagsManager(ITags tagsRepository) { Repo = tagsRepository; }
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); }
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)); }
public void Init(ITags view, bool IsPostBack) { _view = view; DetermineClientState(); }
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; }
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); }
public void Init(ITags view, bool IsPostBack) { _view = view; _view.SetTitle(Tag.GetTagByID(_webContext.TagID).Name); _view.LoadUI(SystemObjectTag.GetSystemObjectsByTagID(_webContext.TagID)); }
/// <summary> /// Get all Tags /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='orderby'> /// <p><a href='#queryoptions'>Sorts</a> the result in /// ascending order by the supplied property.</p><p>Valid values /// are: <strong>TagId</strong> (default), /// <strong>Text</strong>.</p><p>Note: /// <strong>orderby</strong> and /// <strong>orderbydesc</strong> are mutually exclusive.</p> /// </param> /// <param name='orderbydesc'> /// <p><a href='#queryoptions'>Sorts</a> the result in /// descending order by the supplied property.</p><p>Valid values /// are: <strong>TagId</strong> (default), /// <strong>Text</strong>.</p><p>Note: /// <strong>orderby</strong> and /// <strong>orderbydesc</strong> are mutually exclusive.</p> /// </param> /// <param name='accountAccountId'> /// <p><a href="#queryoptions">Filters</a> the result by /// Account.AccountId using the supplied operation and /// value.</p><p>Valid operations are: /// <strong>eq(int)</strong></p> /// </param> /// <param name='top'> /// <a href="#queryoptions">Query paging</a> Returns the maximum /// number of entities. Default and max value is 10000 /// </param> /// <param name='skip'> /// <a href="#queryoptions">Query paging</a> 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); } }
public TagsController(ITags tags, ILogger <TagsController> logger) { this.tags = tags; this.logger = logger; }
public HomeController(ITags tags) { _tags = tags; }