Fix #2372: Update OpenTelemetry version constraints for compatibility with newer versions

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-03-14 10:27:58 +00:00
parent d0959573dc
commit 7f55f830a0
3 changed files with 39 additions and 3 deletions

View File

@@ -17,9 +17,9 @@ dependencies = [
"pdfplumber>=0.11.4", "pdfplumber>=0.11.4",
"regex>=2024.9.11", "regex>=2024.9.11",
# Telemetry and Monitoring # Telemetry and Monitoring
"opentelemetry-api>=1.22.0", "opentelemetry-api>=1.22.0,<2.0.0",
"opentelemetry-sdk>=1.22.0", "opentelemetry-sdk>=1.22.0,<2.0.0",
"opentelemetry-exporter-otlp-proto-http>=1.22.0", "opentelemetry-exporter-otlp-proto-http>=1.22.0,<2.0.0",
# Data Handling # Data Handling
"chromadb>=0.5.23", "chromadb>=0.5.23",
"openpyxl>=3.1.5", "openpyxl>=3.1.5",

View File

View File

@@ -0,0 +1,36 @@
import pytest
from importlib import import_module
def test_opentelemetry_imports():
"""Test that all required OpenTelemetry modules can be imported."""
# Test basic imports
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.trace import Span, Status, StatusCode
# Verify that the imports are from the expected modules
assert trace.__name__ == 'opentelemetry.trace'
assert OTLPSpanExporter.__module__ == 'opentelemetry.exporter.otlp.proto.http.trace_exporter'
assert Resource.__module__ == 'opentelemetry.sdk.resources'
assert TracerProvider.__module__ == 'opentelemetry.sdk.trace'
assert BatchSpanProcessor.__module__ == 'opentelemetry.sdk.trace.export'
assert Span.__module__ == 'opentelemetry.trace.span'
assert Status.__module__ == 'opentelemetry.trace.status'
assert StatusCode.__module__ == 'opentelemetry.trace.status'
def test_telemetry_class_initialization():
"""Test that the Telemetry class can be initialized with current OpenTelemetry versions."""
from src.crewai.telemetry.telemetry import Telemetry
# Create an instance of the Telemetry class
telemetry = Telemetry()
# Check if the telemetry instance is initialized correctly
assert hasattr(telemetry, 'ready')
assert hasattr(telemetry, 'trace_set')
# Try to set the tracer
telemetry.set_tracer()