-
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
fixing InMemoryExporter & Metrics bug. new class: MetricSnapshot. new ctor: InMemoryExporter(Func) #3266
fixing InMemoryExporter & Metrics bug. new class: MetricSnapshot. new ctor: InMemoryExporter(Func) #3266
Conversation
@cijothomas, this PR is meant to address your ask here: #3198 (comment)
|
Codecov Report
@@ Coverage Diff @@
## main #3266 +/- ##
==========================================
+ Coverage 85.22% 85.27% +0.04%
==========================================
Files 264 265 +1
Lines 9505 9541 +36
==========================================
+ Hits 8101 8136 +35
- Misses 1404 1405 +1
|
src/OpenTelemetry.Exporter.InMemory/InMemoryExporterMetricsExtensions.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.InMemory/InMemoryExporterMetricsExtensions.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.InMemory/InMemoryExporterMetricsExtensions.cs
Show resolved
Hide resolved
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.
Left 2 comments - please address them as well.
@cijothomas, i just updated the changelog;
|
Bug: #2361
Supersedes: #3198.
Changes
MetricSnapshot
. This is used for a strategic selective copy of the minimum members to facilitate unit testing.InMemoryExporter
to acceptFunc<Batch<T>, ExportResult
.This allows the export behavior to be fully replaced and provides greater flexibility for unit tests.
AddInMemoryExporter(ICollection<MetricSnapshot>)
added toInMemoryExporterMetricsExtensions
.Please provide a brief description of the changes here.
Metric
instances are reused by design.As a side effect, the
InMemoryExporter
will repeatedly export duplicates ofMetric
instances.Because of this,
Metric
s can be modified after export. See also: #2361 (comment)This change introduces a new class
MetricSnapshot
to be used in unit tests.This class is a collection of minimum members needed for existing unit tests.
An end user has the option to use either this copy or the original
Metric
.This change also introduces a new ctor
public InMemoryExporter(Func<Batch<T>, ExportResult> exportFunc)
.This is needed to export a type that differs from the
Batch
type, in this case convertingMetric
toMetricSnapshot
.For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changesAdditional Comment
This PR keeps the existing functionality, allowing users to export
Metric
s via theInMemoryExporter
.We have some tests that have a dependency on the
Metric
.PrometheusSerializerTests
needsMetric
to testPrometheusSerializer.WriteMetric()
OtlpMetricsExporterTests
needsBatch<Metric>
to testExportMetricsServiceRequest.AddMetrics()