Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion py/src/braintrust/span_origin.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ def _deployment_mode(value: str | None) -> SpanOriginEnvironment | None:
return {"type": "server", "name": normalized}
if normalized in ("development", "local"):
return {"type": "local", "name": normalized}
return None
return {"name": value}
37 changes: 37 additions & 0 deletions py/src/braintrust/test_otel.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,43 @@ def test_detect_environment_preserves_explicit_name_without_type(monkeypatch):
assert detect_environment() == {"name": "staging"}


def test_detect_environment_preserves_custom_python_env(monkeypatch):
from braintrust.span_origin import detect_environment

for key in (
"BRAINTRUST_ENVIRONMENT_TYPE",
"BRAINTRUST_ENVIRONMENT_NAME",
"GITHUB_ACTIONS",
"GITLAB_CI",
"CIRCLECI",
"BUILDKITE",
"JENKINS_URL",
"JENKINS_HOME",
"TF_BUILD",
"TEAMCITY_VERSION",
"TRAVIS",
"BITBUCKET_BUILD_NUMBER",
"CI",
"VERCEL",
"NETLIFY",
"ECS_CONTAINER_METADATA_URI",
"ECS_CONTAINER_METADATA_URI_V4",
"AWS_EXECUTION_ENV",
"AWS_LAMBDA_FUNCTION_NAME",
"K_SERVICE",
"FUNCTION_TARGET",
"KUBERNETES_SERVICE_HOST",
"DYNO",
"FLY_APP_NAME",
"RAILWAY_ENVIRONMENT",
"RENDER_SERVICE_NAME",
):
monkeypatch.delenv(key, raising=False)
monkeypatch.setenv("PYTHON_ENV", "preview")

assert detect_environment() == {"name": "preview"}


def test_detect_environment_classifies_lambda_when_lambda_specific(monkeypatch):
from braintrust.span_origin import detect_environment

Expand Down