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
4 changes: 2 additions & 2 deletions packages/client/src/launchdarkly_ai_server/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _setup_telemetry(sdk_key: str, options: InitClientOptions | None = None) ->
if OTel packages are not installed (graceful degradation).

This function:
- Stamps ``service.name``, ``highlight.project_id``, and (when set)
- Stamps ``service.name``, ``launchdarkly.project_id``, and (when set)
``deployment.environment`` resource attributes, mirroring the TS SDK.
- Registers W3C trace context and baggage propagators.
- Configures GZIP compression on the OTLP exporter.
Expand Down Expand Up @@ -152,7 +152,7 @@ def _setup_telemetry(sdk_key: str, options: InitClientOptions | None = None) ->
resource_attrs: dict[str, str] = {
"service.name": opts.get("serviceName")
or os.environ.get("LD_SERVICE_NAME", "python-sdk"),
"highlight.project_id": sdk_key,
"launchdarkly.project_id": sdk_key,
}
environment = opts.get("environment") or os.environ.get("LD_ENVIRONMENT")
if environment:
Expand Down
4 changes: 2 additions & 2 deletions packages/client/tests/test_evaluations_spans.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _install_provider(
resource=Resource.create(
{
"service.name": "python-sdk",
"highlight.project_id": "sdk-key",
"launchdarkly.project_id": "sdk-key",
}
)
)
Expand Down Expand Up @@ -347,7 +347,7 @@ async def handler(
]
for span in spans:
assert span.resource is not None
assert span.resource.attributes["highlight.project_id"] == "sdk-key"
assert span.resource.attributes["launchdarkly.project_id"] == "sdk-key"
assert_row_attributes(span.attributes)
assert span.status.status_code == StatusCode.OK

Expand Down
12 changes: 9 additions & 3 deletions packages/client/tests/test_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,19 @@ def _spy_create(attributes: dict | None = None) -> Resource:

return created_resources, mock_exporter_cls

def test_stamps_highlight_project_id(self) -> None:
"""highlight.project_id resource attribute must equal the resolved SDK key."""
def test_stamps_launchdarkly_project_id(self) -> None:
"""launchdarkly.project_id resource attribute must equal the resolved SDK key."""
created_resources, _ = self._setup_with_mock_exporter("my-sdk-key")
assert any(
r.get("highlight.project_id") == "my-sdk-key" for r in created_resources
r.get("launchdarkly.project_id") == "my-sdk-key" for r in created_resources
)

def test_stamps_no_highlight_project_id(self) -> None:
"""launchdarkly.project_id is the only project id the resource carries."""
created_resources, _ = self._setup_with_mock_exporter("my-sdk-key")
assert created_resources
assert all("highlight.project_id" not in r for r in created_resources)

def test_registers_w3c_propagators(self) -> None:
"""init_client must register a CompositePropagator with W3C trace context and baggage propagators."""
from opentelemetry import propagate
Expand Down
Loading