Add Structlog Handler as Instrumentation#4286
Add Structlog Handler as Instrumentation#4286JWinermaSplunk wants to merge 7 commits intoopen-telemetry:mainfrom
Conversation
e0317fa to
fab1022
Compare
...ntelemetry-instrumentation-structlog/src/opentelemetry/instrumentation/structlog/__init__.py
Outdated
Show resolved
Hide resolved
| return _STD_TO_OTEL[levelno] | ||
|
|
||
|
|
||
| class StructlogHandler: |
There was a problem hiding this comment.
Could this be simplified by subclassing an existing type in structlog (which I don't know that well 🙂 )?
...ntelemetry-instrumentation-structlog/src/opentelemetry/instrumentation/structlog/__init__.py
Outdated
Show resolved
Hide resolved
|
Thank you for undertaking this! |
opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py
Outdated
Show resolved
Hide resolved
| current_processors.insert(insert_position, processor) | ||
|
|
||
| # Reconfigure structlog with the new processor chain | ||
| structlog.configure(processors=current_processors) |
There was a problem hiding this comment.
During auto-instrumentation, instrumentors will run first, then the user's code will run, and if that code calls structlog.configure, looks like it will overwrite this config. The solution may be to monkeypatch structlog.configure.
There was a problem hiding this comment.
Believe I resolved this by intercepting the original call, injecting the handler into the processors list, then calling the original once. But, I will leave this comment unresolved for context just in case I did not.
fd07c37 to
ddae8b5
Compare
...ntelemetry-instrumentation-structlog/src/opentelemetry/instrumentation/structlog/__init__.py
Show resolved
Hide resolved
|
I think a rebase is needed. This PR is now reverting some unrelated docker-test fixes (this other PR) |
# Conflicts: # .github/workflows/test_0.yml # .github/workflows/test_1.yml # .github/workflows/test_2.yml # opentelemetry-contrib-instrumentations/pyproject.toml
# Conflicts: # .github/workflows/test_1.yml # .github/workflows/test_2.yml # .github/workflows/test_3.yml
ef6ad9a to
ece1f64
Compare
Believe I went ahead and rebased, but feel free to let me know if it still looks off! |
|
|
||
| ### Added | ||
|
|
||
| - `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. |
There was a problem hiding this comment.
Something like this:
| - `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. | |
| - `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. `opentelemetry-instrumentation`: adds shared `log_utils` |
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes open-telemetry/opentelemetry-python#2993
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.