Skip to content
This repository was archived by the owner on Dec 23, 2023. It is now read-only.
This repository was archived by the owner on Dec 23, 2023. It is now read-only.

Avoid unnecessary calls to .toString in ViewData.checkAggregation #1265

@steveniemitz

Description

@steveniemitz

Please answer these questions before submitting a bug report.

What version of OpenCensus are you using?

0.12.2, but present up to current version

What JVM are you using (java -version)?

java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

I ran into this randomly running a CPU profiler on a live instance running OpenCensus 0.12.2. We use a custom exporter to export OpenCensus metrics into our own system. I noticed that a lot of CPU time was spent in ViewData.checkAggregation (https://github.com/census-instrumentation/opencensus-java/blob/master/api/src/main/java/io/opencensus/stats/ViewData.java#L252). Specific to our use case, we create Distribution objects with ~10,000 buckets to get high precision on our percentile calculations. createErrorMessageForAggregation is called for each View instance, regardless if the error message will be used or not. This then calls .toString on the Distribution instance, which calls toString on the bucket boundaries, which in my case was very large.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions