Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for OTEL_LOG_LEVEL env variable #1059

Open
codeboten opened this issue Aug 31, 2020 · 16 comments
Open

Add support for OTEL_LOG_LEVEL env variable #1059

codeboten opened this issue Aug 31, 2020 · 16 comments
Labels

Comments

@codeboten
Copy link
Contributor

The spec describes environment variables that should be supported to configure the log level, this feature request is to add support in the current implementation.

https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/sdk-environment-variables.md

@codeboten codeboten added good first issue Good first issue help wanted release:required-for-ga To be resolved before GA release labels Aug 31, 2020
@ffe4
Copy link
Contributor

ffe4 commented Sep 2, 2020

I'll take this up.

@codeboten
Copy link
Contributor Author

Thanks!

@ffe4
Copy link
Contributor

ffe4 commented Sep 9, 2020

There is ongoing discussion about what the values for this should look like, or whether this variable should even exist right now in opentelemetry/opentelemetry-specification#920.

@codeboten codeboten added release:after-ga To be resolved after GA release and removed release:required-for-ga To be resolved before GA release labels Oct 15, 2020
@github-actions
Copy link

github-actions bot commented Apr 9, 2021

This issue was marked stale due to lack of activity. It will be closed in 30 days.

@JPLachance
Copy link

JPLachance commented Feb 3, 2022

Hello,

I recently realized that the open telemetry instrumentation is logging formatted JSON objects instead of JSON lines.

In the context of:

  • an application running in Kubernetes
  • a log collector like Filebeat that expects JSON lines

We get broken logs in Elasticsearch, because Filebeat is indexing each line of the JSON document separately (because each line ends with a \n).

Is there a way to tell opentelemetry-python to log in JSON lines?

The issue comes from

. The indent parameter of json.dumps must not be passed when running inside a Kubernetes pod with a log collector that expects JSON lines.

It would be ideal to get the control over both the logging level and the logging format.

For the logging indent, adding a new OTEL_LOG_INDENT environment variable that we can set to 0 would work.

Thank you!

@srikanthccv
Copy link
Member

It would be ideal to get the control over both the logging level and the logging format.

I think you are mixing different things here. The OTEL_LOG_LEVEL is for setting the log level for the loggers used in internally by SDK not for your application logs.

For the logging indent, adding a new OTEL_LOG_INDENT environment variable that we can set to 0 would work.

Are you using the ConsoleLogExporter? That's primarily intended for debugging purposes. I don't see an issue in enabling you to configuring indent through func args but not sure if we can support the env. I am also wondering if you are actually looking for exporter that writes to file instead of an network destination (OTLP gRPC exporter).

@owais
Copy link
Contributor

owais commented Feb 4, 2022

@JPLachance Could you please open a new issue for what you're reporting? Looks like we are talking about different things here :)

@JPLachance
Copy link

Hello,

We use the OTLPSpanExporter, with a fallback to the ConsoleSpanExporter when we cannot properly configure the OTLPSpanExporter.

That fallback made me fell into a rabbit hole. My bad 🤦🏼

@ffe4
Copy link
Contributor

ffe4 commented Jun 3, 2022

As there was a question on the linked PR #1069 I will post a quick update here.

I wanted to wait for the open spec issue opentelemetry-specification#920 regarding standardising the logging variables to be resolved before implementing yet another languages specific solution. There haven't really been any updates on that issue and at this point some languages have had their own solution for long enough that I think we can just implement our own as well.

As I don't have time right now, feel free to reassign if someone wants to drive this issue. If we decide on implementing an otel-python specific solution it should be easy enough to implement.

@anooprh
Copy link

anooprh commented Mar 22, 2023

Is the original issue of supporting OTEL_LOG_LEVEL env variable still open ?

Looks like #1069 was never merged. I can take this up as I'm looking to get started on this project.

@srikanthccv
Copy link
Member

Yes, this is still open. The author of #1069 didn't have the time to re-work the PR after many changes got made to codebase.

@anooprh
Copy link

anooprh commented Mar 22, 2023

Given that there has been no updates on standardization of the logging levels in specifications, open-telemetry/opentelemetry-specification#920 since @ffe4 worked on this last, I still don't see a clear path forward here.

Given that in the other languages (js and java from the thread ^) implemented what is most sensible as per the respective language, and python sdk is still not respecting the OTEL_LOG_LEVEL variable, I'm inclined to recreate whatever @ffe4 had in #1069 but on the updated version.

We will likely have to make changes to this once again when there is a consensus reached on open-telemetry/opentelemetry-specification#920 on language independent/numeric logging levels.

cc : @srikanthccv

@srikanthccv
Copy link
Member

I think we can start by supporting DEBUG, INFO and ERROR since they are more universal and expand later if the spec adds more. I looked at the prev PR, and I don't think we should set up the level only for SDK. This level should be used in other components such as propagator, exporters, and instrumentation.

@lzchen
Copy link
Contributor

lzchen commented Jul 10, 2024

@anooprh

Are you sitll working on this?

@anooprh
Copy link

anooprh commented Jul 11, 2024

@anooprh

Are you sitll working on this?

@lzchen
I'm not continuing on this due to other commitments.

I'll un-assign myself form this.

@lzchen
Copy link
Contributor

lzchen commented Oct 31, 2024

Related autoinstrumentation pr: #4203

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

7 participants