Skip to content

Conversation

@wconti27
Copy link
Contributor

Description

Testing

Risks

Additional Notes

@github-actions
Copy link
Contributor

CODEOWNERS have been resolved as:

ddtrace/_trace/tracing_plugins/__init__.py                              @DataDog/apm-sdk-capabilities-python
ddtrace/_trace/tracing_plugins/base/__init__.py                         @DataDog/apm-sdk-capabilities-python
ddtrace/_trace/tracing_plugins/base/client.py                           @DataDog/apm-sdk-capabilities-python
ddtrace/_trace/tracing_plugins/base/consumer.py                         @DataDog/apm-sdk-capabilities-python
ddtrace/_trace/tracing_plugins/base/database.py                         @DataDog/apm-sdk-capabilities-python
ddtrace/_trace/tracing_plugins/base/events.py                           @DataDog/apm-sdk-capabilities-python
ddtrace/_trace/tracing_plugins/base/inbound.py                          @DataDog/apm-sdk-capabilities-python
ddtrace/_trace/tracing_plugins/base/outbound.py                         @DataDog/apm-sdk-capabilities-python
ddtrace/_trace/tracing_plugins/base/producer.py                         @DataDog/apm-sdk-capabilities-python
ddtrace/_trace/tracing_plugins/base/server.py                           @DataDog/apm-sdk-capabilities-python
ddtrace/_trace/tracing_plugins/base/storage.py                          @DataDog/apm-sdk-capabilities-python
ddtrace/_trace/tracing_plugins/base/tracing.py                          @DataDog/apm-sdk-capabilities-python
ddtrace/_trace/tracing_plugins/contrib/__init__.py                      @DataDog/apm-sdk-capabilities-python
ddtrace/_trace/tracing_plugins/contrib/asyncpg.py                       @DataDog/apm-sdk-capabilities-python
ddtrace/contrib/auto/__init__.py                                        @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/auto/_base.py                                           @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/auto/asyncpg/__init__.py                                @DataDog/apm-core-python @DataDog/apm-idm-python
docs/design/instrumentation-api-v2.md                                   @DataDog/python-guild
docs/design/integration-system-v2.md                                    @DataDog/python-guild

@github-actions
Copy link
Contributor

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 248 ± 2 ms.

The average import time from base is: 253 ± 4 ms.

The import time difference between this PR and base is: -4.6 ± 0.1 ms.

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 2.834 ms (1.14%)
ddtrace.bootstrap.sitecustomize 1.453 ms (0.59%)
ddtrace.bootstrap.preload 1.453 ms (0.59%)
ddtrace.internal.remoteconfig.client 0.666 ms (0.27%)
ddtrace 1.382 ms (0.56%)
ddtrace._logger 0.698 ms (0.28%)
ddtrace.internal.telemetry 0.698 ms (0.28%)
ddtrace.internal.telemetry.writer 0.698 ms (0.28%)
ddtrace.internal.utils.version 0.698 ms (0.28%)
ddtrace.version 0.698 ms (0.28%)
ddtrace.internal._unpatched 0.028 ms (0.01%)
json 0.028 ms (0.01%)
json.decoder 0.028 ms (0.01%)
re 0.028 ms (0.01%)
enum 0.028 ms (0.01%)
types 0.028 ms (0.01%)


Usage:
# During ddtrace initialization
from ddtrace._trace.tracing_plugins import initialize
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the plugins going to be tracer specific? Would it make sense to put these modules in ddtrace/internal/plugins/..... I can see other products (asm, llmobs, serverless, ...) extending or using these plugins. Making them tracing specific puts us in a corner.

_initialized = True

# Import contrib plugins
from ddtrace._trace.tracing_plugins.contrib import asyncpg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid inlining imports at all costs. This is a code smell and a sign of circular imports. If importing modules have unintended side effects we should remove them (ex: importing from ddtrace.contrib should not register trace handler listeners, we should get rid of this import side effect)

"""

kind = SpanKind.CLIENT
type = "web"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use SpanType here.

(receiving data FROM a message broker/queue).
"""

from typing import TYPE_CHECKING
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't use TYPE_CHECKING constant any more. This is used to support python2 style typing (types in comments). We should enforce python3 typing and if we do we don;t need to hid imports.

Using this is actually a code smell because it can hide circular imports

return

# Mark as measured
span.set_metric(_SPAN_MEASURED_KEY, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very important tag for trace metrics. Now that we are getting rid of integration specific service names we will ONLY compute trace metrics for spans with this tag OR tags that have a span.kind of producer, server, client, and producer.

To be safe we should move this to be a core component for all plugins. This should be set on the first span for each integration


def on_finish(
self,
ctx: "ExecutionContext",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we avoiding circular imports here? Can we avoid this?

from ddtrace.constants import SPAN_KIND
from ddtrace.internal.constants import COMPONENT

pin = ctx.get_item("pin")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of pin. do not use it anywhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants