"""Resource attribute extraction for OpenTelemetry."""

import os
from typing import Any, Dict

from opentelemetry.semconv.resource import (
    ResourceAttributes as SemConvResourceAttributes,
)


def extract_resource_attributes() -> Dict[str, Any]:
    """Extract minimal resource attributes for telemetry."""
    attributes: Dict[str, Any] = {
        SemConvResourceAttributes.DEPLOYMENT_ENVIRONMENT: (
            "supervisor.prod"
            if os.environ.get("THOUGHTFUL_PRODUCTION")
            else "supervisor.dev"
        ),
    }

    if run_id := os.environ.get("RC_PROCESS_RUN_ID"):
        attributes["robocorp.run_id"] = run_id

    return attributes
