Skip to content

Commit c0aad73

Browse files
internal comments
1 parent da7743f commit c0aad73

5 files changed

Lines changed: 20 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Added
1515

16+
- `opentelemetry-instrumentation-structlog`: Add new package providing `StructlogHandler` and `StructlogInstrumentor` to bridge structlog into the OpenTelemetry Logs SDK pipeline with trace context correlation and exception capture.
17+
([#4286](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4286))
1618
- `opentelemetry-instrumentation-confluent-kafka`: Loosen confluent-kafka upper bound to <3.0.0
1719
([#4289](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4289))
1820
- `opentelemetry-instrumentation`: Add support for wrapt 2.x
@@ -251,8 +253,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
251253
([#3912](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3912))
252254

253255
### Added
254-
- `opentelemetry-instrumentation-structlog`: Add new package providing `StructlogHandler` and `StructlogInstrumentor` to bridge structlog into the OpenTelemetry Logs SDK pipeline with trace context correlation and exception capture.
255-
([#4286](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4286))
256256
- `opentelemetry-instrumentation-botocore`: Add support for AWS Secrets Manager semantic convention attribute
257257
([#3765](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3765))
258258
- `opentelemetry-instrumentation-dbapi`: Add support for `commenter_options` in `trace_integration` function to control SQLCommenter behavior

instrumentation/opentelemetry-instrumentation-structlog/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ classifiers = [
2323
"Programming Language :: Python :: 3.11",
2424
"Programming Language :: Python :: 3.12",
2525
"Programming Language :: Python :: 3.13",
26+
"Programming Language :: Python :: 3.14",
2627
]
2728
dependencies = [
2829
"opentelemetry-api ~= 1.12",
2930
"opentelemetry-instrumentation == 0.62b0.dev",
31+
"opentelemetry-semantic-conventions == 0.62b0.dev",
3032
]
3133

3234
[project.optional-dependencies]

instrumentation/opentelemetry-instrumentation-structlog/src/opentelemetry/instrumentation/structlog/__init__.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
4949
from opentelemetry.instrumentation.log_utils import std_to_otel
5050
from opentelemetry.instrumentation.structlog.package import _instruments
51-
from opentelemetry.semconv._incubating.attributes import (
51+
from opentelemetry.semconv.attributes import (
5252
exception_attributes,
5353
)
5454

@@ -306,7 +306,18 @@ def _instrument(self, **kwargs):
306306
def _patched_configure(*args, **kwargs):
307307
# If the user is supplying a processors list, ensure our handler
308308
# is included before passing it to the original configure.
309-
if "processors" in kwargs:
309+
# processors may be passed as the first positional arg or as a kwarg.
310+
if args:
311+
processors = list(args[0])
312+
if not any(
313+
isinstance(p, StructlogHandler) for p in processors
314+
):
315+
insert_position = max(len(processors) - 1, 0)
316+
processors.insert(
317+
insert_position, StructlogInstrumentor._processor
318+
)
319+
args = (processors,) + args[1:]
320+
elif "processors" in kwargs:
310321
processors = list(kwargs["processors"])
311322
if not any(
312323
isinstance(p, StructlogHandler) for p in processors
@@ -318,7 +329,7 @@ def _patched_configure(*args, **kwargs):
318329
kwargs["processors"] = processors
319330
original = StructlogInstrumentor._original_configure
320331
if original is not None:
321-
original(*args, **kwargs)
332+
return original(*args, **kwargs)
322333

323334
structlog.configure = _patched_configure
324335

instrumentation/opentelemetry-instrumentation-structlog/tests/test_structlog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
InMemoryLogRecordExporter,
2929
SimpleLogRecordProcessor,
3030
)
31-
from opentelemetry.semconv._incubating.attributes import exception_attributes
31+
from opentelemetry.semconv.attributes import exception_attributes
3232
from opentelemetry.test.test_base import TestBase
3333
from opentelemetry.trace import TraceFlags
3434

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ envlist =
198198
lint-instrumentation-starlette
199199

200200
; opentelemetry-instrumentation-structlog
201-
py3{9,10,11,12,13}-test-instrumentation-structlog
201+
py3{9,10,11,12,13,14}-test-instrumentation-structlog
202202
pypy3-test-instrumentation-structlog
203203
lint-instrumentation-structlog
204204

0 commit comments

Comments
 (0)