Skip to content

Commit 088af0d

Browse files
committed
Support environment in logfire-browser
Fixes #33
1 parent 45ad87d commit 088af0d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.changeset/clever-planets-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pydantic/logfire-browser": minor
3+
---
4+
5+
Support environment configuration

packages/logfire-browser/src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
ATTR_BROWSER_LANGUAGE,
1919
ATTR_BROWSER_MOBILE,
2020
ATTR_BROWSER_PLATFORM,
21+
ATTR_DEPLOYMENT_ENVIRONMENT_NAME,
2122
} from '@opentelemetry/semantic-conventions/incubating'
2223
import { ULIDGenerator } from '@pydantic/logfire-api'
2324
import * as logfireApi from '@pydantic/logfire-api'
@@ -33,10 +34,17 @@ export interface LogfireConfigOptions {
3334
* Defines the available internal logging levels for the diagnostic logger.
3435
*/
3536
diagLogLevel?: DiagLogLevel
37+
3638
/**
3739
* Set to `false` to disable the [zone context manager](https://www.npmjs.com/package/@opentelemetry/context-zone) usage.
3840
*/
3941
enableZoneContextManager?: boolean
42+
43+
/**
44+
* 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.
45+
* Defaults to the `LOGFIRE_ENVIRONMENT` environment variable.
46+
*/
47+
environment?: string
4048
/**
4149
* The instrumentations to register - a common one [is the fetch instrumentation](https://www.npmjs.com/package/@opentelemetry/instrumentation-fetch).
4250
*/
@@ -45,6 +53,7 @@ export interface LogfireConfigOptions {
4553
* Options for scrubbing sensitive data. Set to False to disable.
4654
*/
4755
scrubbing?: false | logfireApi.SrubbingOptions
56+
4857
/**
4958
* Name of this service.
5059
*/
@@ -76,6 +85,7 @@ export function configure(options: LogfireConfigOptions) {
7685
[ATTR_SERVICE_VERSION]: options.serviceVersion ?? '0.0.1',
7786
[ATTR_TELEMETRY_SDK_LANGUAGE]: TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS,
7887
[ATTR_TELEMETRY_SDK_NAME]: 'logfire-browser',
88+
...(options.environment ? { [ATTR_DEPLOYMENT_ENVIRONMENT_NAME]: options.environment } : {}),
7989
// eslint-disable-next-line no-undef
8090
[ATTR_TELEMETRY_SDK_VERSION]: PACKAGE_VERSION,
8191
...(navigator.userAgentData

0 commit comments

Comments
 (0)