admin管理员组文章数量:1122832
I'm using Datadog with a Flask/Dash application and while the basic Flask routes seem to be traced, I can't see the spans from my Dash callbacks in Datadog. Here's my setup:
from dash import Dash
from functools import wraps
from ddtrace import tracer
from webapp.config import app_config
from framework.logging import logger
from framework.decorators.tracing import trace_callback
class DashWithTelemetry(Dash):
"""Provide logging telemetry for Dash callbacks"""
def callback(self, *_args, **_kwargs) -> callable:
def decorator(function: callable) -> callable:
@super(DashWithTelemetry, self).callback(
*_args, **_kwargs,
)
def wrapper(*args, **kwargs) -> callable:
decorated_func = trace_callback(
pagename=function.__module__.split(".")[-1],
name=function.__name__,
)(function)
return decorated_func(*args, **kwargs)
return wrapper
return decorator
def trace_callback(pagename: str, name: str | None = None) -> callable:
"""
Decorator to trace Dash callbacks.
Tracing is disabled when running locally.
"""
def decorator(func: callable) -> callable:
@wraps(func)
def wrapper(*args, **kwargs) -> callable:
if not app_config.enable_tracing:
logger.error(f"Tracing {func.__name__} on {pagename=} {name=}")
return func(*args, **kwargs)
with tracer.trace(name=name or func.__name__, resource=pagename, service="callbacks"):
return func(*args, **kwargs)
return wrapper
return decorator
The application is ran with:
ddtrace-run python app.py
app_config.enable_tracing = True
apm_config = True
I see the Datadog agent running and collecting my logs. But do not see any spans in Datadog for my Dash Callbacks.
Am I missing something?
The Datadog service is hosted by our Middleware, and they run the ddtrace-run
for us.
本文标签: pythonDatadog tracing not showing spans for Dash in Flask applicationStack Overflow
版权声明:本文标题:python - Datadog tracing not showing spans for Dash in Flask application - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736310951a1934562.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论