-
Notifications
You must be signed in to change notification settings - Fork 932
Add docker-tests coverage of metrics export #5030
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
Merged
xrmx
merged 16 commits into
open-telemetry:main
from
tammy-baylis-swi:add-docker-tests-metrics-export
May 14, 2026
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2f96d45
Add docker-tests metrics export
tammy-baylis-swi 7757ae4
Update dc and otcollector
tammy-baylis-swi ec51200
Add test_metrics_export_batch_size_two tests http,grpc
tammy-baylis-swi d33f49c
Changelog
tammy-baylis-swi cb9b481
Update tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py
tammy-baylis-swi 415ca04
Update tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py
tammy-baylis-swi eab141e
Merge branch 'main' into add-docker-tests-metrics-export
tammy-baylis-swi 7678350
Fix import
tammy-baylis-swi 016e12f
Merge branch 'main' into add-docker-tests-metrics-export
tammy-baylis-swi ce7c95b
Merge branch 'main' into add-docker-tests-metrics-export
tammy-baylis-swi 5e27824
Merge branch 'main' into add-docker-tests-metrics-export
tammy-baylis-swi 5673b1c
Merge branch 'main' into add-docker-tests-metrics-export
tammy-baylis-swi f905534
Merge branch 'main' into add-docker-tests-metrics-export
lzchen e942a8c
Merge branch 'main' into add-docker-tests-metrics-export
xrmx 875b68d
Update CHANGELOG.md
xrmx 4ac765d
Create 5030.added
xrmx 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
55 changes: 52 additions & 3 deletions
55
tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_http_exporter_functional.py
This file contains hidden or 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 |
|---|---|---|
| @@ -1,26 +1,75 @@ | ||
| # Copyright The OpenTelemetry Authors | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from opentelemetry import trace | ||
| from opentelemetry import metrics, trace | ||
| from opentelemetry.exporter.otlp.proto.http.metric_exporter import ( | ||
| OTLPMetricExporter, | ||
| ) | ||
| from opentelemetry.exporter.otlp.proto.http.trace_exporter import ( | ||
| OTLPSpanExporter, | ||
| ) | ||
| from opentelemetry.sdk.metrics import MeterProvider | ||
| from opentelemetry.sdk.trace import TracerProvider | ||
| from opentelemetry.test.globals_test import ( | ||
| reset_metrics_globals, | ||
| reset_trace_globals, | ||
| ) | ||
| from opentelemetry.test.test_base import TestBase | ||
|
|
||
| from . import BaseTestOTLPExporter, ExportStatusSpanProcessor | ||
| from . import ( | ||
| BaseTestOTLPExporter, | ||
| ExportStatusMetricReader, | ||
| ExportStatusSpanProcessor, | ||
| ) | ||
|
|
||
|
|
||
| class BatchCountingHTTPExporter(OTLPMetricExporter): | ||
| """HTTP exporter that counts actual batch export calls for testing.""" | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
| self.export_call_count = 0 | ||
|
|
||
| def _export(self, *args, **kwargs): | ||
| self.export_call_count += 1 | ||
| return super()._export(*args, **kwargs) | ||
|
|
||
|
|
||
| class TestOTLPHTTPExporter(BaseTestOTLPExporter, TestBase): | ||
| # pylint: disable=no-self-use | ||
| def get_span_processor(self): | ||
| return ExportStatusSpanProcessor(OTLPSpanExporter()) | ||
|
|
||
| def get_metric_reader(self): | ||
| return ExportStatusMetricReader( | ||
| OTLPMetricExporter(max_export_batch_size=2) | ||
| ) | ||
|
|
||
| def setUp(self): | ||
| super().setUp() | ||
|
|
||
| reset_trace_globals() | ||
| trace.set_tracer_provider(TracerProvider()) | ||
| self.tracer = trace.get_tracer(__name__) | ||
| self.span_processor = self.get_span_processor() | ||
|
|
||
| trace.get_tracer_provider().add_span_processor(self.span_processor) | ||
|
|
||
| reset_metrics_globals() | ||
| self.metric_reader = self.get_metric_reader() | ||
| meter_provider = MeterProvider(metric_readers=[self.metric_reader]) | ||
| metrics.set_meter_provider(meter_provider) | ||
| self.meter = metrics.get_meter(__name__) | ||
|
|
||
| def test_metrics_export_batch_size_two(self): | ||
| """Test metrics max_export_batch_size=2 directly through HTTP exporter""" | ||
| batch_counter = BatchCountingHTTPExporter( | ||
| endpoint="http://localhost:4318/v1/metrics", | ||
| max_export_batch_size=2, | ||
| ) | ||
| metrics_data, data_points = self._create_test_metrics_data( | ||
| num_data_points=6 | ||
| ) | ||
| result = batch_counter.export(metrics_data) | ||
| self._verify_batch_export_result( | ||
| result, data_points, batch_counter, max_batch_size=2 | ||
| ) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.