prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Baggage span processor - key predicate
  This issue is to track adding a method of selecting what baggage key entries should be copied.
  
  Feedback in the JS contrib PR was to allow a user-provided predicate function. This puts the responsibility on the user to ensure sensitive baggage keys are not copied while also not prescribing how that is determined.
  - https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2166
  
  
  We had a similar feedback in the .NET contrib project but thought it was more complicated than just using a set of prefixes so created an issue to continue the discussion. The plain processor that copies all baggage entries (like using `*` in your example) is likely to be accepted first.
  - https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/1695
  
  
  </issue>
  <code>
  [start of processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py]
  1 # Copyright The OpenTelemetry Authors
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 from typing import Optional
  16 
  17 from opentelemetry.baggage import get_all as get_all_baggage
  18 from opentelemetry.context import Context
  19 from opentelemetry.sdk.trace.export import SpanProcessor
  20 from opentelemetry.trace import Span
  21 
  22 
  23 class BaggageSpanProcessor(SpanProcessor):
  24     """
  25     The BaggageSpanProcessor reads entries stored in Baggage
  26     from the parent context and adds the baggage entries' keys and
  27     values to the span as attributes on span start.
  28 
  29     Add this span processor to a tracer provider.
  30 
  31     Keys and values added to Baggage will appear on subsequent child
  32     spans for a trace within this service *and* be propagated to external
  33     services in accordance with any configured propagation formats
  34     configured. If the external services also have a Baggage span
  35     processor, the keys and values will appear in those child spans as
  36     well.
  37 
  38     ⚠ Warning ⚠️
  39 
  40     Do not put sensitive information in Baggage.
  41 
  42     To repeat: a consequence of adding data to Baggage is that the keys and
  43     values will appear in all outgoing HTTP headers from the application.
  44 
  45     """
  46 
  47     def __init__(self) -> None:
  48         pass
  49 
  50     def on_start(
  51         self, span: "Span", parent_context: Optional[Context] = None
  52     ) -> None:
  53         baggage = get_all_baggage(parent_context)
  54         for key, value in baggage.items():
  55             span.set_attribute(key, value)
  56
  [end of processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py]
  [start of processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/__init__.py]
  1 # Copyright The OpenTelemetry Authors
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 # pylint: disable=import-error
  16 
  17 from .processor import BaggageSpanProcessor
  18 from .version import __version__
  19 
  20 __all__ = ["BaggageSpanProcessor", "__version__"]
  21
  [end of processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/__init__.py b/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/__init__.py
  --- a/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/__init__.py
  +++ b/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/__init__.py
  @@ -14,7 +14,7 @@
   
   # pylint: disable=import-error
   
  -from .processor import BaggageSpanProcessor
  +from .processor import ALLOW_ALL_BAGGAGE_KEYS, BaggageSpanProcessor
   from .version import __version__
   
  -__all__ = ["BaggageSpanProcessor", "__version__"]
  +__all__ = ["ALLOW_ALL_BAGGAGE_KEYS", "BaggageSpanProcessor", "__version__"]
  diff --git a/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py b/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py
  --- a/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py
  +++ b/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py
  @@ -12,13 +12,19 @@
   # See the License for the specific language governing permissions and
   # limitations under the License.
   
  -from typing import Optional
  +from typing import Callable, Optional
   
   from opentelemetry.baggage import get_all as get_all_baggage
   from opentelemetry.context import Context
   from opentelemetry.sdk.trace.export import SpanProcessor
   from opentelemetry.trace import Span
   
  +# A BaggageKeyPredicate is a function that takes a baggage key and returns a boolean
  +BaggageKeyPredicateT = Callable[[str], bool]
  +
  +# A BaggageKeyPredicate that always returns True, allowing all baggage keys to be added to spans
  +ALLOW_ALL_BAGGAGE_KEYS: BaggageKeyPredicateT = lambda _: True
  +
   
   class BaggageSpanProcessor(SpanProcessor):
       """
  @@ -44,12 +50,13 @@
   
       """
   
  -    def __init__(self) -> None:
  -        pass
  +    def __init__(self, baggage_key_predicate: BaggageKeyPredicateT) -> None:
  +        self._baggage_key_predicate = baggage_key_predicate
   
       def on_start(
           self, span: "Span", parent_context: Optional[Context] = None
       ) -> None:
           baggage = get_all_baggage(parent_context)
           for key, value in baggage.items():
  -            span.set_attribute(key, value)
  +            if self._baggage_key_predicate(key):
  +                span.set_attribute(key, value)
  
verification_info: {"golden_diff": "diff --git a/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/__init__.py b/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/__init__.py\n--- a/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/__init__.py\n+++ b/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/__init__.py\n@@ -14,7 +14,7 @@\n \n # pylint: disable=import-error\n \n-from .processor import BaggageSpanProcessor\n+from .processor import ALLOW_ALL_BAGGAGE_KEYS, BaggageSpanProcessor\n from .version import __version__\n \n-__all__ = [\"BaggageSpanProcessor\", \"__version__\"]\n+__all__ = [\"ALLOW_ALL_BAGGAGE_KEYS\", \"BaggageSpanProcessor\", \"__version__\"]\ndiff --git a/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py b/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py\n--- a/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py\n+++ b/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py\n@@ -12,13 +12,19 @@\n # See the License for the specific language governing permissions and\n # limitations under the License.\n \n-from typing import Optional\n+from typing import Callable, Optional\n \n from opentelemetry.baggage import get_all as get_all_baggage\n from opentelemetry.context import Context\n from opentelemetry.sdk.trace.export import SpanProcessor\n from opentelemetry.trace import Span\n \n+# A BaggageKeyPredicate is a function that takes a baggage key and returns a boolean\n+BaggageKeyPredicateT = Callable[[str], bool]\n+\n+# A BaggageKeyPredicate that always returns True, allowing all baggage keys to be added to spans\n+ALLOW_ALL_BAGGAGE_KEYS: BaggageKeyPredicateT = lambda _: True\n+\n \n class BaggageSpanProcessor(SpanProcessor):\n     \"\"\"\n@@ -44,12 +50,13 @@\n \n     \"\"\"\n \n-    def __init__(self) -> None:\n-        pass\n+    def __init__(self, baggage_key_predicate: BaggageKeyPredicateT) -> None:\n+        self._baggage_key_predicate = baggage_key_predicate\n \n     def on_start(\n         self, span: \"Span\", parent_context: Optional[Context] = None\n     ) -> None:\n         baggage = get_all_baggage(parent_context)\n         for key, value in baggage.items():\n-            span.set_attribute(key, value)\n+            if self._baggage_key_predicate(key):\n+                span.set_attribute(key, value)\n", "issue": "Baggage span processor - key predicate\nThis issue is to track adding a method of selecting what baggage key entries should be copied.\r\n\r\nFeedback in the JS contrib PR was to allow a user-provided predicate function. This puts the responsibility on the user to ensure sensitive baggage keys are not copied while also not prescribing how that is determined.\r\n- https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2166\r\n\r\n\r\nWe had a similar feedback in the .NET contrib project but thought it was more complicated than just using a set of prefixes so created an issue to continue the discussion. The plain processor that copies all baggage entries (like using `*` in your example) is likely to be accepted first.\r\n- https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/1695\r\n\n", "before_files": [{"content": "# Copyright The OpenTelemetry Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom typing import Optional\n\nfrom opentelemetry.baggage import get_all as get_all_baggage\nfrom opentelemetry.context import Context\nfrom opentelemetry.sdk.trace.export import SpanProcessor\nfrom opentelemetry.trace import Span\n\n\nclass BaggageSpanProcessor(SpanProcessor):\n    \"\"\"\n    The BaggageSpanProcessor reads entries stored in Baggage\n    from the parent context and adds the baggage entries' keys and\n    values to the span as attributes on span start.\n\n    Add this span processor to a tracer provider.\n\n    Keys and values added to Baggage will appear on subsequent child\n    spans for a trace within this service *and* be propagated to external\n    services in accordance with any configured propagation formats\n    configured. If the external services also have a Baggage span\n    processor, the keys and values will appear in those child spans as\n    well.\n\n    \u26a0 Warning \u26a0\ufe0f\n\n    Do not put sensitive information in Baggage.\n\n    To repeat: a consequence of adding data to Baggage is that the keys and\n    values will appear in all outgoing HTTP headers from the application.\n\n    \"\"\"\n\n    def __init__(self) -> None:\n        pass\n\n    def on_start(\n        self, span: \"Span\", parent_context: Optional[Context] = None\n    ) -> None:\n        baggage = get_all_baggage(parent_context)\n        for key, value in baggage.items():\n            span.set_attribute(key, value)\n", "path": "processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py"}, {"content": "# Copyright The OpenTelemetry Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# pylint: disable=import-error\n\nfrom .processor import BaggageSpanProcessor\nfrom .version import __version__\n\n__all__ = [\"BaggageSpanProcessor\", \"__version__\"]\n", "path": "processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/__init__.py"}]}