Skip to content

Commit

Permalink
Update dependencies, especially OTEL (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmojaki authored Jul 26, 2024
1 parent f3c50a2 commit 54d4f3f
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 64 deletions.
8 changes: 7 additions & 1 deletion logfire/_internal/exporters/processor_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ def _tweak_asgi_send_receive_spans(span: ReadableSpanDict) -> None:

def _is_asgi_send_receive_span(name: str, instrumentation_scope: InstrumentationScope | None) -> bool:
return (
instrumentation_scope is not None and instrumentation_scope.name == 'opentelemetry.instrumentation.asgi'
instrumentation_scope is not None
and instrumentation_scope.name
in (
'opentelemetry.instrumentation.asgi',
'opentelemetry.instrumentation.starlette',
'opentelemetry.instrumentation.fastapi',
)
) and (name.endswith((' http send', ' http receive', ' websocket send', ' websocket receive')))


Expand Down
2 changes: 1 addition & 1 deletion logfire/_internal/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
from django.http import HttpRequest, HttpResponse
from fastapi import FastAPI
from flask.app import Flask
from opentelemetry.metrics import _Gauge as Gauge
from opentelemetry.metrics import _Gauge as Gauge # type: ignore
from starlette.applications import Starlette
from starlette.requests import Request
from starlette.websockets import WebSocket
Expand Down
6 changes: 4 additions & 2 deletions logfire/_internal/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

try:
# This only exists in opentelemetry-sdk>=1.23.0
from opentelemetry.metrics import _Gauge
from opentelemetry.metrics import _Gauge # type: ignore

Gauge = _Gauge
except ImportError: # pragma: no cover
Expand Down Expand Up @@ -99,10 +99,12 @@ def get_meter(
name: str,
version: str | None = None,
schema_url: str | None = None,
*args: Any,
**kwargs: Any,
) -> Meter:
with self.lock:
meter = _ProxyMeter(
self.provider.get_meter(name, version=version, schema_url=schema_url),
self.provider.get_meter(name, version=version, schema_url=schema_url, *args, **kwargs),
name,
version,
schema_url,
Expand Down
11 changes: 3 additions & 8 deletions logfire/_internal/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,14 @@ def set_provider(self, provider: SDKTracerProvider) -> None:

def get_tracer(
self,
instrumenting_module_name: str,
instrumenting_library_version: str | None = None,
schema_url: str | None = None,
*args: Any,
is_span_tracer: bool = True,
**kwargs: Any,
) -> _ProxyTracer:
with self.lock:

def make() -> Tracer:
return self.provider.get_tracer(
instrumenting_module_name=instrumenting_module_name,
instrumenting_library_version=instrumenting_library_version,
schema_url=schema_url,
)
return self.provider.get_tracer(*args, **kwargs)

tracer = _ProxyTracer(make(), self, is_span_tracer)
self.tracers[tracer] = make
Expand Down
81 changes: 42 additions & 39 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# features: []
# all-features: false
# with-sources: false
# generate-hashes: false

-e file:.
aiohttp==3.9.5
Expand Down Expand Up @@ -73,6 +74,7 @@ coverage==7.6.0
deprecated==1.2.14
# via opentelemetry-api
# via opentelemetry-exporter-otlp-proto-http
# via opentelemetry-semantic-conventions
dirty-equals==0.7.1.post0
distlib==0.3.8
# via virtualenv
Expand Down Expand Up @@ -118,7 +120,7 @@ httpx==0.27.0
# via anthropic
# via fastapi
# via openai
huggingface-hub==0.24.0
huggingface-hub==0.24.2
# via tokenizers
identify==2.6.0
# via pre-commit
Expand All @@ -128,12 +130,12 @@ idna==3.7
# via httpx
# via requests
# via yarl
importlib-metadata==7.1.0
importlib-metadata==8.0.0
# via opentelemetry-api
# via opentelemetry-instrumentation-flask
iniconfig==2.0.0
# via pytest
inline-snapshot==0.11.0
inline-snapshot==0.12.0
itsdangerous==2.2.0
# via flask
jinja2==3.1.4
Expand Down Expand Up @@ -175,7 +177,7 @@ mkdocs-autorefs==1.0.1
mkdocs-get-deps==0.2.0
# via mkdocs
mkdocs-glightbox==0.4.0
mkdocs-material==9.5.29
mkdocs-material==9.5.30
mkdocs-material-extensions==1.3.1
# via mkdocs-material
mkdocstrings==0.25.1
Expand All @@ -191,10 +193,10 @@ mypy-extensions==1.0.0
nodeenv==1.9.1
# via pre-commit
# via pyright
numpy==2.0.0
numpy==2.0.1
# via pandas
openai==1.36.0
opentelemetry-api==1.25.0
openai==1.37.0
opentelemetry-api==1.26.0
# via opentelemetry-exporter-otlp-proto-http
# via opentelemetry-instrumentation
# via opentelemetry-instrumentation-aiohttp-client
Expand All @@ -217,11 +219,11 @@ opentelemetry-api==1.25.0
# via opentelemetry-instrumentation-wsgi
# via opentelemetry-sdk
# via opentelemetry-semantic-conventions
opentelemetry-exporter-otlp-proto-common==1.25.0
opentelemetry-exporter-otlp-proto-common==1.26.0
# via opentelemetry-exporter-otlp-proto-http
opentelemetry-exporter-otlp-proto-http==1.25.0
opentelemetry-exporter-otlp-proto-http==1.26.0
# via logfire
opentelemetry-instrumentation==0.46b0
opentelemetry-instrumentation==0.47b0
# via logfire
# via opentelemetry-instrumentation-aiohttp-client
# via opentelemetry-instrumentation-asgi
Expand All @@ -241,37 +243,37 @@ opentelemetry-instrumentation==0.46b0
# via opentelemetry-instrumentation-starlette
# via opentelemetry-instrumentation-system-metrics
# via opentelemetry-instrumentation-wsgi
opentelemetry-instrumentation-aiohttp-client==0.46b0
opentelemetry-instrumentation-asgi==0.46b0
opentelemetry-instrumentation-aiohttp-client==0.47b0
opentelemetry-instrumentation-asgi==0.47b0
# via opentelemetry-instrumentation-fastapi
# via opentelemetry-instrumentation-starlette
opentelemetry-instrumentation-asyncpg==0.46b0
opentelemetry-instrumentation-celery==0.46b0
opentelemetry-instrumentation-dbapi==0.46b0
opentelemetry-instrumentation-asyncpg==0.47b0
opentelemetry-instrumentation-celery==0.47b0
opentelemetry-instrumentation-dbapi==0.47b0
# via opentelemetry-instrumentation-psycopg
# via opentelemetry-instrumentation-psycopg2
opentelemetry-instrumentation-django==0.46b0
opentelemetry-instrumentation-fastapi==0.46b0
opentelemetry-instrumentation-flask==0.46b0
opentelemetry-instrumentation-httpx==0.46b0
opentelemetry-instrumentation-psycopg==0.46b0
opentelemetry-instrumentation-psycopg2==0.46b0
opentelemetry-instrumentation-pymongo==0.46b0
opentelemetry-instrumentation-redis==0.46b0
opentelemetry-instrumentation-requests==0.46b0
opentelemetry-instrumentation-sqlalchemy==0.46b0
opentelemetry-instrumentation-starlette==0.46b0
opentelemetry-instrumentation-system-metrics==0.46b0
opentelemetry-instrumentation-wsgi==0.46b0
opentelemetry-instrumentation-django==0.47b0
opentelemetry-instrumentation-fastapi==0.47b0
opentelemetry-instrumentation-flask==0.47b0
opentelemetry-instrumentation-httpx==0.47b0
opentelemetry-instrumentation-psycopg==0.47b0
opentelemetry-instrumentation-psycopg2==0.47b0
opentelemetry-instrumentation-pymongo==0.47b0
opentelemetry-instrumentation-redis==0.47b0
opentelemetry-instrumentation-requests==0.47b0
opentelemetry-instrumentation-sqlalchemy==0.47b0
opentelemetry-instrumentation-starlette==0.47b0
opentelemetry-instrumentation-system-metrics==0.47b0
opentelemetry-instrumentation-wsgi==0.47b0
# via opentelemetry-instrumentation-django
# via opentelemetry-instrumentation-flask
opentelemetry-proto==1.25.0
opentelemetry-proto==1.26.0
# via opentelemetry-exporter-otlp-proto-common
# via opentelemetry-exporter-otlp-proto-http
opentelemetry-sdk==1.25.0
opentelemetry-sdk==1.26.0
# via logfire
# via opentelemetry-exporter-otlp-proto-http
opentelemetry-semantic-conventions==0.46b0
opentelemetry-semantic-conventions==0.47b0
# via opentelemetry-instrumentation-aiohttp-client
# via opentelemetry-instrumentation-asgi
# via opentelemetry-instrumentation-asyncpg
Expand All @@ -288,7 +290,7 @@ opentelemetry-semantic-conventions==0.46b0
# via opentelemetry-instrumentation-starlette
# via opentelemetry-instrumentation-wsgi
# via opentelemetry-sdk
opentelemetry-util-http==0.46b0
opentelemetry-util-http==0.47b0
# via opentelemetry-instrumentation-aiohttp-client
# via opentelemetry-instrumentation-asgi
# via opentelemetry-instrumentation-django
Expand Down Expand Up @@ -321,11 +323,11 @@ pluggy==1.5.0
pre-commit==3.7.1
prompt-toolkit==3.0.47
# via click-repl
protobuf==4.25.3
protobuf==4.25.4
# via googleapis-common-protos
# via logfire
# via opentelemetry-proto
psutil==5.9.8
psutil==6.0.0
# via opentelemetry-instrumentation-system-metrics
psycopg==3.2.1
psycopg-binary==3.2.1
Expand All @@ -345,7 +347,7 @@ pymdown-extensions==10.8.1
# via mkdocs-material
# via mkdocstrings
pymongo==4.8.0
pyright==1.1.372
pyright==1.1.373
pytest==8.3.1
# via pytest-django
# via pytest-pretty
Expand Down Expand Up @@ -373,7 +375,7 @@ pyyaml==6.0.1
pyyaml-env-tag==0.1
# via mkdocs
redis==5.0.7
regex==2024.5.15
regex==2024.7.24
# via mkdocs-material
requests==2.32.3
# via huggingface-hub
Expand All @@ -386,8 +388,8 @@ rich==13.7.1
# via logfire
# via pytest-pretty
# via typer
ruff==0.5.3
setuptools==71.0.4
ruff==0.5.4
setuptools==71.1.0
# via opentelemetry-instrumentation
shellingham==1.5.4
# via typer
Expand All @@ -401,7 +403,7 @@ sniffio==1.3.1
# via openai
sqlalchemy==2.0.31
# via sqlmodel
sqlmodel==0.0.20
sqlmodel==0.0.21
sqlparse==0.5.1
# via django
starlette==0.37.2
Expand All @@ -422,6 +424,7 @@ typing-extensions==4.12.2
# via anthropic
# via fastapi
# via huggingface-hub
# via inline-snapshot
# via logfire
# via mypy
# via openai
Expand Down
22 changes: 12 additions & 10 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# features: []
# all-features: false
# with-sources: false
# generate-hashes: false

-e file:.
certifi==2024.7.4
Expand All @@ -15,38 +16,39 @@ charset-normalizer==3.3.2
deprecated==1.2.14
# via opentelemetry-api
# via opentelemetry-exporter-otlp-proto-http
# via opentelemetry-semantic-conventions
executing==2.0.1
# via logfire
googleapis-common-protos==1.63.2
# via opentelemetry-exporter-otlp-proto-http
idna==3.7
# via requests
importlib-metadata==7.1.0
importlib-metadata==8.0.0
# via opentelemetry-api
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
opentelemetry-api==1.25.0
opentelemetry-api==1.26.0
# via opentelemetry-exporter-otlp-proto-http
# via opentelemetry-instrumentation
# via opentelemetry-sdk
# via opentelemetry-semantic-conventions
opentelemetry-exporter-otlp-proto-common==1.25.0
opentelemetry-exporter-otlp-proto-common==1.26.0
# via opentelemetry-exporter-otlp-proto-http
opentelemetry-exporter-otlp-proto-http==1.25.0
opentelemetry-exporter-otlp-proto-http==1.26.0
# via logfire
opentelemetry-instrumentation==0.46b0
opentelemetry-instrumentation==0.47b0
# via logfire
opentelemetry-proto==1.25.0
opentelemetry-proto==1.26.0
# via opentelemetry-exporter-otlp-proto-common
# via opentelemetry-exporter-otlp-proto-http
opentelemetry-sdk==1.25.0
opentelemetry-sdk==1.26.0
# via logfire
# via opentelemetry-exporter-otlp-proto-http
opentelemetry-semantic-conventions==0.46b0
opentelemetry-semantic-conventions==0.47b0
# via opentelemetry-sdk
protobuf==4.25.3
protobuf==4.25.4
# via googleapis-common-protos
# via logfire
# via opentelemetry-proto
Expand All @@ -56,7 +58,7 @@ requests==2.32.3
# via opentelemetry-exporter-otlp-proto-http
rich==13.7.1
# via logfire
setuptools==71.0.4
setuptools==71.1.0
# via opentelemetry-instrumentation
typing-extensions==4.12.2
# via logfire
Expand Down
6 changes: 3 additions & 3 deletions tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_create_metric_gauge(metrics_reader: InMemoryMetricReader) -> None:
'data_points': [
{
'attributes': {},
'start_time_unix_nano': 0,
'start_time_unix_nano': None,
'time_unix_nano': IsInt(),
'value': 1,
}
Expand All @@ -169,7 +169,7 @@ def test_create_metric_gauge(metrics_reader: InMemoryMetricReader) -> None:
'data_points': [
{
'attributes': {},
'start_time_unix_nano': 0,
'start_time_unix_nano': None,
'time_unix_nano': IsInt(),
'value': 24,
}
Expand Down Expand Up @@ -278,7 +278,7 @@ def observable_gauge(options: CallbackOptions):
'data_points': [
{
'attributes': {},
'start_time_unix_nano': 0,
'start_time_unix_nano': None,
'time_unix_nano': IsInt(),
'value': 4000,
}
Expand Down

0 comments on commit 54d4f3f

Please sign in to comment.