1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-12 10:04:29 +02:00
opentelemetry-go/website_docs/exporting_data.md

65 lines
2.8 KiB
Markdown
Raw Normal View History

2021-04-01 18:36:51 +02:00
---
title: "Processing and Exporting Data"
weight: 4
---
Once you've instrumented your code, you need to get the data out in order to do anything useful with it. This page will cover the basics of the process and export pipeline.
# Sampling
Sampling is a process that restricts the amount of traces that are generated by a system. The exact sampler you should use depends on your specific needs, but in general you should make a decision at the start of a trace, and allow the sampling decision to propagate to other services.
A sampler needs to be set on the tracer provider when its configured, as follows:
```go
provider := sdktrace.NewTracerProvider(
sdktrace.WithSampler(sdktrace.AlwaysSample()),
2021-04-01 18:36:51 +02:00
)
```
`AlwaysSample` and `NeverSample` are fairly self-explanatory. Always means that every trace will be sampled, the converse holds as true for Never. When you're getting started, or in a development environment, you'll almost always want to use `AlwaysSample`.
Other samplers include:
* `TraceIDRatioBased`, which will sample a fraction of traces, based on the fraction given to the sampler. Thus, if you set this to .5, half of traces will be sampled.
* `ParentBased`, which behaves differently based on the incoming sampling decision. In general, this will sample spans that have parents that were sampled, and will not sample spans whose parents were _not_ sampled.
2021-05-25 21:20:45 +02:00
When you're in production, you should consider using the `TraceIDRatioBased` sampler with the `ParentBased` sampler.
2021-04-24 22:57:23 +02:00
2021-04-01 18:36:51 +02:00
# Resources
Resources are a special type of attribute that apply to all spans generated by a process. These should be used to represent underlying metadata about a process that's non-ephemeral - for example, the hostname of a process, or its instance ID.
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"),
2021-04-01 18:36:51 +02:00
)
provider := sdktrace.NewTracerProvider(
...
sdktrace.WithResources(resources),
2021-04-01 18:36:51 +02:00
)
```
# OTLP Exporter
OpenTelemetry Protocol (OTLP) is available in the `go.opentelemetry.io/otel/exporters/otlp` package.
Please find more documentation on [GitHub](https://github.com/open-telemetry/opentelemetry-go/tree/main/exporters/otlp)
# Jaeger Exporter
Jaeger export is available in the `go.opentelemetry.io/otel/exporters/jaeger` package.
2021-04-01 18:36:51 +02:00
Please find more documentation on [GitHub](https://github.com/open-telemetry/opentelemetry-go/tree/main/exporters/jaeger)
2021-04-01 18:36:51 +02:00
# Prometheus Exporter
Prometheus export is available in the `go.opentelemetry.io/otel/exporters/prometheus` package.
2021-04-01 18:36:51 +02:00
Please find more documentation on [GitHub](https://github.com/open-telemetry/opentelemetry-go/tree/main/exporters/prometheus)