{"record":{"id":"c4b039b37149e566","repo":"BerriAI/litellm","slug":"otel-attributes-include-list-and-exclude-list-are","errorCode":null,"errorMessage":"otel.attributes: include_list and exclude_list are mutually exclusive","messagePattern":"otel\\.attributes: include_list and exclude_list are mutually exclusive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/opentelemetry.py","lineNumber":179,"sourceCode":"        raise ValueError(\n            \"otel.attributes must be a mapping with optional 'include_list' / \"\n            f\"'exclude_list', got {type(value).__name__}\"\n        )\n    return OTELMetricAttributeFilter(\n        include_list=value.get(\"include_list\"),\n        exclude_list=value.get(\"exclude_list\"),\n    )\n\n\ndef _resolve_metric_attribute_filter(\n    attributes: OTELMetricAttributeFilter | None,\n) -> tuple[frozenset[str] | None, frozenset[str] | None]:\n    if attributes is None:\n        return None, None\n    include: Final = attributes.include_list or None\n    exclude: Final = attributes.exclude_list or None\n    if include and exclude:\n        raise ValueError(\"otel.attributes: include_list and exclude_list are mutually exclusive\")\n    requested: Final = include or exclude or []\n    if TOKEN_TYPE_ATTRIBUTE in requested:\n        raise ValueError(\n            f\"otel.attributes: {TOKEN_TYPE_ATTRIBUTE} is a structural token-usage discriminator and cannot be filtered\"\n        )\n    unknown: Final = sorted(name for name in requested if name not in VALID_METRIC_ATTRIBUTE_NAMES)\n    if unknown:\n        raise ValueError(\n            f\"otel.attributes: unknown attribute name(s) {unknown}. Valid names: {sorted(VALID_METRIC_ATTRIBUTE_NAMES)}\"\n        )\n    return (\n        frozenset(include) if include else None,\n        frozenset(exclude) if exclude else None,\n    )\n\n\ndef _normalize_team_metadata_keys(value: Any) -> list[str]:\n    \"\"\"Coerce a team-metadata allowlist from a list or comma-separated string.","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/opentelemetry.py#L161-L197","documentation":"The otel.attributes filter supports either include_list (export only these attributes) or exclude_list (export all but these) — never both, because their combination is ambiguous. _resolve_metric_attribute_filter raises ValueError when both are non-empty; empty lists and None are treated as unset, so an empty include_list alongside exclude_list is fine.","triggerScenarios":"config.yaml with otel.attributes containing both include_list and exclude_list; config generated by templating that merges both keys; copying an example config that demonstrates both lists without removing one.","commonSituations":"Teams iterating on metric-label reduction and leaving both strategies in the YAML; Helm values merging defaults (exclude_list) with overrides (include_list).","solutions":["Keep exactly one of include_list or exclude_list under otel.attributes","Decide the strategy: allow-list for strict label control, deny-list to drop a few noisy labels","If config comes from templates, ensure earlier keys are overridden, not merged","Restart the proxy after correcting config.yaml"],"exampleFix":"# before\notel:\n  attributes:\n    include_list: [model, endpoint]\n    exclude_list: [api_key_hash]  # ValueError: mutually exclusive\n\n# after\notel:\n  attributes:\n    include_list: [model, endpoint]","handlingStrategy":"validation","validationCode":"def validate_otel_attributes(attrs: dict) -> None:\n    include = attrs.get(\"include_list\") or None\n    exclude = attrs.get(\"exclude_list\") or None\n    if include and exclude:\n        raise ValueError(\"choose include_list OR exclude_list, not both\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document one filtering strategy per team and template configs from a single source","Reject merged Helm values that contain both lists"],"tags":["python","opentelemetry","configuration","yaml","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}