1
- ![ OpenTelemetry — An observability framework for cloud-native software.] [ splash ]
2
-
3
- [ splash ] : https://raw.githubusercontent.com/open-telemetry/opentelemetry-rust/main/assets/logo-text.png
4
-
5
1
# OpenTelemetry Rust
6
2
7
- The Rust [ OpenTelemetry] ( https://opentelemetry.io/ ) implementation .
3
+ This crate contains the [ OpenTelemetry] ( https://opentelemetry.io/ ) API for Rust .
8
4
9
5
[ ![ Crates.io: opentelemetry] ( https://img.shields.io/crates/v/opentelemetry.svg )] ( https://crates.io/crates/opentelemetry )
10
6
[ ![ Documentation] ( https://docs.rs/opentelemetry/badge.svg )] ( https://docs.rs/opentelemetry )
@@ -15,124 +11,120 @@ The Rust [OpenTelemetry](https://opentelemetry.io/) implementation.
15
11
16
12
## Overview
17
13
18
- OpenTelemetry is a collection of tools, APIs, and SDKs used to instrument,
19
- generate, collect, and export telemetry data (metrics, logs, and traces) for
20
- analysis in order to understand your software's performance and behavior. You
21
- can export and analyze them using [ Prometheus] , [ Jaeger] , and other
22
- observability tools.
14
+ OpenTelemetry is an Observability framework and toolkit designed to create and
15
+ manage telemetry data such as traces, metrics, and logs. OpenTelemetry is
16
+ vendor- and tool-agnostic, meaning that it can be used with a broad variety of
17
+ Observability backends, including open source tools like [ Jaeger] and
18
+ [ Prometheus] , as well as commercial offerings.
19
+
20
+ OpenTelemetry is * not* an observability backend like Jaeger, Prometheus, or other
21
+ commercial vendors. OpenTelemetry is focused on the generation, collection,
22
+ management, and export of telemetry. A major goal of OpenTelemetry is that you
23
+ can easily instrument your applications or systems, no matter their language,
24
+ infrastructure, or runtime environment. Crucially, the storage and visualization
25
+ of telemetry is intentionally left to other tools.
23
26
24
27
* Compiler support: [ requires ` rustc ` 1.64+] [ msrv ] *
25
28
26
29
[ Prometheus ] : https://prometheus.io
27
30
[ Jaeger ] : https://www.jaegertracing.io
28
31
[ msrv ] : #supported-rust-versions
29
32
30
- ## Getting Started
31
-
32
- ``` rust
33
- use opentelemetry :: {
34
- global,
35
- sdk :: trace :: TracerProvider ,
36
- trace :: {Tracer , TracerProvider as _},
37
- };
38
-
39
- fn main () {
40
- // Create a new trace pipeline that prints to stdout
41
- let provider = TracerProvider :: builder ()
42
- . with_simple_exporter (opentelemetry_stdout :: SpanExporter :: default ())
43
- . build ();
44
- let tracer = provider . tracer (" readme_example" );
45
-
46
- tracer . in_span (" doing_work" , | cx | {
47
- // Traced app logic here...
48
- });
49
-
50
- // Shutdown trace pipeline
51
- global :: shutdown_tracer_provider ();
52
- }
53
- ```
54
-
55
- See the [ examples] ( ../examples ) directory for different integration patterns.
56
-
57
- ## Ecosystem
58
-
59
- ### Related Crates
60
-
61
- In addition to ` opentelemetry ` , which only carries the API, the
62
- [ ` open-telemetry/opentelemetry-rust ` ] repository contains several additional
63
- crates designed to be used with the ` opentelemetry ` ecosystem. This includes a
64
- collection of trace ` SpanExporter ` and metrics pull and push controller
65
- implementations, as well as utility and adapter crates to assist in propagating
66
- state and instrumenting applications.
67
-
68
- In particular, the following crates are likely to be of interest:
69
-
70
- - [ ` opentelemetry-aws ` ] provides unofficial propagators for AWS X-ray.
71
- - [ ` opentelemetry-contrib ` ] provides additional exporters and propagators that
72
- are experimental.
73
- - [ ` opentelemetry-datadog ` ] provides additional exporters to [ ` Datadog ` ] .
74
- - [ ` opentelemetry-dynatrace ` ] * Deprecated, last release 0.4.0* provides additional exporters to [ ` Dynatrace ` ] . See [ README] [ `opentelemetry-dynatrace-readme` ]
75
- - [ ` opentelemetry-http ` ] provides an interface for injecting and extracting
76
- trace information from [ ` http ` ] headers.
77
- - [ ` opentelemetry-jaeger ` ] provides a pipeline and exporter for sending trace
78
- information to [ ` Jaeger ` ] .
79
- - [ ` opentelemetry-otlp ` ] exporter for sending trace and metric data in the OTLP
80
- format to the OpenTelemetry collector.
81
- - [ ` opentelemetry-prometheus ` ] provides a pipeline and exporter for sending
82
- metrics information to [ ` Prometheus ` ] .
83
- - [ ` opentelemetry_sdk ` ] provides the standard reference implementation of
84
- opentelemetry.
85
- - [ ` opentelemetry-semantic-conventions ` ] provides standard names and semantic
86
- otel conventions.
87
- - [ ` opentelemetry-stackdriver ` ] provides an exporter for Google's [ Cloud Trace]
88
- (which used to be called StackDriver).
89
- - [ ` opentelemetry-zipkin ` ] provides a pipeline and exporter for sending trace
90
- information to [ ` Zipkin ` ] .
91
-
92
- Additionally, there are also several third-party crates which are not
93
- maintained by the ` opentelemetry ` project. These include:
94
-
95
- - [ ` tracing-opentelemetry ` ] provides integration for applications instrumented
96
- using the [ ` tracing ` ] API and ecosystem.
97
- - [ ` actix-web-opentelemetry ` ] provides integration for the [ ` actix-web ` ] web
98
- server and ecosystem.
99
- - [ ` opentelemetry-application-insights ` ] provides an unofficial [ Azure
100
- Application Insights] exporter.
101
- - [ ` opentelemetry-tide ` ] provides integration for the [ ` Tide ` ] web server and
102
- ecosystem.
103
-
104
- If you're the maintainer of an ` opentelemetry ` ecosystem crate not listed
105
- above, please let us know! We'd love to add your project to the list!
106
-
107
- [ `open-telemetry/opentelemetry-rust` ] : https://github.com/open-telemetry/opentelemetry-rust
108
- [ `opentelemetry-jaeger` ] : https://crates.io/crates/opentelemetry-jaeger
109
- [ `Jaeger` ] : https://www.jaegertracing.io
110
- [ `opentelemetry-otlp` ] : https://crates.io/crates/opentelemetry-otlp
111
- [ `opentelemetry-http` ] : https://crates.io/crates/opentelemetry-http
112
- [ `opentelemetry-prometheus` ] : https://crates.io/crates/opentelemetry-prometheus
113
- [ `opentelemetry-aws` ] : https://crates.io/crates/opentelemetry-aws
114
- [ `Prometheus` ] : https://prometheus.io
115
- [ `opentelemetry-zipkin` ] : https://crates.io/crates/opentelemetry-zipkin
116
- [ `Zipkin` ] : https://zipkin.io
117
- [ `opentelemetry-contrib` ] : https://crates.io/crates/opentelemetry-contrib
118
- [ `Datadog` ] : https://www.datadoghq.com
119
- [ `Dynatrace` ] : https://www.dynatrace.com
120
- [ `opentelemetry-datadog` ] : https://crates.io/crates/opentelemetry-datadog
121
- [ `opentelemetry-dynatrace` ] : https://crates.io/crates/opentelemetry-dynatrace
122
- [ `opentelemetry-dynatrace-readme` ] : https://github.com/open-telemetry/opentelemetry-rust-contrib/blob/main/opentelemetry-dynatrace/README.md
123
- [ `opentelemetry-semantic-conventions` ] : https://crates.io/crates/opentelemetry-semantic-conventions
124
- [ `http` ] : https://crates.io/crates/http
125
-
126
- [ `tracing-opentelemetry` ] : https://crates.io/crates/tracing-opentelemetry
127
- [ `tracing` ] : https://crates.io/crates/tracing
128
- [ `actix-web-opentelemetry` ] : https://crates.io/crates/actix-web-opentelemetry
129
- [ `actix-web` ] : https://crates.io/crates/actix-web
130
- [ `opentelemetry-application-insights` ] : https://crates.io/crates/opentelemetry-application-insights
131
- [ Azure Application Insights ] : https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview
132
- [ `opentelemetry-tide` ] : https://crates.io/crates/opentelemetry-tide
133
- [ `Tide` ] : https://crates.io/crates/tide
134
- [ `opentelemetry-stackdriver` ] : https://crates.io/crates/opentelemetry-stackdriver
135
- [ Cloud Trace ] : https://cloud.google.com/trace/
33
+ ### What does this crate contain?
34
+
35
+ This crate is basic foundation for integrating OpenTelemetry into libraries and
36
+ applications, encompassing several aspects of OpenTelemetry, such as context
37
+ management and propagation, baggage, logging, tracing, and metrics. It follows
38
+ the [ OpenTelemetry
39
+ specification] ( https://github.com/open-telemetry/opentelemetry-specification ) .
40
+ Here's a breakdown of its components:
41
+
42
+ - ** [ Context
43
+ API] ( https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/README.md ) :**
44
+ Provides a way to manage and propagate context, which is essential for keeping
45
+ track of trace execution across asynchronous tasks.
46
+ - ** [ Propagators
47
+ API] ( https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/api-propagators.md ) :**
48
+ Defines how context can be shared across process boundaries, ensuring
49
+ continuity across microservices or distributed systems.
50
+ - ** [ Baggage
51
+ API] ( https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/baggage/api.md ) :**
52
+ Allows for the attachment of metadata (baggage) to telemetry, which can be
53
+ used for sharing application-specific information across service boundaries.
54
+ - ** [ Logs Bridge
55
+ API] ( https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/bridge-api.md ) :**
56
+ Allows to bridge existing logging mechanisms with OpenTelemetry logging. This
57
+ is ** NOT** meant for end users to call, instead it is meant to enable writing
58
+ bridges/appenders for existing logging mechanisms such as
59
+ [ log] ( https://crates.io/crates/log ) or
60
+ [ tracing] ( https://crates.io/crates/tracing ) .
61
+ - ** [ Tracing
62
+ API] ( https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md ) :**
63
+ Offers a set of primitives to produce distributed traces to understand the
64
+ flow of a request across system boundaries.
65
+ - ** [ Metrics
66
+ API] ( https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md ) :**
67
+ Offers a set of primitives to produce measurements of operational metrics like
68
+ latency, throughput, or error rates.
69
+
70
+ This crate serves as a facade or no-op implementation, meaning it defines the
71
+ traits for instrumentation but does not itself implement the processing or
72
+ exporting of telemetry data. This separation of concerns allows library authors
73
+ to depend on the API crate without tying themselves to a specific
74
+ implementation.
75
+
76
+ Actual implementation and the heavy lifting of telemetry data collection,
77
+ processing, and exporting are delegated to the
78
+ [ opentelemetry-sdk] ( https://crates.io/crates/opentelemetry-sdk ) crate and
79
+ various exporter crates such as
80
+ [ opentelemetry-otlp] ( https://crates.io/crates/opentelemetry-otlp ) . This
81
+ architecture ensures that the final application can light up the instrumentation
82
+ by integrating an SDK implementation.
83
+
84
+ Library authors are recommended to depend on this crate * only* . This approach is
85
+ also aligned with the design philosophy of existing telemetry solutions in the
86
+ Rust ecosystem, like ` tracing ` or ` log ` , where these crates only offer a facade
87
+ and the actual functionality is enabled through additional crates.
88
+
89
+ ### Related crates
90
+
91
+ Unless you are a library author, you will almost always need to use additional
92
+ crates along with this. Given this crate has no-op implementation only, an
93
+ OpenTelemetry SDK is always required.
94
+ [ opentelemetry-sdk] ( https://crates.io/crates/opentelemetry-sdk ) is the official
95
+ SDK implemented by OpenTelemetry itself, though it is possible to use a
96
+ different sdk.
97
+
98
+ Additionally one or more exporters are also required to export telemetry to a
99
+ destination. OpenTelemetry provides the following exporters:
100
+
101
+ - ** [ opentelemetry-stdout] ( https://crates.io/crates/opentelemetry-stdout ) :**
102
+ Prints telemetry to stdout, primarily used for learning/debugging purposes.
103
+ - ** [ opentelemetry-otlp] ( https://crates.io/crates/opentelemetry-otlp ) :** Exports
104
+ telemetry (logs, metrics and traces) in the [ OTLP
105
+ format] ( https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/protocol )
106
+ to an endpoint accepting OTLP. This could be the [ OTel
107
+ Collector] ( https://github.com/open-telemetry/opentelemetry-collector ) ,
108
+ telemetry backends like [ Jaeger] ( https://www.jaegertracing.io/ ) ,
109
+ [ Prometheus] ( https://prometheus.io/docs/prometheus/latest/feature_flags/#otlp-receiver )
110
+ or [ vendor specific endpoints] ( https://opentelemetry.io/ecosystem/vendors/ ) .
111
+ - ** [ opentelemetry-zipkin] ( https://crates.io/crates/opentelemetry-zipkin ) :**
112
+ Exports telemetry (traces only) to Zipkin following [ OpenTelemetry to Zipkin
113
+ specification] ( https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk_exporters/zipkin.md )
114
+ - ** [ opentelemetry-prometheus] ( https://crates.io/crates/opentelemetry-prometheus ) :**
115
+ Exports telemetry (metrics only) to Prometheus following [ OpenTelemetry to
116
+ Prometheus
117
+ specification] ( https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/prometheus.md )
118
+
119
+ OpenTelemetry Rust also has a [ contrib
120
+ repo] ( https://github.com/open-telemetry/opentelemetry-rust-contrib ) , where
121
+ additional exporters could be found. Check [ OpenTelemetry
122
+ Registry] ( https://opentelemetry.io/ecosystem/registry/?language=rust ) for
123
+ additional exporters and other related components as well.
124
+
125
+ ## Getting started
126
+
127
+ See [ docs] ( https://docs.rs/opentelemetry ) .
136
128
137
129
## Supported Rust Versions
138
130
@@ -146,7 +138,3 @@ version is 1.49, the minimum supported version will not be increased past 1.46,
146
138
three minor versions prior. Increasing the minimum supported compiler version
147
139
is not considered a semver breaking change as long as doing so complies with
148
140
this policy.
149
-
150
- ## Contributing
151
-
152
- See the [ contributing file] ( ../CONTRIBUTING.md ) .
0 commit comments