Add CodeSource parameter to configure - #451
Conversation
Deploying logfire-docs with
|
| Latest commit: |
11b8fb0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://55b7eeb7.logfire-docs.pages.dev |
| Branch Preview URL: | https://add-code-source.logfire-docs.pages.dev |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #451 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 131 131
Lines 9783 9811 +28
Branches 1290 1293 +3
=========================================
+ Hits 9783 9811 +28 ☔ View full report in Codecov by Sentry. |
| """The root path for the source code in the repository. | ||
|
|
||
| Example: | ||
| If the `code.filename` is `/path/to/project/src/logfire/main.py` and the `root_path` is `src/`, the URL |
There was a problem hiding this comment.
This is a long and not very readable example.
It's code.filepath, not filename.
code.filepath is not necessarily something users will know about. It's relative to the current working directory, so it probably shouldn't start with /. And users are likely to not know what the current working directory is or will be when running the app, so setting this correctly may be tricky.
There was a problem hiding this comment.
I'm planning to document this feature btw...
This PR is just the first step. After the feature is on the frontend, I'll add to the docs.
There was a problem hiding this comment.
Logfire spans automatically have a
code.filepathattribute indicating where they were created. That path is relative to the current working directory of the Python process. Theroot_pathsetting is combined with thecode.filepathattribute to construct a link, soroot_pathshould be a path starting from the root of the repository that corresponds to the current working directory of the Python process.
For example, suppose that your repository contains
a/b/c/main.py, the foldera/b/is copied into the/docker/root/folder of your docker container, and within the container the commandpython ./b/c/main.pyis run from within the/docker/root/a/directory. Thencode.filepathwill beb/c/main.pyfor spans created in that file, and theroot_pathshould be set toaso that the final link isa/b/c/main.py.
| revision: str | ||
| """The git revision of the code e.g. branch name, commit hash, tag name etc.""" | ||
|
|
||
| root_path: str |
There was a problem hiding this comment.
Should this default to ''?
|
|
||
|
|
||
| @dataclass | ||
| class CodeSource: |
There was a problem hiding this comment.
Should this be CodeSourceOptions? I genuinely don't know.
There was a problem hiding this comment.
It just seems cleaner the way it is, even if the others have the Options.
|
@alexmojaki Your comments seem not that blocking, can you check them and tell me what would make you happy? I want to push this forward. |
|
We can even put the feature under experimental or something? |
|
I think just document the dataclass and parameter as not ready for public use and then it's fine to go ahead. Or just don't change the SDK for now if it's only going to add resource attributes for the sake of developing the frontend, those can already be set in environment variables. |
558fde3 to
2689423
Compare
I'll add documentation after this is supported by the frontend.