Skip to content

Commit fa804ad

Browse files
authored
DOCS-4321 Add Go instructions for OTel inst (DataDog#17897)
* add go * add note about dependence on OTel * nit
1 parent 0407333 commit fa804ad

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

config/_default/menus/menus.en.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,11 @@ main:
14421442
parent: tracing_otel_inst
14431443
identifier: tracing_otel_inst_ruby
14441444
weight: 103
1445+
- name: Go
1446+
url: tracing/trace_collection/otel_instrumentation/go/
1447+
parent: tracing_otel_inst
1448+
identifier: tracing_otel_inst_go
1449+
weight: 104
14451450
- name: .NET
14461451
url: tracing/trace_collection/otel_instrumentation/dotnet/
14471452
parent: tracing_otel_inst
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: Custom Instrumentation of Go Applications with the OpenTelemetry API
3+
kind: documentation
4+
description: 'Instrument your Go application with OTel API to send traces to Datadog'
5+
code_lang: go
6+
type: multi-code-lang
7+
code_lang_weight: 30
8+
further_reading:
9+
- link: 'tracing/glossary/'
10+
tag: 'Documentation'
11+
text: 'Explore your services, resources, and traces'
12+
---
13+
14+
{{% otel-custom-instrumentation %}}
15+
16+
## Requirements and limitations
17+
18+
- Datadog Go tracing library `dd-trace-go` version 1.5.0 or greater.
19+
- Go version 1.8 or greater.
20+
- The Datadog OTel API implementation is dependent on upstream [OpenTelemetry Go][6].
21+
22+
The following OTel features are implemented in the Datadog library as noted:
23+
24+
| Feature | Support notes |
25+
|---------------------------------------|------------------------------------|
26+
| [OTel Context propagation][1] | [Datadog distributed header format][9] is used instead. |
27+
| [Span processors][2] | Unsupported |
28+
| [Span Exporters][3] | Unsupported |
29+
| Trace/span [ID generators][4] | ID generation is performed by `ddtrace`. |
30+
31+
32+
## Configuring OTel to use the Datadog trace provider
33+
34+
1. Add your desired manual OTel instrumentation to your Go code following the [OTel Go Manual Instrumentation documentation][5].
35+
36+
2. Install the OpenTelemetry package `go.opentelemetry.io/otel` using the command:
37+
38+
```shell
39+
go get go.opentelemetry.io/otel
40+
```
41+
42+
3. Install the Datadog OpenTelemetry wrapper package `gopkg.in/DataDog/dd-trace-go.v1/ddtrace/opentelemetry` using the command:
43+
44+
```shell
45+
go get gopkg.in/DataDog/dd-trace-go.v1/ddtrace/opentelemetry
46+
```
47+
48+
4. Import packages in the code:
49+
50+
```go
51+
import (
52+
"go.opentelemetry.io/otel"
53+
ddotel "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/opentelemetry"
54+
)
55+
```
56+
57+
5. Create a TracerProvider, optionally providing a set of options, that are specific to Datadog APM, and defer the Shutdown method, which stops the tracer:
58+
59+
```go
60+
provider := ddotel.NewTracerProvider()
61+
defer provider.Shutdown()
62+
```
63+
64+
6. Use the Tracer Provider instance with the OpenTelemetry API to set the global TracerProvider:
65+
66+
```go
67+
otel.SetTracerProvider(provider)
68+
```
69+
70+
7. Run your application.
71+
72+
Datadog combines these OpenTelemetry spans with other Datadog APM spans into a single trace of your application.
73+
74+
75+
[1]: https://opentelemetry.io/docs/instrumentation/go/manual/#propagators-and-context
76+
[2]: https://opentelemetry.io/docs/reference/specification/trace/sdk/#span-processor
77+
[3]: https://opentelemetry.io/docs/reference/specification/trace/sdk/#span-exporter
78+
[4]: https://opentelemetry.io/docs/reference/specification/trace/sdk/#id-generators
79+
[5]: https://opentelemetry.io/docs/instrumentation/go/manual/
80+
[6]: https://opentelemetry.io/docs/instrumentation/go/
81+
[9]: /tracing/trace_collection/trace_context_propagation/go/

layouts/partials/apm/apm-otel-instrumentation.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
</div>
2424
</a>
2525
</div>
26+
<div class="col">
27+
<a class="card h-100" href="go">
28+
<div class="card-body text-center py-2 px-1">
29+
{{ partial "img.html" (dict "root" . "src" "integrations_logos/golang.png" "class" "img-fluid" "alt" "Go" "width" "400") }}
30+
</div>
31+
</a>
32+
</div>
2633
<div class="col">
2734
<a class="card h-100" href="dotnet">
2835
<div class="card-body text-center py-2 px-1">

0 commit comments

Comments
 (0)