Skip to content

Add logfire.configure(environment=...) - #557

Merged
alexmojaki merged 15 commits into
mainfrom
add-environment-configuration
Oct 30, 2024
Merged

alexmojaki merged 15 commits into
mainfrom
add-environment-configuration

Conversation

@Kludex

@Kludex Kludex commented Oct 30, 2024

Copy link
Copy Markdown
Member

No description provided.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 30, 2024 •

Copy link
Copy Markdown

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0aed79e
Status: ✅  Deploy successful!
Preview URL: https://e6b4b884.logfire-docs.pages.dev
Branch Preview URL: https://add-environment-configuratio.logfire-docs.pages.dev

View logs

if self.service_version:
otel_resource_attributes[ResourceAttributes.SERVICE_VERSION] = self.service_version
if self.environment:
otel_resource_attributes[RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME] = self.environment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate that ResourceAttributes.DEPLOYMENT_ENVIRONMENT exists, but ResourceAttributes.DEPLOYMENT_ENVIRONMENT_NAME doesn't. And the first is deprecated...

https://opentelemetry.io/docs/specs/semconv/attributes-registry/deployment/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe open an otel issue? And put this link in code.

@codecov

codecov Bot commented Oct 30, 2024 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (5480347) to head (0aed79e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #557   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          133       133           
  Lines        10214     10227   +13     
  Branches      1396      1397    +1     
=========================================
+ Hits         10214     10227   +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Kludex
Kludex force-pushed the add-environment-configuration branch from f63b4d2 to 7f39490 Compare October 30, 2024 12:13
@Kludex
Kludex force-pushed the add-environment-configuration branch from 7f39490 to 3d325c8 Compare October 30, 2024 12:13
@Kludex
Kludex requested a review from alexmojaki October 30, 2024 12:16
Comment thread logfire/_internal/config.py Outdated
service_name: Name of this service. Defaults to the `LOGFIRE_SERVICE_NAME` environment variable.
service_version: Version of this service. Defaults to the `LOGFIRE_SERVICE_VERSION` environment variable, or the
current git commit hash if available.
environment: The environment this service is running in. Defaults to the `LOGFIRE_ENVIRONMENT` environment variable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
environment: The environment this service is running in. Defaults to the `LOGFIRE_ENVIRONMENT` environment variable.
environment: The environment this service is running in, e.g. `'staging'` or `'prod'`. Sets the `deployment.environment.name` resource attribute. Useful for filtering within projects in the Logfire UI. Defaults to the `LOGFIRE_ENVIRONMENT` environment variable.

but with newlines

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and link to otel docs

if self.service_version:
otel_resource_attributes[ResourceAttributes.SERVICE_VERSION] = self.service_version
if self.environment:
otel_resource_attributes[RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME] = self.environment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe open an otel issue? And put this link in code.

Comment on lines +262 to +263
Defaults to the `LOGFIRE_TOKEN` environment variable.
service_name: Name of this service.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Defaults to the `LOGFIRE_TOKEN` environment variable.
service_name: Name of this service.
Defaults to the `LOGFIRE_TOKEN` environment variable.
service_name: Name of this service.

can we do this to make it more readable? otherwise it's confusing which lines are grouped together.

@alexmojaki
alexmojaki merged commit 74d1e39 into main Oct 30, 2024
@alexmojaki
alexmojaki deleted the add-environment-configuration branch October 30, 2024 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants