open-telemetry / opentelemetry-python

OpenTelemetry Python API and SDK
https://opentelemetry.io
Apache License 2.0
1.68k stars 584 forks source link

Add handler for structlog #2993

Open srikanthccv opened 1 year ago

srikanthccv commented 1 year ago

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

lzchen commented 1 year ago

@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.

srikanthccv commented 1 year ago

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

Samyak2 commented 9 months ago

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.

lzchen commented 9 months ago

@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.

corentinmusard commented 5 months ago

Any update on it?

Samyak2 commented 4 months ago

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.

carolinecgilbert commented 3 months ago

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 commented 3 months ago

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.

srikanthccv commented 3 months ago

@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.

lzchen commented 2 weeks ago

@carolinecgilbert

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

Samyak2 commented 1 week ago

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

folt commented 3 days ago

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