opentelemetry-python icon indicating copy to clipboard operation
opentelemetry-python copied to clipboard

Add handler for structlog

Open srikanthccv opened this issue 3 years ago • 15 comments

Similar to stdlib logging library, adding a handler for structlog the popular alternative logging library can enable people to directly export with OTLP

srikanthccv avatar Oct 27 '22 05:10 srikanthccv

@srikanthccv Curious if we are formalizing going down the route of utilizing handlers in supporting telemetry collection of different Python logging libraries. For example, Java is utilizing instrumentations for logging capture support. I wonder what the implications are of having logging library support via handlers. Ex. users would need to install the sdk to get logging library collection support since handlers exist within our sdk.

lzchen avatar Nov 22 '22 02:11 lzchen

That's a good question. Let me take a look at Java implementations and come back on this.

srikanthccv avatar Jan 06 '23 16:01 srikanthccv

I have been using a custom handler for structlog that I wrote. Although I'm not sure how much of it is specific to our use case and possibly specific to Signoz (it will need a few iterations to make it generic enough). It also uses some private bits from structlog, so the optional dependency on it will need to be restricted.

I can open a PR for this if adding handlers to the sdk is fine.

Samyak2 avatar Sep 27 '23 16:09 Samyak2

@Samyak2

It would be great if you could open a pr for this. We probably do not want this as part of the sdk. Can you open up a pr to the contrib repo and add a folder called "handlers"? The structlog handler can be a separate package as we are not trying to support anymore third party libraries in the core repository.

lzchen avatar Sep 28 '23 16:09 lzchen

Any update on it?

corentinmusard avatar Jan 25 '24 13:01 corentinmusard

I have a draft PR for this here - https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2139

I'm no longer working with structlog and otel in python, so I'll need some help testing and validating this approach.

Samyak2 avatar Mar 12 '24 16:03 Samyak2

I am working on a team of 4 to contribute to this issue as a university project. We have been working on developing tests for the structlog handler.

carolinecgilbert avatar Mar 26 '24 23:03 carolinecgilbert

My team has completed tests for the structlog handler and integrated the tests into the tox testing framework. https://github.com/carolinecgilbert/opentelemetry-python-contrib

The tests are located in the instrumentation/opentelemetry-instrumentation-logging/tests/test_logging.py file under the TestStructlogHandler class.

carolinecgilbert avatar Apr 15 '24 18:04 carolinecgilbert

@carolinecgilbert I'd suggest you open PR against the @Samyak2's PR. One of you needs to take it to the ready state for review. And address the review comments post that etc.. So you might just want to create a separate with co-authoring @Samyak2 if they don't have the bandwidth to drive this forward.

srikanthccv avatar Apr 16 '24 18:04 srikanthccv

@carolinecgilbert

Are you still working this? If so, would you be able to open up a pr?

lzchen avatar Jul 03 '24 18:07 lzchen

So you might just want to create a separate with co-authoring @Samyak2 if they don't have the bandwidth to drive this forward.

@carolinecgilbert I'm ok with having my commits cherry-picked or squashed into a different PR. I can help answer questions/review comments with the code too. I'll complete the CLA soon.

Are you still working this? If so, would you be able to open up a pr?

@lzchen looks like they have a PR here: https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2492

Samyak2 avatar Jul 07 '24 13:07 Samyak2

Any updates on this? I'm really looking forward to the solution.

folt avatar Jul 17 '24 18:07 folt

Any news about structlog?

giulioindev avatar Sep 16 '24 16:09 giulioindev

@giulioindev

There's an open pr: https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2492

lzchen avatar Sep 16 '24 16:09 lzchen

My team and I were working on this project last year for coursework in one of our classes and are no longer working on it.

carolinecgilbert avatar Sep 17 '24 13:09 carolinecgilbert

A simple implementation can be referred to here. https://github.com/a1403951401/ez_otlp/blob/main/ez_otlp/log/structlog_config.py

a1403951401 avatar Dec 04 '24 15:12 a1403951401