Skip to content

Commit

Permalink
chore(asm): remove datadog.api_security metrics (#8906)
Browse files Browse the repository at this point in the history
Metrics were added during R&D phase on API Security. This PR removes
them.
It prevents to send unneeded data to DD backend.

APPSEC-52415

DataDog/dd-analytics#30330 is also put in place
to ensure no additional charges for customers using non updated tracers.

This PR is backported to all versions containing api security.

## Checklist

- [x] Change(s) are motivated and described in the PR description
- [x] Testing strategy is described if automated tests are not included
in the PR
- [x] Risks are described (performance impact, potential for breakage,
maintainability)
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed or label `changelog/no-changelog` is set
- [x] Documentation is included (in-code, generated user docs, [public
corp docs](https://github.com/DataDog/documentation/))
- [x] Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))
- [x] If this PR changes the public interface, I've notified
`@DataDog/apm-tees`.

## Reviewer Checklist

- [ ] Title is accurate
- [ ] All changes are related to the pull request's stated goal
- [ ] Description motivates each change
- [ ] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- [ ] Testing strategy adequately addresses listed risks
- [ ] Change is maintainable (easy to change, telemetry, documentation)
- [ ] Release note makes sense to a user of the library
- [ ] Author has acknowledged and discussed the performance implications
of this PR as reported in the benchmarks PR comment
- [ ] Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
  • Loading branch information
christophe-papazian authored Apr 9, 2024
1 parent 131837d commit 616c5a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 1 addition & 8 deletions ddtrace/appsec/_api_security/api_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
from ddtrace.appsec._constants import API_SECURITY
from ddtrace.appsec._constants import SPAN_DATA_NAMES
from ddtrace.internal.logger import get_logger
from ddtrace.internal.metrics import Metrics
from ddtrace.internal.service import Service
from ddtrace.settings.asm import config as asm_config


log = get_logger(__name__)
metrics = Metrics(namespace="datadog.api_security")
_sentinel = object()


Expand Down Expand Up @@ -55,7 +53,6 @@ def enable(cls) -> None:

asm_config._api_security_active = True
log.debug("Enabling %s", cls.__name__)
metrics.enable()
cls._instance = cls()
cls._instance.start()
log.debug("%s enabled", cls.__name__)
Expand All @@ -70,13 +67,11 @@ def disable(cls) -> None:
log.debug("Disabling %s", cls.__name__)
cls._instance.stop()
cls._instance = None
metrics.disable()
log.debug("%s disabled", cls.__name__)

def __init__(self) -> None:
super(APIManager, self).__init__()

self._schema_meter = metrics.get_meter("schema")
log.debug("%s initialized", self.__class__.__name__)
self._hashtable: collections.OrderedDict[int, float] = collections.OrderedDict()

Expand Down Expand Up @@ -178,8 +173,7 @@ def _schema_callback(self, env):
if len(b64_gzip_content) >= MAX_SPAN_META_VALUE_LEN:
raise TooLargeSchemaException
root._meta[meta] = b64_gzip_content
except Exception as e:
self._schema_meter.increment("errors", tags={"exc": e.__class__.__name__, "address": address})
except Exception:
self._log_limiter.limit(
log.warning,
"Failed to get schema from %r [schema length=%d]:\n%s",
Expand All @@ -188,4 +182,3 @@ def _schema_callback(self, env):
repr(value)[:256],
exc_info=True,
)
self._schema_meter.increment("spans")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
ASM: This fix removes unrequired API security metrics.

0 comments on commit 616c5a9

Please sign in to comment.