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)
In order to use this package, you must also install the GRPC package using PECL. See the instructions on the [OpenTelemetry PHP repository](https://github.com/open-telemetry/opentelemetry-php#optional-dependencies) for more information.
TracingsupportfordownstreamAWSSDKcallstoAmazonDynamoDB, S3, andothersisprovidedbythe [OpenTelemetryPHPAWSSDKInstrumentation](https://github.com/open-telemetry/opentelemetry-php-contrib/tree/main/src/Instrumentation/AwsSdk). The example below demonstrates setting up the AWS SDK instrumentation and tracing a call to S3.
0 commit comments