opentelemetry-python-contrib icon indicating copy to clipboard operation
opentelemetry-python-contrib copied to clipboard

Add db.name to sqlite spans

Open philipcwhite opened this issue 1 year ago • 0 comments
trafficstars

Before opening a feature request against this repo, consider whether the feature should/could be implemented in the other OpenTelemetry client libraries. If so, please open an issue on opentelemetry-specification first.

Is your feature request related to a problem? If so, provide a concise description of the problem.

Describe the solution you'd like What do you want to happen instead? What is the expected behavior?

Currently db.name is not populated in spans by the sqlite instrumentation. I believe this is a required field for the service graph connector to instrument a database link. Also it just feels incomplete not being here. It would be nice if the file name for the database was used to replace the blank field.

Describe alternatives you've considered Which alternative solutions or features have you considered?

I have found a work around using the otel transform processor

      transform:
        error_mode: ignore
        trace_statements:
          - context: span
            statements:
              - set(attributes["db.name"], "pydemodb") where attributes["db.system"] == "sqlite"
          - context: resource
            statements:
              - set(attributes["db.name"], "pydemodb")

Also directly editing the dbapi init.py file works as well to override this. line 381

        span.set_attribute(
            SpanAttributes.DB_NAME, "test.db"
        )

Additional context Add any other context about the feature request here.

philipcwhite avatar Dec 08 '23 17:12 philipcwhite