GithubHelp home page GithubHelp logo

stackexchange / stackexchange.metrics Goto Github PK

View Code? Open in Web Editor NEW
137.0 137.0 25.0 7.08 MB

A .NET client to send metrics to a variety of metrics backends

License: MIT License

C# 99.60% PowerShell 0.34% Batchfile 0.05%

stackexchange.metrics's People

Contributors

bretcope avatar deanward81 avatar g3rv4 avatar hamvocke avatar lockwobr avatar mgravell avatar mhmd-azeez avatar nickcraver avatar nied avatar rossipedia avatar viveret avatar xsoheilalizadeh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stackexchange.metrics's Issues

GetMetricWithoutPrefix Method

An application may want to use a metric name prefix, but still have the ability to send some metrics without that prefix (global metrics). A method called GetMetricWithoutPrefix should be added which is identical to GetMetric except that it does not prepend the prefix.

Add IMetricGroup with type parameter variance

I've been taking advantage of the flexibility of passing around IDoubleGauges to keep the specific choice of gauge as configuration. Now, I'd like the ability to do the same with MetricGroups of them. This will require creating an interface IMetricGroup, since variant type annotations can only be applied to interfaces, not classes.

Here are the expected variances of the type parameters:

  • TMetric is clearly covariant, since you are using it for output. Namely, you want to be able to perform this assignment legally:

    IMetricGroup<bool, IDoubleGauge> group = GetMetricGroup<bool, EventGauge>(...);
    
  • The other type parameters are probably contravariant, since they are used as inputs. I believe you would like the following assignment to be legal:

    IMetricGroup<short, EventGauge> group = GetMetricGroup<int, EventGauge>(...);
    

The reasoning in the latter case can be considered like this: later calls to the group variable will only ever try to produce a new metric with a tag value of the derived type, but the MetricGroup can handle anything that's of the base type. I could also see the case made that it should just be invariant.

There's a big caveat to all of this: MetricGroup has mutable state. That means, if you cast to a group type with a more generic TMetric and then try to add an incompatible metric you'll get a runtime type error. Fortunately, the actual creation of the metric added is handled by the factory, which is type-specific, so I believe we're golden.

Adding this interface would lock in two specific aspects of the MetricGroup API:

  • we couldn't add a TMetric as an input parameter to a method on MetricGroup (e.g. void AddCustom(T1 key, TMetric metric))
  • we couldn't add a method that returns values of the other parameter types (e.g. IEnumerable<T1> GetKeys())

The first point seems like a reasonable limitation, but I could see how the second point is too limiting. That's why it might be useful to leave the other parameters as invariant. Also, I can't think of a great use case for really needing contravariance on those parameters, whereas for the covariance of TMetric the value is obvious.

This may be a little bit of effort, but I think it's worth it to promote MetricGroup to the same level of flexibility that the first-level gauges and counters have. Also I'm totally willing to hack at it, as long as the idea seems reasonable.

some docs

Metadata not being sent if MetricsCollector exists only for a short time

I have a small console app that gets triggered by windows after certain events. It's supposed to fire up, read a few files and record metrics, then close. It does minimal work and is active for a very short period of time.

What I've found is this means it doesn't reliably send meta data. I'm calling Shutdown() to ensure metrics are sent, but I couldn't find an equivalent for sending the meta data.

