census-instrumentation / opencensus-java

A stats collection and distributed tracing framework
https://opencensus.io
Apache License 2.0
673 stars 202 forks source link

Stackdriver: don't write cumulative metrics if they haven't changed #2041

Closed ulfjack closed 4 years ago

ulfjack commented 4 years ago

Is your feature request related to a problem? If so, please describe it.

Trying to minimize Stackdriver costs.

We have a cumulative metric that only changes rarely, but we'd still like to track it. The default settings seem to be that the cumulative metric is written every minute after the first time it's recorded to a non-zero value.

Describe the solution you'd like.

Don't write cumulative metrics to Stackdriver if there was no change from the most recent write.

Describe alternatives you've considered.

Additional context.

https://cloud.google.com/stackdriver/pricing#monitoring-costs

ulfjack commented 4 years ago

Technically, this also applies to other metrics but cumulative metrics are 10x more expensive than normal ones.

ulfjack commented 4 years ago

We believe that this change would reduce our metric volume (and costs) by 2-3x, and we could work on the implementation if there's interest in merging something like this.

nilebox commented 4 years ago

Please note that OpenCensus is not being actively developed anymore, and we are not accepting new feature requests. The project has been replaced with the OpenTelemetry project: https://opentelemetry.io/, so you may be interested in contributing there instead.

As you mentioned, the current workaround is to increase the reporting interval among others. You may also be interested in a more detailed breakdown for a similar issue: https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver/issues/270#issuecomment-657440772

ulfjack commented 4 years ago

So the old one is deprecated and the new one doesn't work yet? We're not going to switch to a 'beta' API for our production code, and we need to have this fixed now, so I went ahead, forked it, and then patched our fork. I can send you a PR or not, but based on your response I take it the answer is not.