-
Notifications
You must be signed in to change notification settings - Fork 775
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
Change InMemoryExporter to clear collection before exporting Metrics #2937
Closed
Closed
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
f944a1c
Merge pull request #1 from open-telemetry/main
TimothyMothra ba726c5
Merge branch 'open-telemetry:main' into main
TimothyMothra 68d1977
Merge branch 'open-telemetry:main' into main
TimothyMothra 9dcb839
poc for fix to InMemoryExporter
TimothyMothra 34d15ec
Revert "poc for fix to InMemoryExporter"
TimothyMothra 436f0dc
Merge branch 'open-telemetry:main' into main
TimothyMothra 48bf1e9
change InMemoryExporter. update tests. add more tests.
TimothyMothra 2d06efc
cleanup
TimothyMothra 1617248
cleanup
TimothyMothra 8aa4885
Merge branch 'main' into 2361
TimothyMothra 4723675
cleanup tests
TimothyMothra f4b40fd
changelog
TimothyMothra 70fc774
Merge branch 'main' into 2361
TimothyMothra 99f3aa0
Update README.md
TimothyMothra 93db30d
Update InMemoryExporter.cs
TimothyMothra d080e27
fix markdownlint
TimothyMothra 31c7be9
Merge branch 'main' into 2361
cijothomas 37aa2af
Update README.md
TimothyMothra d8a8b6e
cleanup
TimothyMothra d6b488c
Merge branch '2361' of https://github.com/TimothyMothra/opentelemetry…
TimothyMothra 3078c97
Delete InMemoryExporterTests.cs
TimothyMothra b0a07aa
Merge branch 'main' into 2361
TimothyMothra 598aa0d
Merge branch 'main' into 2361
TimothyMothra 585177a
Merge branch 'main' into 2361
TimothyMothra 8fa1aad
Merge branch 'main' into 2361
TimothyMothra 6de7a75
Merge branch 'main' into 2361
cijothomas 4f8de4d
Update docs/metrics/extending-the-sdk/README.md
TimothyMothra bffb822
Update docs/metrics/extending-the-sdk/README.md
TimothyMothra 1fa45bd
Update src/OpenTelemetry.Exporter.InMemory/InMemoryExporter.cs
TimothyMothra 79c1357
Merge branch 'main' into 2361
TimothyMothra fc33bb2
Update docs/metrics/extending-the-sdk/README.md
TimothyMothra 58dccbc
markdownlint
TimothyMothra 021f308
Merge branch 'main' into 2361
TimothyMothra 87ee7f7
Merge branch 'main' into 2361
cijothomas b16c6bc
Merge branch 'main' into 2361
TimothyMothra a6e5140
Merge branch 'main' into 2361
TimothyMothra a86f858
Merge branch 'main' into 2361
TimothyMothra 05aa392
Merge branch 'main' into 2361
TimothyMothra 697fb9f
discussing an alternate approach
TimothyMothra 6edcc26
merge main
TimothyMothra 4f3f330
clean up public api
TimothyMothra c91f522
remove whitespace
TimothyMothra 735b297
remove whitespace
TimothyMothra 5de8c9c
fix whitespace
TimothyMothra 83af046
update changelog
TimothyMothra cfb8773
Merge branch 'main' into 2361
TimothyMothra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/OpenTelemetry.Exporter.InMemory/InMemoryMetricExporter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// <copyright file="InMemoryMetricExporter.cs" company="OpenTelemetry Authors"> | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System.Collections.Generic; | ||
|
||
using OpenTelemetry.Metrics; | ||
|
||
namespace OpenTelemetry.Exporter | ||
{ | ||
internal class InMemoryMetricExporter : InMemoryExporter<Metric> | ||
{ | ||
public InMemoryMetricExporter(ICollection<Metric> exportedItems) | ||
: base(exportedItems) | ||
{ | ||
} | ||
|
||
public override ExportResult Export(in Batch<Metric> batch) | ||
{ | ||
// By design, The MetricApi reuses Metrics (MetricReader.metricsCurrentBatch). | ||
// This means that exported Metrics will always reflect the latest values. | ||
// Here, we clear the exported collection to prevent populating | ||
// this with duplicate instances of the same Metric. | ||
this.ExportedItems.Clear(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we (InMemoryExporter) does the clearing:
We could simply let the user do this, if they chose to. And document this in the readme. |
||
|
||
return base.Export(batch); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can add comment here.