Skip to content

Commit

Permalink
Merge branch 'main' into protype-new-codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
lmolkova authored Apr 18, 2024
2 parents a949e72 + 5bd2e96 commit c8bf9f4
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
# Otherwise, set variable to the commit of your branch on
# opentelemetry-python-contrib which is compatible with these Core repo
# changes.
CONTRIB_REPO_SHA: 3c2788469834aa4f5976e1644d757f43d60bc219
CONTRIB_REPO_SHA: 9ce1c26d2732dfbdadbb492fc38c562dcd08ed2e
# This is needed because we do not clone the core repo in contrib builds anymore.
# When running contrib builds as part of core builds, we use actions/checkout@v2 which
# does not set an environment variable (simply just runs tox), which is different when
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#3785](https://github.com/open-telemetry/opentelemetry-python/pull/3785))
- Add capture the fully qualified type name for raised exceptions in spans
([#3837](https://github.com/open-telemetry/opentelemetry-python/pull/3837))
- Prometheus exporter sort label keys to prevent duplicate metrics when user input changes order
([#3698](https://github.com/open-telemetry/opentelemetry-python/pull/3698))
- Update semantic conventions to version 1.25.0.
Refactor semantic-convention structure:
- `SpanAttributes`, `ResourceAttributes`, and `MetricInstruments` are deprecated.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright The OpenTelemetry Authors
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ googleapis-common-protos==1.52.0
grpcio==1.56.0
gunicorn==20.0.4
itsdangerous==2.1.2
Jinja2==3.1.2
Jinja2==3.1.3
MarkupSafe==2.1.3
opentelemetry-api==1.20.0
opentelemetry-exporter-otlp==1.20.0
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/fork-process-model/flask-uwsgi/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ click==8.1.7
Flask==2.3.3
googleapis-common-protos==1.52.0
grpcio==1.56.0
gunicorn==20.0.4
gunicorn==22.0.0
itsdangerous==2.1.2
Jinja2==3.1.2
Jinja2==3.1.3
MarkupSafe==2.1.3
opentelemetry-api==1.20.0
opentelemetry-exporter-otlp==1.20.0
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ click==8.1.7
Deprecated==1.2.14
flaky==3.7.0
Flask==2.3.3
idna==3.4
idna==3.7
importlib-metadata==6.8.0
iniconfig==2.0.0
itsdangerous==2.1.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _translate_to_prometheus(
label_keys = []
label_values = []

for key, value in number_data_point.attributes.items():
for key, value in sorted(number_data_point.attributes.items()):
label_keys.append(self._sanitize(key))
label_values.append(self._check_value(value))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,24 @@ def test_target_info_sanitize(self):
prometheus_metric.samples[0].labels["ratio"],
"0.1",
)

def test_label_order_does_not_matter(self):
metric_reader = PrometheusMetricReader()
provider = MeterProvider(metric_readers=[metric_reader])
meter = provider.get_meter("getting-started", "0.1.2")
counter = meter.create_counter("counter")

counter.add(1, {"cause": "cause1", "reason": "reason1"})
counter.add(1, {"reason": "reason2", "cause": "cause2"})

prometheus_output = generate_latest().decode()

# All labels are mapped correctly
self.assertIn('cause="cause1"', prometheus_output)
self.assertIn('cause="cause2"', prometheus_output)
self.assertIn('reason="reason1"', prometheus_output)
self.assertIn('reason="reason2"', prometheus_output)

# Only one metric is generated
metric_count = prometheus_output.count("# HELP counter_total")
self.assertEqual(metric_count, 1)
5 changes: 3 additions & 2 deletions opentelemetry-api/src/opentelemetry/propagate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ def inject(
"""Uses the configured propagator to inject a Context into the carrier.
Args:
carrier: An object that contains a representation of HTTP
headers. Should be paired with setter, which
carrier: the medium used by Propagators to read
values from and write values to.
Should be paired with setter, which
should know how to set header values on the carrier.
context: An optional Context to use. Defaults to current
context if not set.
Expand Down

0 comments on commit c8bf9f4

Please sign in to comment.