Skip to content

Invalid type dict in attribute 'db.mongodb.collection' value sequence. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or None #3940

@abdullah-retorio

Description

@abdullah-retorio

Describe your environment

Docker: python:3.12.11-slim-bookworm
Package version: opentelemetry-instrumentation-pymongo = "0.59b0"

What happened?

Hello,

I hope you are all doing well. We implemented OTEL in Python and instrumented it with a gRPC exporter to our self-hosted Grafana Alloy instance that sends data to Grafana Cloud.

Our python serverless application is deployed to Google Cloud Run. In Cloud Run logs, we always see this warning log.

  "textPayload": "Invalid type dict in attribute 'db.mongodb.collection' value sequence. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or None",
  "insertId": "---",
  "httpRequest": {},
  "resource": {
    "type": "cloud_run_revision",
    "labels": {
      "service_name": "get-xyz"
      "project_id": "---",
      "configuration_name": "get-xyz",
      "revision_name": "get-xyz-00003-v6x",
      "location": "europe-west1"
    }
  },
  "timestamp": "2025-11-13T07:10:01.362533Z",
  "severity": "WARNING",
  "labels": {
    "instanceId": "asdfgh",
    "python_logger": "opentelemetry.attributes"
  },
  "logName": "projects/---/logs/run.googleapis.com%2Fstderr",
  "trace": "projects/--/traces/asdfgdf",
  "sourceLocation": {
    "file": "/usr/local/lib/python3.12/site-packages/opentelemetry/attributes/__init__.py",
    "line": "80",
    "function": "_clean_attribute"
  },
  "receiveTimestamp": "2025-11-13T07:10:01.559557217Z",
  "spanId": "abc",
  "traceSampled": true
}

Steps to Reproduce

Pymongo instrumentor with grpc exporter

Expected Result

No warning or error

Actual Result

  "textPayload": "Invalid type dict in attribute 'db.mongodb.collection' value sequence. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or None",
  "insertId": "---",
  "httpRequest": {},
  "resource": {
    "type": "cloud_run_revision",
    "labels": {
      "service_name": "get-xyz"
      "project_id": "---",
      "configuration_name": "get-xyz",
      "revision_name": "get-xyz-00003-v6x",
      "location": "europe-west1"
    }
  },
  "timestamp": "2025-11-13T07:10:01.362533Z",
  "severity": "WARNING",
  "labels": {
    "instanceId": "asdfgh",
    "python_logger": "opentelemetry.attributes"
  },
  "logName": "projects/---/logs/run.googleapis.com%2Fstderr",
  "trace": "projects/--/traces/asdfgdf",
  "sourceLocation": {
    "file": "/usr/local/lib/python3.12/site-packages/opentelemetry/attributes/__init__.py",
    "line": "80",
    "function": "_clean_attribute"
  },
  "receiveTimestamp": "2025-11-13T07:10:01.559557217Z",
  "spanId": "abc",
  "traceSampled": true
}

Additional context

No response

Would you like to implement a fix?

None

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions