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

Set logfire.code.work_dir resource attribute whenever other code source attributes are present #563

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion logfire/_internal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,6 @@ def _initialize(self) -> None:
if self.code_source:
otel_resource_attributes.update(
{
RESOURCE_ATTRIBUTES_CODE_WORK_DIR: os.getcwd(),
RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL: self.code_source.repository,
RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION: self.code_source.revision,
}
Expand All @@ -727,6 +726,11 @@ def _initialize(self) -> None:
for _field in otel_resource_attributes_from_env.split(','):
key, value = _field.split('=', maxsplit=1)
otel_resource_attributes[key.strip()] = value.strip()
if (
RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL in otel_resource_attributes
and RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION in otel_resource_attributes
):
otel_resource_attributes[RESOURCE_ATTRIBUTES_CODE_WORK_DIR] = os.getcwd()

resource = Resource.create(otel_resource_attributes)

Expand Down