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

add simple documentation for ddtrace-api package #28254

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

emmettbutler
Copy link
Contributor

What does this PR do? What is the motivation?

This change adds basic documentation of the ddtrace-api Python package, recently released on PyPI.

Merge instructions

Merge readiness:

  • Ready for merge

Merge queue is enabled in this repo. To have it automatically merged after it receives the required reviews, create the PR (from a branch that follows the <yourname>/description naming convention) and then add the following PR comment:

/merge

Additional notes

@emmettbutler emmettbutler requested review from a team as code owners March 19, 2025 19:07
@github-actions github-actions bot added the Architecture Everything related to the Doc backend label Mar 19, 2025
@emmettbutler emmettbutler added tracing Content changed in the tracing folder and removed Architecture Everything related to the Doc backend labels Mar 19, 2025
Copy link
Contributor

github-actions bot commented Mar 19, 2025

Preview links (active after the build_preview check completes)

Modified Files

@github-actions github-actions bot added the Architecture Everything related to the Doc backend label Mar 19, 2025
@jhgilbert jhgilbert added the editorial review Waiting on a more in-depth review label Mar 19, 2025
Copy link
Contributor

@brett0000FF brett0000FF left a comment

Choose a reason for hiding this comment

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

@emmettbutler - Very cool! Thanks for adding this content.

I am going to be OOO for the rest of the week shortly, so I wanted to share a couple high-level thoughts before I can review in more detail next week.

It seems like we could simplify this quite a bit by integrating it into the existing Datadog API page? From my quick scan, the main difference for users appears to be using from dd_trace_api import tracer instead of from ddtrace import tracer, plus installing an additional package.

The current tab structure (ddtrace-api, Datadog API, OpenTelemetry API) suggests these are parallel, alternative approaches, when ddtrace-api actually seems to be a complementary layer that works with the standard ddtrace implementation.

I might be missing certain technical context, but presenting this as a separate, duplicated documentation page might create confusion about the relationship between these packages and increase our maintenance burden when documentation needs to be updated.

@emmettbutler
Copy link
Contributor Author

@brett0000FF making this an extension of the Datadog API tab was the first approach I considered. I chose instead to make it a separate tab to make it as clear as possible that this is an early and unstable feature. Depending on how one looks at it, dd-trace-api can also be considered a parallel integration method to ddtrace and otel. The fact that it can be used as a drop-in replacement for the ddtrace API is important to the rollout plan, because we want to avoid ever requiring users to do a hard cutover from one method to the other.

If you think it's important enough, I could replace the new tab with a paragraph at the bottom of the Datadog API tab labelled "pre-release".

@brett0000FF
Copy link
Contributor

If you think it's important enough, I could replace the new tab with a paragraph at the bottom of the Datadog API tab labelled "pre-release".

@emmettbutler - I think I would be in favor of removing the separate tab for now and integrating this content into the existing DD API tab. I definitely see where you are coming from, but I think having this as a parallel tab, especially when in Preview, could create more confusion for users. Preview features are typically more hidden in the docs.

I'd be happy to take a crack at moving the content if that'd be helpful!

@github-actions github-actions bot removed the Architecture Everything related to the Doc backend label Mar 28, 2025
Copy link
Contributor

@brett0000FF brett0000FF left a comment

Choose a reason for hiding this comment

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

@emmettbutler - Looks great, thank you! I just left a few suggestions with minor edits for readability.

Comment on lines +268 to +269
<div class="alert alert-warning">The ddtrace-api Python package is in preview and may not include the API calls you need. If you'd rather use something more complete, use the API described above.
The following steps are only necessary if you want to experiment with the preview `ddtrace-api` package.</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<div class="alert alert-warning">The ddtrace-api Python package is in preview and may not include the API calls you need. If you'd rather use something more complete, use the API described above.
The following steps are only necessary if you want to experiment with the preview `ddtrace-api` package.</div>
{{< callout btn_hidden="true" header="ddtrace-api is in Preview!">}}
The <code>ddtrace-api</code> Python package is in Preview and may not include all the API calls you need. If you need more complete functionality, use the API as described in the previous sections.
<br><br>The following steps are only necessary if you want to experiment with the in Preview <code>ddtrace-api</code> package.{{< /callout >}}

