Skip to content

Commit 2536f5e

Browse files
Reorganize the documentation (#335)
1 parent 64f90a7 commit 2536f5e

8 files changed

Lines changed: 111 additions & 95 deletions

File tree

CONTRIBUTING.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
# Contributing to dd-trace-cpp
1+
# Contributing to the Datadog C++ Tracer
22

33
Pull requests for bug fixes are welcome.
44

55
Before submitting new features or changes to current functionality, [open an
66
issue](https://github.com/DataDog/dd-trace-cpp/issues/new) and discuss your ideas or propose the
77
changes you wish to make. After a resolution is reached, a PR can be submitted for review.
88

9-
## Code Style
10-
11-
C++ code is formatted using `clang-format-14`. Before submitting code changes, run the following
12-
command:
13-
14-
```shell
15-
bin/format
16-
```
9+
Please refer to the [documentation](docs) to learn about the architecture of the Datadog of C++ Tracing
10+
Library and the development processes, notably testing and code formatting, which are mandatory before
11+
submitting code changes.

README.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# Datadog C++ Tracing Library
1+
# Datadog C++ Tracer
2+
3+
This `dd-trace-cpp` repository contains the Datadog C++ Tracer, which is the [Datadog Application
4+
Performance Monitoring (APM)](https://docs.datadoghq.com/tracing) C++ client library.
5+
6+
## Usage Example
27

38
```c++
49
#include <datadog/span_config.h>
@@ -37,7 +42,7 @@ int main() {
3742
}
3843
```
3944

40-
See the [examples](examples) directory for more extensive usage examples.
45+
See the [examples](examples) for more extensive usage examples.
4146

4247
## Platform Support
4348

@@ -107,21 +112,12 @@ options is not needed. The `-ldd_trace_cpp` option is always needed.
107112
c++ -o my_app my_app.o -L/path/to/dd-trace-cpp/.install/lib -ldd_trace_cpp
108113
```
109114

110-
## Test
111-
112-
Pass `-DDD_TRACE_BUILD_TESTING=1` to `cmake` to include the unit tests in the build.
113-
114-
The resulting unit test executable is `test/tests` within the build directory.
115-
116-
```shell
117-
cmake -B build -DDD_TRACE_BUILD_TESTING=1 .
118-
cmake --build build -j
119-
./build/test/tests
120-
```
115+
## Contributing
121116

122-
Alternatively, [bin/test](bin/test) is provided for convenience.
117+
See the [contributing guidelines](CONTRIBUTING.md) if you would like to contribute to the Datadog
118+
C++ Tracer.
123119

124-
## Contributing
120+
## Security
125121

126-
See the [contributing guidelines](CONTRIBUTING.md) and the [maintainer docs](doc/maintainers.md) for
127-
information on the overall structure of the repository.
122+
If you discover a security vulnerablity in the Datadog C++ Tracer, please refer to the [Security
123+
Policy](SECURITY.md).

SECURITY.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Security Policy
1+
# Datadog C++ Tracer Security Policy
22

3-
This document outlines the security policy for the Datadog C++ client library (a.k.a. C++ tracer)
4-
and what to do if you discover a security vulnerability in the project. Most notably, please do not
5-
share the details in a public forum (such as in a discussion, issue, or pull request) but instead
6-
reach out to us with the details. This gives us an opportunity to release a fix for others to
7-
benefit from by the time details are made public.
3+
This document outlines the security policy for the Datadog C++ Tracer and what to do if you discover
4+
a security vulnerability in the project. Most notably, please do not share the details in a public
5+
forum (such as in a discussion, issue, or pull request) but instead reach out to us with the
6+
details. This gives us an opportunity to release a fix for others to benefit from by the time
7+
details are made public.
88

99
## Supported Versions
1010

@@ -13,7 +13,5 @@ release](https://github.com/DataDog/dd-trace-cpp/releases).
1313

1414
## Reporting a Vulnerability
1515

16-
If you discover a vulnerability in the Datadog C++ client library (or any Datadog product for that
17-
matter) please submit details to the following email address:
18-
19-
* [security@datadoghq.com](mailto:security@datadoghq.com)
16+
If you discover a vulnerability in the Datadog C++ Tracer (or any Datadog product for that matter)
17+
please submit details to the [security@datadoghq.com](mailto:security@datadoghq.com) email address.

doc/README.md

Lines changed: 0 additions & 49 deletions
This file was deleted.

docs/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Datadog C++ Tracer Documentation
2+
3+
This directory contains documentation of the Datadog C++ Tracer, including:
4+
5+
- [Design](design.md)
6+
- [Development Processes](development.md)
File renamed without changes.
Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
# Care and Feeding of Your New Tracing Library
1+
# Datadog C++ Tracer Design
22

3-
Congratulations! You are now the proud owner of a distributed tracing library.
4-
5-
The primary purpose of this guide is to describe salient features of the library's design.
6-
`dd-trace-cpp` differs considerably from its [older
3+
The primary purpose of this guide is to describe salient features of the Datadog C++ Tracer's
4+
design. It differs considerably from its [older
75
sibling](https://github.com/DataDog/dd-opentracing-cpp) and
86
[peers](https://github.com/open-telemetry/opentelemetry-cpp).
97

108
This guide will also cover operations performed by maintainers of the library, such as scooping the
119
box, applying flea medication, and regular trips to the vet.
1210

13-
## Design
11+
## Architecture
1412

1513
### Span
1614

@@ -278,7 +276,55 @@ uses a different implementation, [class AgentHTTPClient : public HTTPClient,
278276
...](https://github.com/envoyproxy/envoy/blob/main/source/extensions/tracers/datadog/agent_http_client.h),
279277
which uses Envoy's built-in HTTP facilities. libcurl is not involved at all.
280278

281-
### EventScheduler
279+
### Logical Component Relationships
280+
281+
- Vertices are components.
282+
- Edges are ownership relationships between components. Each edge is labeled by the kind of pointer
283+
that is used to implement the relationship.
284+
- Components with a padlock are protected by a mutex.
285+
286+
```mermaid
287+
---
288+
title: Components Relationships
289+
config:
290+
layout: elk
291+
---
292+
graph LR;
293+
Tracer(Tracer) & TraceSegment("TraceSegment 🔒")-- shared -->Collector("Collector 🔒") & SpanSampler("SpanSampler 🔒") & TraceSampler("TraceSampler 🔒")
294+
TraceSegment-- "`**unique**`" -->SpanData(SpanData)
295+
Span(Span)-- shared -->TraceSegment
296+
Span-- "`**raw**`" -->SpanData
297+
```
298+
299+
Objects:
300+
301+
- `Span` has a beginning, end, and tags. It is associated with a `TraceSegment`.
302+
- `TraceSegment` is part of a trace. It makes sampling decisions, detects when it is finished, and
303+
sends itself to the `Collector`.
304+
- `Collector` receives trace segments. It provides a callback to deliver sampler modifications, if
305+
applicable.
306+
- `Tracer` is responsible for creating trace segments. It contains the instances of, and
307+
configuration for, the `Collector`, `TraceSampler`, and `SpanSampler`. A tracer is created from a
308+
`TracerConfig`.
309+
- `TraceSampler` is used by trace segments to decide when to keep or drop themselves.
310+
- `SpanSampler` is used by trace segments to decide which spans to keep when the segment is dropped.
311+
- `TracerConfig` contains all of the information needed to configure the collector, trace sampler,
312+
and span sampler, as well as defaults for span properties.
313+
314+
Intended usage is:
315+
316+
1. Create a `TracerConfig`.
317+
2. Use the `TracerConfig` to create a `Tracer`.
318+
3. Use the `Tracer` to create and/or extract local root `Span`s.
319+
4. Use `Span` to create children and/or inject context.
320+
5. Use a `Span`'s `TraceSegment` to perform trace-wide operations.
321+
6. When all `Span`s in `TraceSegment` are finished, the segment is sent to the
322+
`Collector`.
323+
324+
Different instances of `Tracer` are independent of each other. If an application wishes to
325+
reconfigure tracing at runtime, it can create another `Tracer` using the new configuration.
326+
327+
## EventScheduler
282328

283329
As of this writing, `class DatadogAgent` flushes batches of finished trace segments to the Datadog
284330
Agent once every two second [by
@@ -314,7 +360,7 @@ also uses a different implementation, [class EventScheduler : public
314360
EventScheduler](https://github.com/envoyproxy/envoy/blob/main/source/extensions/tracers/datadog/event_scheduler.h),
315361
which uses Envoy's built-in event dispatch facilities.
316362
317-
### Configuration
363+
## Configuration
318364
319365
There's a good [blog post](https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/) by
320366
[Alexis King](https://lexi-lambda.github.io/about.html) where she makes the case for encoding
@@ -362,7 +408,7 @@ is to prevent eventual intermixing between the "configuration representation" an
362408
representation." In part, `finalize_config` already mitigates the problem. Abstaining from storing
363409
the finalized config as a data member is a step further.
364410
365-
### Error Handling
411+
## Error Handling
366412
367413
Most error scenarios within this library are individually enumerated by `enum Error::Code`, defined
368414
in [error.h](../include/datadog/error.h).
@@ -514,7 +560,7 @@ operator bool` has the opposite meaning as it does in `Expected<T>`. I wanted er
514560
be the same in the two cases, and so I specialized `Expected<void>`. `Expected<void>` is implemented
515561
in terms of `std::optional<Error>`, but inverts the value of `explicit operator bool`.
516562
517-
### Logging
563+
## Logging
518564
519565
Can we write a tracing library that does not do any logging by itself? The previous section
520566
describes how errors are reported by the library, and no logging is involved there. Why not leave it

docs/development.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Datadog C++ Tracer Development Processes
2+
3+
## Test
4+
5+
Pass `-DDD_TRACE_BUILD_TESTING=1` to `cmake` to include the unit tests in the build.
6+
7+
The resulting unit test executable is `test/tests` within the build directory.
8+
9+
```shell
10+
cmake -B build -DDD_TRACE_BUILD_TESTING=1 .
11+
cmake --build build -j
12+
./build/test/tests
13+
```
14+
15+
Alternatively, [bin/test](../bin/test) is provided for convenience.
16+
17+
## Code Style
18+
19+
C++ code is formatted using `clang-format-14`. Before submitting code changes, run the following
20+
command:
21+
22+
```shell
23+
bin/format
24+
```

0 commit comments

Comments
 (0)