Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add extensions to graphql span events on errors #12181

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3ac7025
chore(openai): remove remaining v0 snapshot files (#12218)
Yun-Kim Feb 4, 2025
1245846
chore(tracing): remove deprecated properties and parameters (#12199)
mabdinur Feb 4, 2025
17c60dd
fix(tracing): add flag for aiohttp that disables potential for memory…
ZStriker19 Feb 4, 2025
be50fd7
fix(logging): remove unneeded forksafe unregister to avoid unneeded l…
ZStriker19 Feb 4, 2025
cdaa1e3
chore(openai): drop legacy integration metrics and logs (#12211)
Yun-Kim Feb 4, 2025
3081919
chore(langchain): drop legacy integration metrics and logs (#12220)
Yun-Kim Feb 4, 2025
a2b1d7b
chore(configurations): remove deprecated tracing env vars (#12176)
mabdinur Feb 5, 2025
a8760c6
chore(iast): xss vulnerability for jinja2 template engine (#12183)
avara1986 Feb 5, 2025
a54a55d
chore: remove more 3.7 related code (#12221)
taegyunkim Feb 5, 2025
e5055b7
chore(iast): header source in werkzeug 3.1 (#12213)
avara1986 Feb 5, 2025
b17990b
chore(llmobs): [MLOB-1944] generalize helper for extracting token met…
Kyle-Verhoog Feb 5, 2025
5b42292
chore(tracing): make ddtrace.trace.Tracer a singleton (#12209)
mabdinur Feb 5, 2025
8f8aebe
chore(iast): update xss release note (#12228)
avara1986 Feb 5, 2025
135ae7c
feat: add valkey instrumentation support (#12060)
ZStriker19 Feb 5, 2025
33ad7b3
ci(fix): fix failing pre-check on the tracing module (#12232)
mabdinur Feb 5, 2025
25e7e2e
chore(pin): enforce the use of the global tracer (#12219)
mabdinur Feb 5, 2025
9ba79f4
chore(langchain): remove openai cost span metric (#12233)
Yun-Kim Feb 6, 2025
3b03961
add span event to errors
quinna-h Jan 24, 2025
55ff6a2
wip
quinna-h Jan 24, 2025
d8ad542
wip
quinna-h Jan 27, 2025
51c0e54
add fields
quinna-h Jan 29, 2025
6d159e9
add test
quinna-h Jan 29, 2025
4c8742d
update tests
quinna-h Jan 30, 2025
2392a05
wip
quinna-h Jan 30, 2025
d22af7f
formatting
quinna-h Jan 30, 2025
8e6fb0d
add noqa
quinna-h Feb 4, 2025
f6c5589
formatting
quinna-h Feb 4, 2025
b030f33
type checking
quinna-h Feb 4, 2025
0205450
update snapshot decorator arguments
quinna-h Feb 4, 2025
a84739d
update error extensions
quinna-h Feb 5, 2025
627923a
formatting
quinna-h Feb 6, 2025
c02935b
add release note
quinna-h Feb 6, 2025
246fa84
format
quinna-h Feb 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/COMMIT_TEMPLATE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ feat/fix/docs/refactor/ci(xxx): commit title here
# mysqlpython, openai, opentelemetry, opentracer, profile, psycopg, pylibmc, pymemcache,
# pymongo, pymysql, pynamodb, pyodbc, pyramid, pytest, redis, rediscluster, requests, rq,
# sanic, snowflake, sourcecode, sqlalchemy, starlette, stdlib, structlog, subprocess,
# telemetry, test_logging, tornado, tracer, unittest, urllib3, vendor, vertica, wsgi,
# telemetry, test_logging, tornado, tracer, unittest, urllib3, valkey, vendor, vertica, wsgi,
# yaaredis
2 changes: 1 addition & 1 deletion .github/workflows/build_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
build_wheels:
uses: ./.github/workflows/build_python_3.yml
with:
cibw_build: 'cp37* cp38* cp39* cp310* cp311* cp312* cp313*'
cibw_build: 'cp38* cp39* cp310* cp311* cp312* cp313*'

build_sdist:
name: Build source distribution
Expand Down
6 changes: 6 additions & 0 deletions .gitlab/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
redis:
name: registry.ddbuild.io/redis:7.0.7
alias: redis
valkey:
name: registry.ddbuild.io/images/mirror/valkey:8.0-alpine
alias: valkey
kafka:
name: registry.ddbuild.io/images/mirror/apache/kafka:3.8.0
alias: kafka
Expand All @@ -54,6 +57,9 @@
rediscluster:
name: registry.ddbuild.io/images/mirror/grokzen/redis-cluster:6.2.0
alias: rediscluster
valkeycluster:
name: registry.ddbuild.io/images/mirror/grokzen/redis-cluster:6.2.0
alias: valkeycluster
elasticsearch:
name: registry.ddbuild.io/images/mirror/library/elasticsearch:7.17.23
alias: elasticsearch
Expand Down
26 changes: 26 additions & 0 deletions .riot/requirements/11ac941.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate .riot/requirements/11ac941.in
#
async-timeout==5.0.1
attrs==24.3.0
coverage[toml]==7.6.1
exceptiongroup==1.2.2
hypothesis==6.45.0
importlib-metadata==8.5.0
iniconfig==2.0.0
mock==5.1.0
opentracing==2.4.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.4
pytest-asyncio==0.23.7
pytest-cov==5.0.0
pytest-mock==3.14.0
pytest-randomly==3.15.0
sortedcontainers==2.4.0
tomli==2.2.1
valkey==6.0.2
zipp==3.20.2
26 changes: 26 additions & 0 deletions .riot/requirements/1e98e9b.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate .riot/requirements/1e98e9b.in
#
async-timeout==5.0.1
attrs==24.3.0
coverage[toml]==7.6.10
exceptiongroup==1.2.2
hypothesis==6.45.0
importlib-metadata==8.5.0
iniconfig==2.0.0
mock==5.1.0
opentracing==2.4.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.4
pytest-asyncio==0.23.7
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-randomly==3.16.0
sortedcontainers==2.4.0
tomli==2.2.1
valkey==6.0.2
zipp==3.21.0
22 changes: 22 additions & 0 deletions .riot/requirements/4aa2a2a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate .riot/requirements/4aa2a2a.in
#
async-timeout==5.0.1
attrs==24.3.0
coverage[toml]==7.6.10
hypothesis==6.45.0
iniconfig==2.0.0
mock==5.1.0
opentracing==2.4.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.4
pytest-asyncio==0.23.7
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-randomly==3.16.0
sortedcontainers==2.4.0
valkey==6.0.2
21 changes: 21 additions & 0 deletions .riot/requirements/7219cf4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# This file is autogenerated by pip-compile with Python 3.13
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate .riot/requirements/7219cf4.in
#
attrs==24.3.0
coverage[toml]==7.6.10
hypothesis==6.45.0
iniconfig==2.0.0
mock==5.1.0
opentracing==2.4.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.4
pytest-asyncio==0.23.7
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-randomly==3.16.0
sortedcontainers==2.4.0
valkey==6.0.2
21 changes: 21 additions & 0 deletions .riot/requirements/b96b665.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate .riot/requirements/b96b665.in
#
attrs==24.3.0
coverage[toml]==7.6.10
hypothesis==6.45.0
iniconfig==2.0.0
mock==5.1.0
opentracing==2.4.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.4
pytest-asyncio==0.23.7
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-randomly==3.16.0
sortedcontainers==2.4.0
valkey==6.0.2
24 changes: 24 additions & 0 deletions .riot/requirements/dd68acc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate .riot/requirements/dd68acc.in
#
async-timeout==5.0.1
attrs==24.3.0
coverage[toml]==7.6.10
exceptiongroup==1.2.2
hypothesis==6.45.0
iniconfig==2.0.0
mock==5.1.0
opentracing==2.4.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.4
pytest-asyncio==0.23.7
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-randomly==3.16.0
sortedcontainers==2.4.0
tomli==2.2.1
valkey==6.0.2
2 changes: 1 addition & 1 deletion benchmarks/bm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def process_trace(self, trace):


def drop_traces(tracer):
tracer.configure(settings={"FILTERS": [_DropTraces()]})
tracer.configure(trace_processors=[_DropTraces()])


def drop_telemetry_events():
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/rate_limiter/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def _(loops):
windows = [start + (i * self.time_window) for i in range(self.num_windows)]
per_window = math.floor(loops / self.num_windows)

for window in windows:
for _ in windows:
for _ in range(per_window):
rate_limiter.is_allowed(window)
rate_limiter.is_allowed()

yield _
1 change: 1 addition & 0 deletions ddtrace/_monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"unittest": True,
"coverage": False,
"selenium": True,
"valkey": True,
}


Expand Down
70 changes: 39 additions & 31 deletions ddtrace/_trace/pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import wrapt

import ddtrace
from ddtrace.vendor.debtcollector import deprecate

from ..internal.logger import get_logger

Expand All @@ -32,25 +31,17 @@ class Pin(object):
>>> conn = sqlite.connect('/tmp/image.db')
"""

__slots__ = ["tags", "tracer", "_target", "_config", "_initialized"]
__slots__ = ["tags", "_tracer", "_target", "_config", "_initialized"]

def __init__(
self,
service=None, # type: Optional[str]
tags=None, # type: Optional[Dict[str, str]]
tracer=None,
_config=None, # type: Optional[Dict[str, Any]]
):
# type: (...) -> None
if tracer is not None and tracer is not ddtrace.tracer:
deprecate(
"Initializing ddtrace.trace.Pin with `tracer` argument is deprecated",
message="All Pin instances should use the global tracer instance",
removal_version="3.0.0",
)
tracer = tracer or ddtrace.tracer
self.tags = tags
self.tracer = tracer
self._tracer = ddtrace.tracer
self._target = None # type: Optional[int]
# keep the configuration attribute internal because the
# public API to access it is not the Pin class
Expand All @@ -68,10 +59,14 @@ def service(self):
return self._config["service_name"]

def __setattr__(self, name, value):
if getattr(self, "_initialized", False) and name != "_target":
if getattr(self, "_initialized", False) and name not in ("_target", "_tracer"):
raise AttributeError("can't mutate a pin, use override() or clone() instead")
super(Pin, self).__setattr__(name, value)

@property
def tracer(self):
return self._tracer

def __repr__(self):
return "Pin(service=%s, tags=%s, tracer=%s)" % (self.service, self.tags, self.tracer)

Expand Down Expand Up @@ -127,7 +122,6 @@ def override(
obj, # type: Any
service=None, # type: Optional[str]
tags=None, # type: Optional[Dict[str, str]]
tracer=None,
):
# type: (...) -> None
"""Override an object with the given attributes.
Expand All @@ -139,20 +133,32 @@ def override(
>>> # Override a pin for a specific connection
>>> Pin.override(conn, service='user-db')
"""
if tracer is not None:
deprecate(
"Calling ddtrace.trace.Pin.override(...) with the `tracer` argument is deprecated",
message="All Pin instances should use the global tracer instance",
removal_version="3.0.0",
)
Pin._override(obj, service=service, tags=tags)

@classmethod
def _override(
cls,
obj, # type: Any
service=None, # type: Optional[str]
tags=None, # type: Optional[Dict[str, str]]
tracer=None,
):
# type: (...) -> None
"""
Internal method that allows overriding the global tracer in tests
"""
if not obj:
return

pin = cls.get_from(obj)
if pin is None:
Pin(service=service, tags=tags, tracer=tracer).onto(obj)
pin = Pin(service=service, tags=tags)
else:
pin.clone(service=service, tags=tags, tracer=tracer).onto(obj)
pin = pin.clone(service=service, tags=tags)

if tracer:
pin._tracer = tracer
pin.onto(obj)

def enabled(self):
# type: () -> bool
Expand Down Expand Up @@ -198,21 +204,22 @@ def clone(
self,
service=None, # type: Optional[str]
tags=None, # type: Optional[Dict[str, str]]
tracer=None,
):
# type: (...) -> Pin
"""Return a clone of the pin with the given attributes replaced."""
return self._clone(service=service, tags=tags)

def _clone(
self,
service=None, # type: Optional[str]
tags=None, # type: Optional[Dict[str, str]]
tracer=None,
):
"""Internal method that can clone the tracer from an existing Pin. This is used in tests"""
# do a shallow copy of Pin dicts
if not tags and self.tags:
tags = self.tags.copy()

if tracer is not None:
deprecate(
"Initializing ddtrace.trace.Pin with `tracer` argument is deprecated",
message="All Pin instances should use the global tracer instance",
removal_version="3.0.0",
)

# we use a copy instead of a deepcopy because we expect configurations
# to have only a root level dictionary without nested objects. Using
# deepcopy introduces a big overhead:
Expand All @@ -221,9 +228,10 @@ def clone(
# deepcopy: 0.2787208557128906
config = self._config.copy()

return Pin(
pin = Pin(
service=service or self.service,
tags=tags,
tracer=tracer or self.tracer, # do not clone the Tracer
_config=config,
)
pin._tracer = tracer or self.tracer
return pin
14 changes: 5 additions & 9 deletions ddtrace/_trace/sampling_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from ddtrace.internal.glob_matching import GlobMatcher
from ddtrace.internal.logger import get_logger
from ddtrace.internal.utils.cache import cachedmethod
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
from ddtrace.vendor.debtcollector import deprecate


if TYPE_CHECKING: # pragma: no cover
Expand Down Expand Up @@ -210,14 +208,12 @@ def choose_matcher(self, prop):
# We currently support the ability to pass in a function, a regular expression, or a string
# If a string is passed in we create a GlobMatcher to handle the matching
if callable(prop) or isinstance(prop, pattern_type):
# deprecated: passing a function or a regular expression'
deprecate(
"Using methods or regular expressions for SamplingRule matching is deprecated. ",
message="Please move to passing in a string for Glob matching.",
removal_version="3.0.0",
category=DDTraceDeprecationWarning,
log.error(
"Using methods or regular expressions for SamplingRule matching is not supported: %s ."
"Please move to passing in a string for Glob matching.",
str(prop),
)
return prop
return "None"
# Name and Resource will never be None, but service can be, since we str()
# whatever we pass into the GlobMatcher, we can just use its matching
elif prop is None:
Expand Down
Loading
Loading