Is there something I'm missing?
Should the meta data be sent from within the Shutdown method (if it wasn't previously sent)?
Should a public method be made available to force sending meta data?

Fix Windows builds

Some wonkiness around Git versioning, may be fixed with a package upgrade

Turn Record Lock into Spin Wait

For aggregate gauges, there is a lock around the Record code, and the snapshot-swap. This could get contentious and expensive, and it's likely a good candidate for using SpinWait instead of a lock.

Feature request: more visibility of internal status

It is very hard to know whether it is working, as there are no API hooks that allow you to see metadata such as "last upload", "number of uploads", "number of metrics", or whatever - I don't know quite what should be exposed, but it would be good to have some mechanism to provide high level info; heck, just a ToString() status might be enough

Snapshot Gauge

Right now there are counters and aggregate gauges, but we also need snapshot gauges which are much simpler than aggregate gauges (they just report the last value).

They should also have the ability to hook into an event or callback which fires right before metrics are going to be snapshotted.

Suggestion: automatic type conversion on tags

For example, this fails:

            [BosunTag]
            public readonly int Response;

but this works fine:

            [BosunTag]
            public readonly string Response;

It seems like the library could perform the string conversion itself?

Try Streaming Metrics instead of using String.Join

I'm using String.Join to put together the metric list. It may or may not perform better if I just wrote the individual strings out to the response stream. Need to benchmark this before making any changes to the library.

Continuous Flush from Queue

Right now, flush is called when metrics are snapshotted, but it should really be running in an infinite loop which pauses for a second when the queue is empty, and five seconds when an API POST fails. This is the way SCollector is implemented.

Add Access Token Option

Bosun is going to start using an access token for sending metrics to it. This will take the form of an HTTP X-Access-Token header. BosunReporter should add this to the Options class as string AccessToken.

Send Type Metadata

I'm not sure yet what a good way to expose the metadata API via this library is going to be. In the meantime, I can at least start sending whether each metric is a gauge or a counter since that's already available.

Method to Remove Metric

Right now, there is no way to remove a metric from the reporter after it has been added. There should be a way to do this.

Question about the limits of bosun

Hi!

Are there people who use bosun and BosunReporter.NET in production to measure app metrics like service or page calls.

I am very interested in the kind of throughput that people are able to achieve.

So far, I only got the information that StackExchange's setup can cope with 15k entries per seconds which amount to about 3GB of data a day.

Suggestion: ZabbixMetricHandler

I'm looking for a metrics library to embed in my software. This one looks very promising, I like the way you can define custom metrics.

Our company uses Zabbix for it's monitoring purposes. Is there a way a ZabbixMetricHandler can be added to this library? I can put together a PR if you guys would accept that.

One last question, will this library also be available as a Nuget package on nuget.org?

Suggestion: Tags as properties with no attribute

I always thought [BosunTag] public readonly string TagName; was awkward. You have to remember the attribute, remember to use a field, rather than a property, and remember the readonly keyword.

If I remember right, the choice of readonly fields pre-dated C# 6 and its read-only auto-properties. Furthermore, since most fields/properties on a metric are intended to be tags, I think an opt-out system would be cleaner than opt-in.

If I were designing the Metric class today, I would probably support public string TagName { get; } with no attribute. Attributes could be used to opt-out a field/property or mark it as an optional tag.

Immutability is still important for preventing accidental duplicate metrics. So, at the very least, I would want to make sure the property has no setter, and perhaps see if it has a matching auto-generated field. You can always actively choose to shoot yourself in the foot with reflection, but you don't want people to accidentally do it.

Fyi, I noticed BosunTagAttribute was renamed to MetricTagAttribute, but there are still documentation references to [BosunTag] which should be cleaned up.


It's a breaking change and might not be worth the hassle (part of why I never did it), but since you're transforming BosunReporter into StackExchange.Metrics and there are other breaking changes, I thought now might be a good time to suggest it.

Default Tags

I was originally thinking that default tags could be handled as part of inheritance, but since there are three different metric classes (four if you include the base BosunMetric class) you can inherit from, it's going to get tedious to make users implement it that way. Instead, I'm going to provide a Dictionary<string, string> for default tags in BosunReporterOptions.

Custom Tag Name Replacer

I want to provide the ability to specify a Funct<string, string> which property names are run through to generate tag names.

The general convention for public member names in C# is PublicMemberName, but you want that to translate to public_member_name. This option would let you do that.

I should also provide a ToSnakeCase which can be used, since that seems like the most common use case.

Automatic Snapshot Interval

Need to implement a way to set a standard interval for snapshotting the metrics (in seconds). It would be neat to integrate schyntax into this when there is a C# port of that.

Count Aggregator

We want a _count suffix and aggregator for AggregateGauge which reports how many records were reported during the previous reporting interval.

I think I'm 90% done, but Bosun is complaining about something, so it's going to take a bit of debugging work. Should be done soon.

Require Background Exception Handler

The fact that BosunReporter has a background exception handler isn't even documented at the moment. Yet, it can crash your entire process if it's not set.

The next major version of BosunReporter should require it, rather than making it optional.

Implement Better Queue

Right now I'm just using a list, with some optimization hacks for when it's empty or you're dequeuing everything. A standard Queue or ConcurrentQueue didn't seem like good choices, but I should revisit this in the near future.

Feature request : utility tag sanitization method

Not all tag values are valid; the library includes features to check for invalid tags, but it would be nice if it exposed something on the public API to sanitize tag values (perhaps simply removing all illegal characters)

Make HttpJsonMetricHandler a generic HttpMetricHandler ?

Hi,

I am currently investigating if I could add a custom handler to write metrics to influxdb using the line protocol which consists of sending HTTP text data with 1 line per metric.

I was reading the code, and found HttpJsonMetricHandler which already handle sending data using HttpClient but specific to json. But the only code I found specific to json seems to be the content-type header, which is hardcoded.

Perhaps this class could be renamed to handle more generic http messages ?

I am certainly short-sighted and the ReadOnlySequenceContent type will certainly need more customization endpoint, for example to add custom auth headers... So in the end, I will still need to do a copy of the class.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.