This is our standard alert box style for features in Preview. Here's how it looks rendered:
image

Comment on lines +271 to +274
A stable public API for Datadog APM's custom Python instrumentation is implemented by the [ddtrace-api package][8]. This package doesn't implement any of the underlying functionality that creates and
sends spans to Datadog; it *only* implements the API interface. This separation between interface in `ddtrace-api` and implementation in `ddtrace` allows users of cusom instrumentation to rely on
an API that changes less frequently and more predictably, while allowing autoinstrumentation-only users to ignore API changes. It also supports those users who integrate both single-step instrumentation
and custom instrumentation by removing the need to depend on two copies of the `ddtrace` package.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
A stable public API for Datadog APM's custom Python instrumentation is implemented by the [ddtrace-api package][8]. This package doesn't implement any of the underlying functionality that creates and
sends spans to Datadog; it *only* implements the API interface. This separation between interface in `ddtrace-api` and implementation in `ddtrace` allows users of cusom instrumentation to rely on
an API that changes less frequently and more predictably, while allowing autoinstrumentation-only users to ignore API changes. It also supports those users who integrate both single-step instrumentation
and custom instrumentation by removing the need to depend on two copies of the `ddtrace` package.
The [ddtrace-api package][8] provides a stable public API for Datadog APM's custom Python instrumentation. This package implements only the API interface, not the underlying functionality that creates and sends spans to Datadog.
This separation between interface (`ddtrace-api`) and implementation (`ddtrace`) offers several benefits:
- You can rely on an API that changes less frequently and more predictably for your custom instrumentation
- If you only use automatic instrumentation, you can ignore API changes entirely
- If you implement both single-step and custom instrumentation, you avoid depending on multiple copies of the `ddtrace` package

Just some light edits and breaking the content out.

Comment on lines +276 to +302
The separation of interface and implementation means that setting up custom instrumentation requires installing two libraries: `ddtrace` as explained in the [Python Setup Instructions][6]
and `ddtrace-api`:

```python
pip install 'ddtrace>=3.1' ddtrace-api
```

Then to instrument your Python application use the included `ddtrace-run` command. To use it, prefix your Python entry-point command with `ddtrace-run`.

For example, if your application is started with `python app.py` then:

```shell
ddtrace-run python app.py
```

Once you've done this setup, you can write custom instrumentation just like the above examples, with `ddtrace` replaced by `dd_trace_api`. For example:

```python
from dd_trace_api import tracer

@tracer.wrap(service="my-sandwich-making-svc", resource="resource_name")
def get_ingredients():
# go to the pantry
# go to the fridge
# maybe go to the store
return
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The separation of interface and implementation means that setting up custom instrumentation requires installing two libraries: `ddtrace` as explained in the [Python Setup Instructions][6]
and `ddtrace-api`:
```python
pip install 'ddtrace>=3.1' ddtrace-api
```
Then to instrument your Python application use the included `ddtrace-run` command. To use it, prefix your Python entry-point command with `ddtrace-run`.
For example, if your application is started with `python app.py` then:
```shell
ddtrace-run python app.py
```
Once you've done this setup, you can write custom instrumentation just like the above examples, with `ddtrace` replaced by `dd_trace_api`. For example:
```python
from dd_trace_api import tracer
@tracer.wrap(service="my-sandwich-making-svc", resource="resource_name")
def get_ingredients():
# go to the pantry
# go to the fridge
# maybe go to the store
return
```
To use `ddtrace-api`:
1. Install both the `ddtrace` and `ddtrace-api` libraries:
```python
pip install 'ddtrace>=3.1' ddtrace-api
```
2. Instrument your Python application using `ddtrace-run` by prefixing your Python entry-point command:
```shell
ddtrace-run python app.py
```
3. After this is set up, you can write custom instrumentation exactly like the examples in the previous sections, but you import from `dd_trace_api` instead of `ddtrace`.
For example:
```python
from dd_trace_api import tracer
@tracer.wrap(service="my-sandwich-making-svc", resource="resource_name")
def get_ingredients():
# go to the pantry
# go to the fridge
# maybe go to the store
return
```

Basically the same content, but this puts it into a numbered list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial review Waiting on a more in-depth review tracing Content changed in the tracing folder
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants