open-telemetry / opentelemetry-python

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

Add more informative/restrictive typing to `Log` `body` field #4124

Open lzchen opened 1 month ago

lzchen commented 1 month ago

Describe your environment

OS: (e.g, Ubuntu) Python version: (e.g., Python 3.8.10) SDK version: (e.g., 1.25.0) API version: (e.g., 1.25.0)

What happened?

From this comment: https://github.com/open-telemetry/opentelemetry-python/pull/4054#discussion_r1715595661

Change the typing of LogRecord to restrict to the data model definition of Any instead of Python's Any type.

Steps to Reproduce

See notes.

Expected Result

See notes.

Actual Result

See notes.

Additional context

No response

Would you like to implement a fix?

None

wasup-yash commented 1 month ago

when #4128 gets merged I would also like to take this up as it is related to it, afaik we just need to make the options take the exporter types, also would like to know if some tests we gonna be writing regarding this ?

lzchen commented 1 month ago

@wasup-yash

Yeah we pretty much want to use a Union of these types instead of the Python any. It will definitely be good to add some tests for this (pass in the various valid/invalid types to try to create a LogRecord).

Ali-Alnosairi commented 1 week ago

Hi @lzchen can I take this ?

lzchen commented 1 week ago

@Ali-Alnosairi

As @xrmx has mentioned, please choose one issue to work on and open a PR accordingly instead of working on multiple different issues.

Krishn1412 commented 6 days ago

Hey @lzchen, can I pick this one up?

Ali-Alnosairi commented 5 days ago

use a Union of these types

I am about to create a union for the Any type , but I wanted to ask where to add it, is it fine to add it here or create new file !

@lzchen would you please help !