1---
2title: "Processing and Exporting Data"
3weight: 4
4---
5
6Once 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.
7
8# Sampling
9
10Sampling 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.
11
12A sampler needs to be set on the tracer provider when its configured, as follows:
13
14```go
15provider := sdktrace.NewTracerProvider(
16  sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}),
17)
18```
19
20`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`.
21
22Other samplers include:
23
24* `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.
25* `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.
26
27# Resources
28
29Resources 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.
30
31Resources should be assigned to a tracer provider at its initialization, and are created much like attributes:
32
33```go
34resources := resource.New(
35  label.String("service.name", "myService"),
36  label.String("service.version", "1.0.0"),
37  label.String("instance.id", "abcdef12345"),
38)
39
40provider := sdktrace.NewTracerProvider(
41  ...
42  sdktrace.WithResources(resources),
43)
44```
45
46# OTLP Exporter
47
48OpenTelemetry Protocol (OTLP) is available in the `go.opentelemetry.io/otel/exporters/otlp` package.
49
50Please find more documentation on [GitHub](https://github.com/open-telemetry/opentelemetry-go/tree/main/exporters/otlp)
51
52# Jaeger Exporter
53
54Jaeger export is available in the `go.opentelemetry.io/otel/exporters/trace/jaeger` package.
55
56Please find more documentation on [GitHub](https://github.com/open-telemetry/opentelemetry-go/tree/main/exporters/trace/jaeger)
57
58# Prometheus Exporter
59
60Prometheus export is available in the `go.opentelemetry.io/otel/exporters/metric/prometheus` package.
61
62Please find more documentation on [GitHub](https://github.com/open-telemetry/opentelemetry-go/tree/main/exporters/metric/prometheus)
63