Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[processor/spanmetrics] use LRU cache for metricKeyToDimensions #6503

Merged
merged 50 commits into from
Dec 17, 2021

Conversation

chenzhihao
Copy link
Contributor

@chenzhihao chenzhihao commented Dec 3, 2021

Description:
Adding a feature - use LRU cache for metricKeyToDimensions. Hence its memory usage will be bounded

Link to tracking Issue:
It partially addresses the issue: #2179

Testing:
New unit tests for the cache implementation.
Existing unit tests are updated to verify existing processing logic is still as expected.

Documentation:
The usage of metric_key_to_dimensions_cache_size configuration field is added in README.md

@chenzhihao chenzhihao changed the title use LRU cache for metricKeyToDimensions [DRAFT] use LRU cache for metricKeyToDimensions Dec 3, 2021
@chenzhihao chenzhihao force-pushed the OBC-259_LRU branch 2 times, most recently from 81caa62 to 0ac8a38 Compare December 6, 2021 00:43
@chenzhihao chenzhihao changed the title [DRAFT] use LRU cache for metricKeyToDimensions DRAFT - [exporter/spanmetricsprocessor] use LRU cache for metricKeyToDimensions Dec 6, 2021
@Tenaria
Copy link

Tenaria commented Dec 6, 2021

lgtm

processor/spanmetricsprocessor/config.go Outdated Show resolved Hide resolved
processor/spanmetricsprocessor/config.go Outdated Show resolved Hide resolved
processor/spanmetricsprocessor/processor.go Outdated Show resolved Hide resolved
@jamesmoessis
Copy link
Contributor

Another thing, why is the name of the PR exporter/spanmetricsproccesor, shouldn't it be processor/spanmetricsprocessor? Or just spanmetricsprocessor.

@chenzhihao chenzhihao changed the title DRAFT - [exporter/spanmetricsprocessor] use LRU cache for metricKeyToDimensions [exporter/spanmetricsprocessor] use LRU cache for metricKeyToDimensions Dec 6, 2021
@chenzhihao chenzhihao marked this pull request as ready for review December 6, 2021 06:20
@chenzhihao chenzhihao requested a review from a team December 6, 2021 06:20
Copy link
Contributor

@MovieStoreGuy MovieStoreGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy the changes made are safe to added back to the collector.

@jpkrohling
Copy link
Member

jpkrohling commented Dec 14, 2021

There seem to be merge conflicts for this PR.

@chenzhihao
Copy link
Contributor Author

Hey @jpkrohling , it should be ready to be merged now. Thanks!

CHANGELOG.md Outdated Show resolved Hide resolved
processor/spanmetricsprocessor/internal/cache/cache.go Outdated Show resolved Hide resolved
processor/spanmetricsprocessor/processor.go Outdated Show resolved Hide resolved
processor/spanmetricsprocessor/processor.go Outdated Show resolved Hide resolved
processor/spanmetricsprocessor/processor.go Show resolved Hide resolved
chenzhihao and others added 5 commits December 15, 2021 22:16
Co-authored-by: Albert <26584478+albertteoh@users.noreply.github.com>
Co-authored-by: Albert <26584478+albertteoh@users.noreply.github.com>
Co-authored-by: Albert <26584478+albertteoh@users.noreply.github.com>
Co-authored-by: Albert <26584478+albertteoh@users.noreply.github.com>
@jpkrohling jpkrohling changed the title [processor/spanmetricsprocessor] use LRU cache for metricKeyToDimensions [processor/spanmetrics] use LRU cache for metricKeyToDimensions Dec 16, 2021
@jpkrohling jpkrohling assigned jpkrohling and unassigned bogdandrutu Dec 16, 2021
@jpkrohling jpkrohling self-requested a review December 16, 2021 09:25
@jpkrohling
Copy link
Member

Once the last points are sorted out, ping me again to review/merge this one.

Copy link
Contributor

@albertteoh albertteoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chenzhihao
Copy link
Contributor Author

@jpkrohling Could you please merge it? Thanks.

@jpkrohling jpkrohling merged commit 6b96a9e into open-telemetry:main Dec 17, 2021
m, err := p.buildMetrics()
if err != nil {
return err
}

// Firstly, export metrics to avoid being impacted by downstream trace processor errors/latency.
if err := p.metricsExporter.ConsumeMetrics(ctx, *m); err != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not consider periodic build and consume metric here?
Each trace goes to export metrics ( for example: remote write、otlp exporter ), will the cost be slightly higher?

povilasv referenced this pull request in coralogix/opentelemetry-collector-contrib Dec 19, 2022
* prepare release 0.64.0

* Prepare stable for version v0.64.0

* Prepare beta for version v0.64.0

* add multimod changes

* changelog entries

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants