You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go `v1.15` or later is required to run an application using OpenTelemetry. Visit the [compatibility chart](https://github.com/open-telemetry/opentelemetry-go#compatibility) of OpenTelemetry Go SDK with different `OS`, `Go Version` and `Architecture`.
32
+
Go `v1.19` or later is required to run an application using OpenTelemetry. Visit the [compatibility chart](https://github.com/open-telemetry/opentelemetry-go#compatibility) of OpenTelemetry Go SDK with different `OS`, `Go Version` and `Architecture`.
33
33
34
-
Note: You’ll also need to have the [ADOT Collector](https://aws-otel.github.io/docs/getting-started/collector) running to export traces to X-Ray.
34
+
Note: You’ll also need to have the [ADOT Collector](https://aws-otel.github.io/docs/getting-started/collector) running to export traces and metrics.
35
35
36
36
<SectionSeparator />
37
37
@@ -44,6 +44,9 @@ Download and install the following packages to use ADOT Components with OpenTele
44
44
3. OTel Go SDK for tracing
45
45
4. OTel Go API for tracing
46
46
5. OTLP gRPC exporter for exporting trace data
47
+
6. OTel Go SDK for metrics
48
+
7. OTel Go API for metrics
49
+
8. OTLP gRPC exporter for exporting metric data
47
50
```
48
51
49
52
To install the above mentioned necessary prerequisites, run the following command in the same directory that the application `go.mod` file is in:
@@ -53,13 +56,15 @@ go get go.opentelemetry.io/otel
53
56
go get go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
54
57
go get go.opentelemetry.io/otel/sdk/resource
55
58
go get go.opentelemetry.io/otel/sdk/trace
59
+
go get go.opentelemetry.io/otel/sdk/metric
60
+
go get go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc
56
61
```
57
62
58
63
<SectionSeparator />
59
64
60
65
## Setting up the Global Tracer
61
66
62
-
### Sending Traces to AWS X-Ray
67
+
### Sending Traces
63
68
64
69
This section talks about how to instantiate a new tracer provider with the X-Ray ID generator and sampling config, setting global options (X-Ray propagator, tracer provider) and instantiate OTLP exporter with the collector's address to export trace data.
65
70
@@ -70,10 +75,9 @@ This section talks about how to instantiate a new tracer provider with the X-Ray
70
75
OpenTelemetry Go requires an exporter to send traces to a backend. Exporters allow telemetry data to be transferred either to the AWS Distro for OpenTelemetry Collector (ADOT Collector), or to a remote system or console for further analysis. The ADOT Collector is a separate process that is designed to be a "sink" for telemetry data emitted by many processes, which can then export
71
76
that data to various back-end systems.
72
77
73
-
To initialize the OTLP exporter, add the following code to the file the `main.go` file.
78
+
To initialize the OTLP trace exporter, add the following code to the file the `main.go` file.
74
79
75
-
76
-
**IMPORTANT**: The following example creates an OTLP exporter that does not encrypt data at transfer because it uses the `otlptracegrpc.WithInsecure()` option. This should only be used for creating proof of concepts and experimenting with the Go SDK.
80
+
**IMPORTANT**: The following examples creates an OTLP exporter that does not encrypt data at transfer because it uses the `otlptracegrpc.WithInsecure()` option. This should only be used for creating proof of concepts and experimenting with the Go SDK.
77
81
For production environments you must properly configure TLS using the `otlptracegrpc.WithTLSCredentials` function.
This section talks about how to instantiate a new meter provider , setting global options (meter provider) and instantiate OTLP exporter with the collector's address to export metric data.
147
+
148
+
#### Creating an OpenTelemetry Protocol (OTLP) Exporter
149
+
150
+
OpenTelemetry Go requires an exporter to send metrics to a backend. Exporters allow telemetry data to be transferred either to the AWS Distro for OpenTelemetry Collector (ADOT Collector), or to a remote system or console for further analysis. The ADOT Collector is a separate process that is designed to be a "sink" for telemetry data emitted by many processes, which can then export
151
+
that data to various back-end systems.
152
+
153
+
To initialize the OTLP metric exporter, add the following code to the file the `main.go` file.
154
+
155
+
**IMPORTANT**: The following examples creates an OTLP exporter that does not encrypt data at transfer because it uses the `otlpmetricgrpc.WithInsecure()` option. This should only be used for creating proof of concepts and experimenting with the Go SDK.
156
+
For production environments you must properly configure TLS using the `otlpmetricgrpc.WithTLSCredentials` function.
log.Fatalf("failed to create new OTLP metric exporter: %v", err)
163
+
}
164
+
```
165
+
166
+
#### Creating a Meter Provider
167
+
168
+
In order to generate metrics, OpenTelemetry Go SDK requires a meter provider to be created. The meter provider is configured with a periodic reader in this example.
169
+
170
+
To create a new meter provider, add the following lines to the `main.go` file.
Above block of code creates a new `MeterProvider` with a periodic reader.
176
+
177
+
178
+
#### Setting Global Options
179
+
180
+
To set up global options for the meter provider, we will use the `otel` package and add the following line to the `main.go` file.
181
+
```go lineNumbers=true
182
+
otel.SetMeterProvider(mp)
183
+
```
138
184
139
185
<SubSectionSeparator />
140
186
@@ -256,7 +302,27 @@ _, span := tracer.Start(
256
302
defer span.End()
257
303
```
258
304
305
+
### Creating metrics
306
+
307
+
Similarly to Traces, you can create custom metrics in your application using the OpenTelemetry API and SDK.
308
+
309
+
In the following example application we demonstrate how to use metric instruments to record metrics with a Counter.
310
+
```go lineNumbers=true
311
+
varmeter = otel.Meter("demo")
312
+
timeAliveMetric, _:= meter.Int64Counter(
313
+
"time_alive",
314
+
instrument.WithDescription("Total amount of time that the application has been alive"),
315
+
instrument.WithUnit("ms"),
316
+
)
317
+
gofunc() {
318
+
for {
319
+
timeAliveMetric.Add(context.Background(), 1000, attribute.String("a", "1")) // in millisconds
320
+
time.Sleep(time.Second * time.Duration(1))
321
+
}
322
+
}()
323
+
```
324
+
259
325
<SectionSeparator />
260
326
261
327
## Sample Application
262
-
See [AWS Distro for OpenTelemetry Sample Code with Go SDK](https://github.com/aws-observability/aws-otel-go/tree/main/sampleapp) for instructions on setting up and using the sample app.
328
+
See [AWS Distro for OpenTelemetry Sample Code with Go SDK](https://github.com/aws-observability/aws-otel-community/tree/master/sample-apps/go-sample-app) for instructions on setting up and using the sample app.
Copy file name to clipboardExpand all lines: src/docs/getting-started/java-sdk.mdx
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,8 +17,9 @@ backend.
17
17
18
18
## Getting Started
19
19
20
-
*[Auto-Instrumentation for Traces and Metrics with the Java agent](/docs/getting-started/java-sdk/trace-auto-instr)
21
-
*[Manual Instrumentation for Traces and Metrics with the Java SDK](/docs/getting-started/java-sdk/trace-manual-instr)
20
+
*[Auto-Instrumentation for Traces and Metrics with the Java agent](/docs/getting-started/java-sdk/auto-instr)
21
+
*[Manual Instrumentation for Traces and Metrics with the Java SDK](/docs/getting-started/java-sdk/manual-instr)
22
22
23
23
## Sample Code
24
-
*[Sample Spring App using OpenTelemetry Java Auto-Instrumentation](https://catalog.us-east-1.prod.workshops.aws/workshops/31676d37-bbe9-4992-9cd1-ceae13c5116c/en-US/aws-managed-oss/adot/javawalkthrough)
24
+
*[Sample Spring App using OpenTelemetry Java Auto-Instrumentation Workshop](https://catalog.us-east-1.prod.workshops.aws/workshops/31676d37-bbe9-4992-9cd1-ceae13c5116c/en-US/aws-managed-oss/adot/javawalkthrough)
25
+
*[Sample App using OpenTelemetry Java Auto-Instrumentation and Manual-Instrumentation](https://github.com/aws-observability/aws-otel-community/tree/master/sample-apps/java-sample-app)
Copy file name to clipboardExpand all lines: src/docs/getting-started/javascript-sdk.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,5 +21,5 @@ In this tutorial, we will introduce how to use [OpenTelemetry JavaScript SDK](ht
21
21
22
22
23
23
## Sample Code with JavaScript SDK
24
-
*[AWS Distro for OpenTelemetry Sample Code with JavaScript SDK](https://github.com/aws-observability/aws-otel-js/tree/main/sample-apps)
24
+
*[AWS Distro for OpenTelemetry Sample Code with JavaScript SDK](https://github.com/aws-observability/aws-otel-community/tree/master/sample-apps/javascript-sample-app)
@@ -13,15 +13,15 @@ import SubSectionSeparator from "components/MdxSubSectionSeparator/subsectionSep
13
13
14
14
OpenTelemetry Python supports automatic instrumentation. It automatically produces spans with telemetry data describing the values used by the python frameworks in your application without adding a single line of code. This telemetry data can then be exported to a backend like AWS X-Ray using the ADOT Python `opentelemetry-sdk-extension-aws` package. We also strongly recommend using the `opentelemetry-propagator-aws-xray` package to support propagating the trace context across AWS services. This propagator handles the extraction and injecting of the [AWS X-Ray Tracing header](https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader) for requests from or to remote services.
15
15
16
-
In this guide, we walk through the steps needed to trace an application with auto-instrumentation.
16
+
In this guide, we walk through the steps needed to trace an application and produce metrics with auto-instrumentation.
17
17
18
18
<SectionSeparator />
19
19
20
20
## Requirements
21
21
22
22
Python 3.6 or later is required to run an application using OpenTelemetry.
23
23
24
-
Note: You’ll also need to have the [ADOT Collector](https://aws-otel.github.io/docs/getting-started/collector) running to export traces to X-Ray.
24
+
Note: You’ll also need to have the [ADOT Collector](https://aws-otel.github.io/docs/getting-started/collector) running to export traces and metrics.
Similarly to Traces, you can create custom metrics in your application using the OpenTelemetry API and SDK.
105
+
106
+
In the following example application we demonstrate how to use metric instruments to record metrics with a Counter.
107
+
```go lineNumbers=true
108
+
meter = metrics.get_meter(__name__)
109
+
time_alive_counter = meter.create_counter(
110
+
name="time_alive",
111
+
description="Total amount of time that the application has been alive",
112
+
unit='ms'
113
+
)
114
+
while True:
115
+
time_alive_counter.add(1, attributes={'a': '1'})
116
+
time.Sleep(1)
117
+
```
118
+
102
119
<SectionSeparator />
103
120
104
121
## Using Manual Instrumentation
105
122
106
-
Because there can only be one global `TracerProvider`, manual instrumentation should not instantiate its own `TracerProvider` if used together alongside auto-instrumentation. Given that the same `TracerProvider` is used, custom tracing works the same way when using automatic instrumentation or manual instrumentation. For information about custom trace instrumentation, see our [docs on manual instrumentation](/docs/getting-started/python-sdk/trace-manual-instr).
123
+
Because there can only be one global `TracerProvider` and `MeterProvider`, manual instrumentation should not instantiate its own `TracerProvider`or `MeterProvider`if used together alongside auto-instrumentation. Given that the same `TracerProvider`and `MeterProvider`is used, custom tracing and metrics works the same way when using automatic instrumentation or manual instrumentation. For information about custom trace instrumentation, see our [docs on manual instrumentation](/docs/getting-started/python-sdk/manual-instr).
107
124
108
125
<SectionSeparator />
109
126
110
127
## Sample Application
111
128
112
-
See a [sample Flask App using OpenTelemetry Python SDK Automatic Instrumentation](https://github.com/aws-observability/aws-otel-python/tree/main/integration-test-apps/auto-instrumentation/flask).
129
+
See a [Sample App using OpenTelemetry Python SDK Automatic Instrumentation](https://github.com/aws-observability/aws-otel-community/tree/master/sample-apps/python-auto-instrumentation-sample-app).
113
130
114
131
**NOTE:** Python Web Frameworks like Flask and Django normally include a "reloader" when running in `debug` mode so that you can apply changes during development. This reloader will break auto-instrumentation because the app is restarted without giving OpenTelemetry a chance to wrap the instrumented libraries. When using `debug` mode, set the `use_reloader=False` as is done in the referenced sample app:
0 commit comments