Skip to content

fix(mqtt): import MQTT when only the OpenTelemetry API is installed - #3261

Merged
borisalekseev merged 1 commit into
ag2ai:mainfrom
SinitsynAndrey:fix/mqtt-otel-api-only
Oct 9, 2026
Merged

borisalekseev merged 1 commit into
ag2ai:mainfrom
SinitsynAndrey:fix/mqtt-otel-api-only

Conversation

@SinitsynAndrey

Copy link
Copy Markdown
Contributor

Description

The regression appeared after FastAPI 0.142 added opentelemetry-api as a dependency. As a result, applications can have the root opentelemetry namespace installed without installing opentelemetry.semconv.

HAS_OPENTELEMETRY was set when importing only the opentelemetry namespace succeeded. Importing the MQTT broker then eagerly loaded TelemetryMiddleware, which requires opentelemetry.semconv, and failed with ModuleNotFoundError.

The compatibility check now requires opentelemetry.semconv. MQTT remains importable when only the OpenTelemetry API is installed, while faststream[otel] continues to enable telemetry. A regression test covers this isolated-import case.

Type of change

  • Bug fix (a non-breaking change that resolves an issue)

Checklist

  • My code adheres to the style guidelines of this project (just lint shows no errors)
  • I have conducted a self-review of my own code
  • I have made the necessary changes to the documentation
  • My changes do not generate any new warnings
  • I have added tests to validate the effectiveness of my fix or the functionality of my new feature
  • Both new and existing unit tests pass successfully on my local environment by running just test-coverage
  • I have ensured that static analysis tests are passing by running just static-analysis
  • I have included code examples to illustrate the modifications

@CLAassistant

CLAassistant commented Oct 9, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@borisalekseev
borisalekseev added this pull request to the merge queue Oct 9, 2026
Merged via the queue into ag2ai:main with commit 5837793 Oct 9, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants