Skip to content

Commit

Permalink
Update website_docs for 1.0.0-RC1
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony J Mirabella <[email protected]>
  • Loading branch information
Aneurysm9 committed Jun 17, 2021
1 parent 4e492d3 commit ca3bf47
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 26 deletions.
2 changes: 1 addition & 1 deletion website_docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The current status of the major functional components for OpenTelemetry Go is as

| Tracing | Metrics | Logging |
| ------- | ------- | ------- |
| Beta | Alpha | Not Yet Implemented |
| Release Candidate | Alpha | Not Yet Implemented |

The current release can be found [here](https://github.com/open-telemetry/opentelemetry-go/releases)

Expand Down
28 changes: 23 additions & 5 deletions website_docs/exporting_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ Resources are a special type of attribute that apply to all spans generated by a
Resources should be assigned to a tracer provider at its initialization, and are created much like attributes:

```go
resources := resource.New(
attribute.String("service.name", "myService"),
attribute.String("service.version", "1.0.0"),
attribute.String("instance.id", "abcdef12345"),
resources := resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceNameKey.String("myService"),
semconv.ServiceVersionKey.String("1.0.0"),
semconv.ServiceInstanceIDKey.String("abcdef12345"),
)

provider := sdktrace.NewTracerProvider(
Expand All @@ -45,9 +46,26 @@ provider := sdktrace.NewTracerProvider(
)
```

Note the use of the `semconv` package to provide conventional names for resource attributes. This helps ensure that consumers of telemetry produced with these semantic conventions can
easily discover relevant attributes and understand their meaning.

Resources can also be detected automatically through `resource.Detector` implementations. These `Detector`s may discover information about the currently running process, the operating
system it is running on, the cloud provider hosting that operating system instance, or any number of other resource attributes.

```go
resources := resource.New(context.Background(),
// Builtin detectors provide default values and support
// OTEL_RESOURCE_ATTRIBUTES and OTEL_SERVICE_NAME environment variables
resource.WithBuiltinDetectors(),
resource.WithProcess(), // This option configures a set of Detectors that discover process information
resource.WithDetectors(thirdparty.Detector{}), // Bring your own external Detector implementation
resource.WithAttributes(attribute.String("foo", "bar")), // Or specify resource attributes directly
)
```

# OTLP Exporter

OpenTelemetry Protocol (OTLP) is available in the `go.opentelemetry.io/otel/exporters/otlp` package.
OpenTelemetry Protocol (OTLP) export is available in the `go.opentelemetry.io/otel/exporters/otlp/otlptrace` and `go.opentelemetry.io/otel/exporters/otlp/otlpmetrics` packages.

Please find more documentation on [GitHub](https://github.com/open-telemetry/opentelemetry-go/tree/main/exporters/otlp)

Expand Down
41 changes: 23 additions & 18 deletions website_docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ To get started with this guide, create a new directory and add a new file named

To install the necessary prerequisites for OpenTelemetry, you'll want to run the following command in the directory with your `go.mod`:

`go get go.opentelemetry.io/[email protected] go.opentelemetry.io/otel/[email protected] go.opentelemetry.io/otel/exporters/[email protected]`
`go get go.opentelemetry.io/[email protected] go.opentelemetry.io/otel/[email protected] go.opentelemetry.io/otel/exporters/stdout/[email protected]`

If you wish to include the experimental metrics support you will need to include a few additional modules:

`go get go.opentelemetry.io/otel/[email protected] go.opentelemetry.io/otel/sdk/[email protected] go.opentelemetry.io/otel/exporters/stdout/[email protected]`

In your `main.go` file, you'll need to import several packages:

Expand All @@ -28,17 +32,19 @@ import (
"time"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/baggage"
"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
"go.opentelemetry.io/otel/exporters/stdout/stdoutmetric"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"

// For experimental metrics support, also include:
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/exporters/stdout/stdoutmetric"
controller "go.opentelemetry.io/otel/sdk/metric/controller/basic"
processor "go.opentelemetry.io/otel/sdk/metric/processor/basic"
"go.opentelemetry.io/otel/sdk/metric/selector/simple"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/trace"
)
```

Expand All @@ -48,7 +54,7 @@ These packages contain the basic requirements for OpenTelemetry Go - the API its

The SDK requires an exporter to be created. Exporters are packages that allow telemetry data to be emitted somewhere - either to the console (which is what we're doing here), or to a remote system or collector for further analysis and/or enrichment. OpenTelemetry supports a variety of exporters through its ecosystem including popular open source tools like Jaeger, Zipkin, and Prometheus.

To initialize the console exporter, add the following code to the file your `main.go` file -
To initialize the console exporter, add the following code to the file your `main.go` file:

```go
func main() {
Expand All @@ -68,7 +74,7 @@ A trace is a type of telemetry that represents work being done by a service. In
OpenTelemetry requires a trace provider to be initialized in order to generate traces. A trace provider can have multiple span processors, which are components that allow for span data to be modified or exported after it's created.
To create a trace provider, add the following code to your `main.go` file -
To create a trace provider, add the following code to your `main.go` file:
```go
ctx := context.Background()
Expand All @@ -87,7 +93,7 @@ A metric is a captured measurement about the execution of a computer program at
OpenTelemetry requires a meter provider to be initialized in order to create instruments that will generate metrics. The way metrics are exported depends on the used system. For example, prometheus uses a pull model, while OTLP uses a push model. In this document we use an stdout exporter which uses the latter. Thus we need to create a push controller that will periodically push the collected metrics to the exporter.
To create a meter provider, add the following code to your `main.go` file -
To create a meter provider, add the following code to your `main.go` file:
```go
metricExporter, err := stdoutmetric.New(
Expand Down Expand Up @@ -121,7 +127,7 @@ Again we create an exporter, this time using the `stdoutmetric` exporter package
When using OpenTelemetry, it's a good practice to set a global tracer provider and a global meter provider. Doing so will make it easier for libraries and other dependencies that use the OpenTelemetry API to easily discover the SDK, and emit telemetry data. In addition, you'll want to configure context propagation options. Context propagation allows for OpenTelemetry to share values across multiple services - this includes trace identifiers, which ensure that all spans for a single request are part of the same trace, as well as baggage, which are arbitrary key/value pairs that you can use to pass observability data between services (for example, sharing a customer ID from one service to the next).
Setting up global options uses the `otel` package - add these options to your `main.go` file as shown -
Setting up global options uses the `otel` package - add these options to your `main.go` file as shown:
```go
otel.SetTracerProvider(tp)
Expand All @@ -141,8 +147,6 @@ Each measurement can be associated with attributes that can later be used by vis
To set up some metric instruments, add the following code to your `main.go` file -
```go
fooKey := attribute.Key("ex.com/foo")
barKey := attribute.Key("ex.com/bar")
lemonsKey := attribute.Key("ex.com/lemons")
anotherKey := attribute.Key("ex.com/another")

Expand Down Expand Up @@ -171,10 +175,13 @@ Let's put the concepts we've just covered together, and create a trace and some
```go
tracer := otel.Tracer("ex.com/basic")
ctx = baggage.ContextWithValues(ctx,
fooKey.String("foo1"),
barKey.String("bar1"),
)

// we're ignoring errors here since we know these values are valid,
// but do handle them appropriately if dealing with user-input
foo, _ := baggage.NewMember("ex.com.foo", "foo1")
bar, _ := baggage.NewMember("ex.com.bar", "bar1")
bag, _ := baggage.New(foo, bar)
ctx = baggage.ContextWithBaggage(ctx, bag)

func(ctx context.Context) {
var span trace.Span
Expand All @@ -185,8 +192,6 @@ Let's put the concepts we've just covered together, and create a trace and some
span.SetAttributes(anotherKey.String("yes"))

meter.RecordBatch(
// Note: call-site variables added as context Entries:
baggage.ContextWithValues(ctx, anotherKey.String("xyz")),
commonAttributes,

valueRecorder.Measurement(2.0),
Expand Down
4 changes: 2 additions & 2 deletions website_docs/instrumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Spans are created by tracers, which can be acquired from a Tracer Provider.

```go
ctx := context.Background()
tracer := provider.Tracer("example/main")
tracer := otel.Tracer("example/main")
var span trace.Span
ctx, span = tracer.Start(ctx, "helloWorld")
defer span.End()
Expand Down Expand Up @@ -93,7 +93,7 @@ The metrics API is currently unstable, documentation TBA.

Traces can extend beyond a single process. This requires _context propagation_, a mechanism where identifiers for a trace are sent to remote processes.

In order to propagate trace context over the wire, a propagator must be registered with the OpenTelemetry SDK.
In order to propagate trace context over the wire, a propagator must be registered with the OpenTelemetry API.

```go
import (
Expand Down

0 comments on commit ca3bf47

Please sign in to comment.