internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: open-telemetry/opentelemetry-python

Issue:
Additional context for `Mixed types x and y in attribute value sequence` warnings
**Is your feature request related to a problem?**
I'm getting a whole lot of warnings like

```
opentelemetry.attributes.Mixed types str and int in attribute value sequence
```

But they're missing context in order to resolve them. I'd like to know what attribute it is that has mixed types.

**Describe the solution you'd like**
Include `key` value in the message to add some more context and give a better chance to resolve the warning.

**Describe alternatives you've considered**

None

**Additional context**

Log is emitted from the lines below

https://github.com/open-telemetry/opentelemetry-python/blob/e0e6a3a940c16c1df6493e258ccfbc57ac38cf96/opentelemetry-api/src/opentelemetry/attributes/__init__.py#L86-L91


Discussion:

Resolving patch:
diff --git a/opentelemetry-api/src/opentelemetry/attributes/__init__.py b/opentelemetry-api/src/opentelemetry/attributes/__init__.py
--- a/opentelemetry-api/src/opentelemetry/attributes/__init__.py
+++ b/opentelemetry-api/src/opentelemetry/attributes/__init__.py
@@ -85,7 +85,8 @@ def _clean_attribute(
             # use equality instead of isinstance as isinstance(True, int) evaluates to True
             elif element_type != sequence_first_valid_type:
                 _logger.warning(
-                    "Mixed types %s and %s in attribute value sequence",
+                    "Attribute %r mixes types %s and %s in attribute value sequence",
+                    key,
                     sequence_first_valid_type.__name__,
                     type(element).__name__,
                 )


Test patch:
Repository: open-telemetry/opentelemetry-python

Issue:
Export ExponentialBucketHistogramAggregation in opentelemetry.sdk.metrics.view
**Is your feature request related to a problem?**
We want to use the Exponential Histograms features publicly released in version [1.17.0](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md#version-1170038b0-2023-03-22).

**Describe the solution you'd like**
I'd like to use the public API.

**Describe alternatives you've considered**
One can import it from `opentelemetry.sdk.metrics._internal.aggregation`

**Additional context**
Currently the code in https://github.com/open-telemetry/opentelemetry-python/blob/b6a1b22fa65f41bdefb01d64b76e5e793d039f6d/opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py#L25-L33 is not exporting the newly added `ExponentialBucketHistogramAggregation`

Export ExponentialBucketHistogramAggregation in opentelemetry.sdk.metrics.view
**Is your feature request related to a problem?**
We want to use the Exponential Histograms features publicly released in version [1.17.0](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md#version-1170038b0-2023-03-22).

**Describe the solution you'd like**
I'd like to use the public API.

**Describe alternatives you've considered**
One can import it from `opentelemetry.sdk.metrics._internal.aggregation`

**Additional context**
Currently the code in https://github.com/open-telemetry/opentelemetry-python/blob/b6a1b22fa65f41bdefb01d64b76e5e793d039f6d/opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py#L25-L33 is not exporting the newly added `ExponentialBucketHistogramAggregation`



Discussion:

Resolving patch:
diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py
--- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py
+++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py
@@ -17,6 +17,7 @@
     DefaultAggregation,
     DropAggregation,
     ExplicitBucketHistogramAggregation,
+    ExponentialBucketHistogramAggregation,
     LastValueAggregation,
     SumAggregation,
 )
@@ -27,6 +28,7 @@
     "DefaultAggregation",
     "DropAggregation",
     "ExplicitBucketHistogramAggregation",
+    "ExponentialBucketHistogramAggregation",
     "LastValueAggregation",
     "SumAggregation",
     "View",


Test patch:
Repository: open-telemetry/opentelemetry-python

Issue:
eachdist fails to update version correctly
The update script fails to update the version when the dep in `pyproject.toml` has a version matcher other than `=` for instance, `1.16.0.dev` will not get updated to `1.16.0` if the dep were to be specified as `opentelemetry-sdk >= 1.16.0.dev`. Refer to this commit https://github.com/open-telemetry/opentelemetry-python/pull/3177/commits/f3b645cab2f59d2a1e0e20254dd7a7cedb47fca3 and this workflow run https://github.com/open-telemetry/opentelemetry-python/actions/runs/4187061654/jobs/7256403807


Discussion:

Resolving patch:
diff --git a/scripts/eachdist.py b/scripts/eachdist.py
--- a/scripts/eachdist.py
+++ b/scripts/eachdist.py
@@ -576,13 +576,18 @@ def update_version_files(targets, version, packages):
 
 def update_dependencies(targets, version, packages):
     print("updating dependencies")
-    targets = filter_packages(targets, packages)
+    # PEP 508 allowed specifier operators
+    operators = ['==', '!=', '<=', '>=', '<', '>', '===', '~=', '=']
+    operators_pattern = '|'.join(re.escape(op) for op in operators)
+
     for pkg in packages:
+        search = rf"({basename(pkg)}[^,]*)({operators_pattern})(.*\.dev)"
+        replace = r"\1\2 " + version
         update_files(
             targets,
             "pyproject.toml",
-            rf"({basename(pkg)}.*)==(.*)",
-            r"\1== " + version + '",',
+            search,
+            replace,
         )
 
 


Test patch:
Repository: open-telemetry/opentelemetry-python

Issue:
Reserved attribute seems to be out of sync for message
https://github.com/open-telemetry/opentelemetry-python/blob/e00306206ea25cf8549eca289e39e0b6ba2fa560/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py#L290

seems to have getMessage whereas https://docs.python.org/3/library/logging.html#logrecord-attributes has message as reserved attribute. This causes "message" to appear in record having exact same data as msg 


Discussion:

Resolving patch:
diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py
--- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py
+++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py
@@ -296,7 +296,7 @@ def force_flush(self, timeout_millis: int = 30000) -> bool:
         "exc_text",
         "filename",
         "funcName",
-        "getMessage",
+        "message",
         "levelname",
         "levelno",
         "lineno",


Test patch:
Repository: open-telemetry/opentelemetry-python

Issue:
View instrument selection criteria should accept unit
Ref: https://github.com/open-telemetry/opentelemetry-specification/pull/3184

... and update the spec-compliance-matrix when this is done.




Discussion:
Can I take this issue?

Resolving patch:
diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/view.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/view.py
--- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/view.py
+++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/view.py
@@ -76,6 +76,9 @@ class View:
             corresponding metrics stream. If `None` an instance of
             `DefaultAggregation` will be used.
 
+        instrument_unit: This is an instrument matching attribute: the unit the
+            instrument must have to match the view.
+
     This class is not intended to be subclassed by the user.
     """
 
@@ -92,10 +95,12 @@ def __init__(
         description: Optional[str] = None,
         attribute_keys: Optional[Set[str]] = None,
         aggregation: Optional[Aggregation] = None,
+        instrument_unit: Optional[str] = None,
     ):
         if (
             instrument_type
             is instrument_name
+            is instrument_unit
             is meter_name
             is meter_version
             is meter_schema_url
@@ -122,6 +127,7 @@ def __init__(
         self._name = name
         self._instrument_type = instrument_type
         self._instrument_name = instrument_name
+        self._instrument_unit = instrument_unit
         self._meter_name = meter_name
         self._meter_version = meter_version
         self._meter_schema_url = meter_schema_url
@@ -143,6 +149,10 @@ def _match(self, instrument: Instrument) -> bool:
             if not fnmatch(instrument.name, self._instrument_name):
                 return False
 
+        if self._instrument_unit is not None:
+            if not fnmatch(instrument.unit, self._instrument_unit):
+                return False
+
         if self._meter_name is not None:
             if instrument.instrumentation_scope.name != self._meter_name:
                 return False


Test patch:
diff --git a/opentelemetry-sdk/tests/metrics/test_view.py b/opentelemetry-sdk/tests/metrics/test_view.py
--- a/opentelemetry-sdk/tests/metrics/test_view.py
+++ b/opentelemetry-sdk/tests/metrics/test_view.py
@@ -37,6 +37,15 @@ def test_instrument_name(self):
             View(instrument_name="instrument_name")._match(mock_instrument)
         )
 
+    def test_instrument_unit(self):
+
+        mock_instrument = Mock()
+        mock_instrument.configure_mock(**{"unit": "instrument_unit"})
+
+        self.assertTrue(
+            View(instrument_unit="instrument_unit")._match(mock_instrument)
+        )
+
     def test_meter_name(self):
 
         self.assertTrue(
Repository: open-telemetry/opentelemetry-python

Issue:
BLRP Export unsupressed.
**Describe your environment**
Using requests or urllib3 instrumentation.

**Steps to reproduce**
Use an Logs exporter that makes a network call with requests or urllib3. Instrument requests or urllib3. Produce logs telemetry. Check to see that the log export call is incorrectly tracked as part of the requests or urllib3 instrumentation's traces. For instance, using the Azure exporter:
```
from logging import getLogger
from azure.monitor.opentelemetry.exporter import (
    ApplicationInsightsSampler,
    AzureMonitorLogExporter,
    AzureMonitorTraceExporter,
)
from opentelemetry import trace
from opentelemetry._logs import get_logger_provider, set_logger_provider
from opentelemetry.instrumentation.requests import RequestsInstrumentor
from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.trace import get_tracer_provider, set_tracer_provider

# Setup Tracing
tracer_provider = TracerProvider(
    sampler=ApplicationInsightsSampler(),
)
set_tracer_provider(tracer_provider)
trace_exporter = AzureMonitorTraceExporter()
span_processor = BatchSpanProcessor(
    trace_exporter,
)
get_tracer_provider().add_span_processor(span_processor)

tracer = trace.get_tracer(__name__)

# Setup Logging
logger_provider = LoggerProvider()
set_logger_provider(logger_provider)
log_exporter = AzureMonitorLogExporter()
log_record_processor = BatchLogRecordProcessor(
    log_exporter,
)
get_logger_provider().add_log_record_processor(log_record_processor)
handler = LoggingHandler(logger_provider=get_logger_provider())
getLogger().addHandler(handler)

RequestsInstrumentor().instrument()

# Produce logging telemetry
getLogger(__name__).error("Test Error")
```

**What is the expected behavior?**
Export calls should be suppressed.

**What is the actual behavior?**
Export call is not suppressed.

**Additional context**
Add any other context about the problem here.



Discussion:

Resolving patch:
diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py
--- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py
+++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py
@@ -307,7 +307,7 @@ def _export_batch(self) -> int:
             record = self._queue.pop()
             self._log_records[idx] = record
             idx += 1
-        token = attach(set_value("suppress_instrumentation", True))
+        token = attach(set_value(_SUPPRESS_INSTRUMENTATION_KEY, True))
         try:
             self._exporter.export(self._log_records[:idx])  # type: ignore
         except Exception:  # pylint: disable=broad-except


Test patch:
Repository: open-telemetry/opentelemetry-python

Issue:
Allow use of "/" in Metrics Instrument Names, and with a 255 char limit
As per the recent specs change :
 
* Increase max instrument name length from 63 to 255: https://github.com/open-telemetry/opentelemetry-specification/pull/3648
* Instrument names can have "/" character: https://github.com/open-telemetry/opentelemetry-specification/pull/3684

Then update spec compliance matrix https://github.com/open-telemetry/opentelemetry-specification/blob/main/spec-compliance-matrix.md


Discussion:

Resolving patch:
diff --git a/opentelemetry-api/src/opentelemetry/metrics/_internal/instrument.py b/opentelemetry-api/src/opentelemetry/metrics/_internal/instrument.py
--- a/opentelemetry-api/src/opentelemetry/metrics/_internal/instrument.py
+++ b/opentelemetry-api/src/opentelemetry/metrics/_internal/instrument.py
@@ -38,7 +38,7 @@
 
 _logger = getLogger(__name__)
 
-_name_regex = re_compile(r"[a-zA-Z][-_.a-zA-Z0-9]{0,62}")
+_name_regex = re_compile(r"[a-zA-Z][-_./a-zA-Z0-9]{0,254}")
 _unit_regex = re_compile(r"[\x00-\x7F]{0,63}")
 
 


Test patch:
diff --git a/opentelemetry-api/tests/metrics/test_instruments.py b/opentelemetry-api/tests/metrics/test_instruments.py
--- a/opentelemetry-api/tests/metrics/test_instruments.py
+++ b/opentelemetry-api/tests/metrics/test_instruments.py
@@ -564,14 +564,13 @@ def test_observable_up_down_counter_callback(self):
         )
 
     def test_name_check(self):
-
         instrument = ChildInstrument("name")
 
         self.assertEqual(
             instrument._check_name_unit_description(
-                "a" * 63, "unit", "description"
+                "a" * 255, "unit", "description"
             )["name"],
-            "a" * 63,
+            "a" * 255,
         )
         self.assertEqual(
             instrument._check_name_unit_description(
@@ -591,12 +590,24 @@ def test_name_check(self):
             )["name"],
             "a_",
         )
+        self.assertEqual(
+            instrument._check_name_unit_description(
+                "a/", "unit", "description"
+            )["name"],
+            "a/",
+        )
 
-        self.assertIsNone(
+        # the old max length
+        self.assertIsNotNone(
             instrument._check_name_unit_description(
                 "a" * 64, "unit", "description"
             )["name"]
         )
+        self.assertIsNone(
+            instrument._check_name_unit_description(
+                "a" * 256, "unit", "description"
+            )["name"]
+        )
         self.assertIsNone(
             instrument._check_name_unit_description(
                 "Ñ", "unit", "description"
Repository: open-telemetry/opentelemetry-python

Issue:
CI failing spellcheck
CI is failing for this typo of "enhance": https://github.com/open-telemetry/opentelemetry-python/blob/7f8c75d4de1a53beec59eed21cf95d2aa6428969/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py#L418

See failed run https://github.com/open-telemetry/opentelemetry-python/actions/runs/6396708356/job/17363097101?pr=3413


Discussion:

Resolving patch:
diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py
--- a/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py
+++ b/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py
@@ -415,7 +415,7 @@ class _OTelSDKConfigurator(_BaseConfigurator):
 
     NOTE: This class should not be instantiated nor should it become an entry
     point on the `opentelemetry-sdk` package. Instead, distros should subclass
-    this Configurator and enchance it as needed.
+    this Configurator and enhance it as needed.
     """
 
     def _configure(self, **kwargs):


Test patch:
Repository: open-telemetry/opentelemetry-python

Issue:
NoOpLoggerProvider has no `force_flush` in exit callback
**Describe your environment** Python 3.11, macOS Ventura

**Steps to reproduce**

1. Create a `LoggingHandler` without providing a `logger_provider`, use it, and log a message.
2. Run program

**What is the expected behavior?**

A clean exit.

**What is the actual behavior?**

```
Exception ignored in atexit callback: <function shutdown at 0x104e3ec00>
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/logging/__init__.py", line 2192, in shutdown
    h.flush()
  File "/Users/pro2023/pyenv-otel/lib/python3.11/site-packages/opentelemetry/sdk/_logs/_internal/__init__.py", line 548, in flush
    self._logger_provider.force_flush()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoOpLoggerProvider' object has no attribute 'force_flush'
```


Discussion:

Resolving patch:
diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py
--- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py
+++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py
@@ -553,9 +553,10 @@ def emit(self, record: logging.LogRecord) -> None:
 
     def flush(self) -> None:
         """
-        Flushes the logging output.
+        Flushes the logging output. Skip flushing if logger is NoOp.
         """
-        self._logger_provider.force_flush()
+        if not isinstance(self._logger, NoOpLogger):
+            self._logger_provider.force_flush()
 
 
 class Logger(APILogger):


Test patch:
diff --git a/opentelemetry-sdk/tests/logs/test_handler.py b/opentelemetry-sdk/tests/logs/test_handler.py
--- a/opentelemetry-sdk/tests/logs/test_handler.py
+++ b/opentelemetry-sdk/tests/logs/test_handler.py
@@ -79,6 +79,19 @@ def test_log_record_emit_noop(self):
             logger.warning("Warning message")
         handler_mock._translate.assert_not_called()
 
+    def test_log_flush_noop(self):
+
+        no_op_logger_provider = NoOpLoggerProvider()
+        no_op_logger_provider.force_flush = Mock()
+
+        logger = get_logger(logger_provider=no_op_logger_provider)
+
+        with self.assertLogs(level=logging.WARNING):
+            logger.warning("Warning message")
+
+        logger.handlers[0].flush()
+        no_op_logger_provider.force_flush.assert_not_called()
+
     def test_log_record_no_span_context(self):
         emitter_provider_mock = Mock(spec=LoggerProvider)
         emitter_mock = APIGetLogger(
Repository: open-telemetry/opentelemetry-python

Issue:
Non-executable files with shebangs in the repository
**Describe your environment**

(Nothing relevant to describe)

**Steps to reproduce**

```
$ rg -l '^#!' | xargs ls -l
-rwxr-xr-x. 1 ben ben  1420 Jul  5  2023 docs/examples/django/manage.py
-rw-r--r--. 1 ben ben  1300 Jul  5  2023 docs/examples/opencensus-exporter-tracer/collector.py
-rwxr-xr-x. 1 ben ben  1485 Jul  5  2023 docs/examples/opentracing/main.py
-rwxr-xr-x. 1 ben ben   853 Jul 13  2023 scripts/build.sh
-rwxr-xr-x. 1 ben ben  1163 Jan 22 10:06 scripts/coverage.sh
-rwxr-xr-x. 1 ben ben 20741 Jul 13  2023 scripts/eachdist.py
-rwxr-xr-x. 1 ben ben   215 Jul  5  2023 scripts/generate_website_docs.sh
-rwxr-xr-x. 1 ben ben  2377 Jan 22 10:06 scripts/proto_codegen.sh
-rwxr-xr-x. 1 ben ben  1928 Jan 22 10:06 scripts/semconv/generate.sh
-rwxr-xr-x. 1 ben ben   945 Jul  5  2023 scripts/tracecontext-integration-test.sh
-rw-r--r--. 1 ben ben  2519 Jan 22 11:43 tests/w3c_tracecontext_validation_server.py
```

Note that two files have shebang lines (`#!`) but do not have the executable bit set, which makes the shebang lines useless.

**What is the expected behavior?**

Files should either be non-executable and have no shebang line, or be executable and have a shebang line.

**What is the actual behavior?**

The following files are not executable and have useless shebang lines:

- `docs/examples/opencensus-exporter-tracer/collector.py`
- `tests/w3c_tracecontext_validation_server.py`

**Additional context**

This is a trivial thing, but I would like to fix it in a PR – either by setting the executable bit on these two files, or by removing the useless shebang lines. Both files are “script-like,” i.e. they have `if __name__ == "__main__"` or have useful side effects. Which approach would you prefer?


Discussion:
@musicinmybrain 

Thanks for looking into this. If you could remove the shebang lines that would be preferred. Feel free to open up a pr to address this.

Resolving patch:
diff --git a/docs/examples/opencensus-exporter-tracer/collector.py b/docs/examples/opencensus-exporter-tracer/collector.py
--- a/docs/examples/opencensus-exporter-tracer/collector.py
+++ b/docs/examples/opencensus-exporter-tracer/collector.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python3
-#
 # Copyright The OpenTelemetry Authors
 #
 # Licensed under the Apache License, Version 2.0 (the "License");


Test patch:
diff --git a/tests/w3c_tracecontext_validation_server.py b/tests/w3c_tracecontext_validation_server.py
--- a/tests/w3c_tracecontext_validation_server.py
+++ b/tests/w3c_tracecontext_validation_server.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python3
-#
 # Copyright The OpenTelemetry Authors
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
Repository: open-telemetry/opentelemetry-python

Issue:
PeriodicExportingMetricReader: Incorrect ValueError message of not accepting infinity as interval value
When an invalid value is entered as `interval` for PeriodicExportingMetricReader, there is an error message generated [here](https://github.com/open-telemetry/opentelemetry-python/blob/8ed71b15fb8fc9534529da8ce4a21e686248a8f3/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py#L428) that states:

```
                f"interval value {self._export_interval_millis} is invalid \
                and needs to be larger than zero and lower than infinity."
```

However, this is not correct and **misleading** as `math.inf` can be provided as a value (which will effectively set the interval to infinity and make periodic exporting metric reader to not move in interval, which is something that this [PR](https://github.com/open-telemetry/opentelemetry-python/pull/3059) addressed.

**What is the expected behavior?**
Error message should state:

```
                f"interval value {self._export_interval_millis} is invalid \
                and needs to be larger than zero and lower or equal to infinity."
```




Discussion:

Resolving patch:
diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py
--- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py
+++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py
@@ -496,7 +496,7 @@ def __init__(
         elif self._export_interval_millis <= 0:
             raise ValueError(
                 f"interval value {self._export_interval_millis} is invalid \
-                and needs to be larger than zero and lower than infinity."
+                and needs to be larger than zero."
             )
 
     def _at_fork_reinit(self):


Test patch: