Skip to content

Commit

Permalink
Merge branch 'main' into appender-tracing-fix-trace-context
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Jan 21, 2025
2 parents 3146dfb + 68af3bb commit f7f2e16
Show file tree
Hide file tree
Showing 26 changed files with 478 additions and 274 deletions.
3 changes: 3 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@
"reqwest",
"runtimes",
"rustc",
"serde",
"shoppingcart",
"struct",
"Tescher",
"testcontainers",
"testresults",
"thiserror",
"tracerprovider",
"updown",
"Zhongyang",
Expand Down
5 changes: 4 additions & 1 deletion opentelemetry-otlp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
- Feature flag "populate-logs-event-name" is removed as no longer relevant.
LogRecord's `event_name()` is now automatically populated on the newly added
"event_name" field in LogRecord proto definition.

- Remove "grpc-tonic" feature from default, and instead add "http-proto" and
"reqwest-blocking-client" features as default, to align with the
specification.
[2516](https://github.com/open-telemetry/opentelemetry-rust/pull/2516)

## 0.27.0

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal-logs = ["tracing", "opentelemetry/internal-logs"]
# add ons
serialize = ["serde", "serde_json"]

default = ["grpc-tonic", "trace", "metrics", "logs", "internal-logs"]
default = ["http-proto", "reqwest-blocking-client", "trace", "metrics", "logs", "internal-logs"]

# grpc using tonic
grpc-tonic = ["tonic", "prost", "http", "tokio", "opentelemetry-proto/gen-tonic"]
Expand Down
5 changes: 2 additions & 3 deletions opentelemetry-otlp/examples/basic-otlp-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ publish = false
[features]
default = ["reqwest-blocking"]
reqwest-blocking = ["opentelemetry-otlp/reqwest-blocking-client"]
hyper = ["opentelemetry-otlp/hyper-client"]

[dependencies]
once_cell = { workspace = true }
opentelemetry = { path = "../../../opentelemetry" }
opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-tokio", "experimental_metrics_periodicreader_with_async_runtime"]}
opentelemetry-otlp = { path = "../..", features = ["http-proto", "http-json", "logs", "internal-logs"] , default-features = false}
opentelemetry_sdk = { path = "../../../opentelemetry-sdk" }
opentelemetry-otlp = { path = "../..", features = ["http-proto", "http-json", "logs", "internal-logs"], default-features = false}
opentelemetry-appender-tracing = { path = "../../../opentelemetry-appender-tracing", default-features = false}

tokio = { workspace = true, features = ["full"] }
Expand Down
6 changes: 0 additions & 6 deletions opentelemetry-otlp/examples/basic-otlp-http/Dockerfile

This file was deleted.

37 changes: 6 additions & 31 deletions opentelemetry-otlp/examples/basic-otlp-http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,25 @@ recommended approach when using OTLP exporters. While it can be modified to use
a `SimpleExporter`, this requires making the main function a regular main and
*not* tokio main.

// TODO: Document `hyper` feature flag when using SimpleProcessor.
// TODO: Document how to use hyper client.

## Usage

### `docker-compose`

By default runs against the `otel/opentelemetry-collector:latest` image, and uses `reqwest-client`
as the http client, using http as the transport.

```shell
docker-compose up
```

In another terminal run the application `cargo run`

The docker-compose terminal will display logs, traces, metrics.

Press Ctrl+C to stop the collector, and then tear it down:

```shell
docker-compose down
```

### Manual

If you don't want to use `docker-compose`, you can manually run the `otel/opentelemetry-collector` container
and inspect the logs to see traces being transferred.
Run the `otel/opentelemetry-collector` container using docker
and inspect the logs to see the exported telemetry.

On Unix based systems use:

```shell
# From the current directory, run `opentelemetry-collector`
docker run --rm -it -p 4318:4318 -v $(pwd):/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
docker run --rm -it -p 4317:4317 -p 4318:4318 -v $(pwd):/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
```

On Windows use:

```shell
# From the current directory, run `opentelemetry-collector`
docker run --rm -it -p 4318:4318 -v "%cd%":/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
docker run --rm -it -p 4317:4317 -p 4318:4318 -v "%cd%":/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
```

Run the app which exports logs, metrics and traces via OTLP to the collector
Expand All @@ -64,11 +43,7 @@ Run the app which exports logs, metrics and traces via OTLP to the collector
cargo run
```

By default the app will use a `reqwest` client to send. A hyper 0.14 client can be used with the `hyper` feature enabled

```shell
cargo run --no-default-features --features=hyper
```
The app will use a `reqwest-blocking` client to send.

## View results

Expand Down
15 changes: 0 additions & 15 deletions opentelemetry-otlp/examples/basic-otlp-http/docker-compose.yaml

This file was deleted.

5 changes: 2 additions & 3 deletions opentelemetry-otlp/examples/basic-otlp-http/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ fn init_metrics() -> Result<opentelemetry_sdk::metrics::SdkMeterProvider, Metric
.build())
}

// #[tokio::main]
// TODO: Re-enable tokio::main, if needed, after
fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
let logger_provider = init_logs()?;

// Create a new OpenTelemetryTracingBridge using the above LoggerProvider.
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/examples/basic-otlp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ publish = false
[dependencies]
once_cell = { workspace = true }
opentelemetry = { path = "../../../opentelemetry" }
opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-tokio"] }
opentelemetry-otlp = { path = "../../../opentelemetry-otlp" }
opentelemetry_sdk = { path = "../../../opentelemetry-sdk" }
opentelemetry-otlp = { path = "../../../opentelemetry-otlp", features = ["grpc-tonic"] }
tokio = { version = "1.0", features = ["full"] }
opentelemetry-appender-tracing = { path = "../../../opentelemetry-appender-tracing", default-features = false}
tracing = { workspace = true, features = ["std"]}
Expand Down
6 changes: 0 additions & 6 deletions opentelemetry-otlp/examples/basic-otlp/Dockerfile

This file was deleted.

29 changes: 4 additions & 25 deletions opentelemetry-otlp/examples/basic-otlp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,42 +49,21 @@ fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {

## Usage

### `docker-compose`

By default runs against the `otel/opentelemetry-collector:latest` image, and uses the `tonic`'s
`grpc` example as the transport.

```shell
docker-compose up
```

In another terminal run the application `cargo run`

The docker-compose terminal will display logs, traces, metrics.

Press Ctrl+C to stop the collector, and then tear it down:

```shell
docker-compose down
```

### Manual

If you don't want to use `docker-compose`, you can manually run the `otel/opentelemetry-collector` container
and inspect the logs to see traces being transferred.
Run the `otel/opentelemetry-collector` container using docker
and inspect the logs to see the exported telemetry.

On Unix based systems use:

```shell
# From the current directory, run `opentelemetry-collector`
docker run --rm -it -p 4317:4317 -v $(pwd):/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
docker run --rm -it -p 4317:4317 -p 4318:4318 -v $(pwd):/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
```

On Windows use:

```shell
# From the current directory, run `opentelemetry-collector`
docker run --rm -it -p 4317:4317 -v "%cd%":/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
docker run --rm -it -p 4317:4317 -p 4318:4318 -v "%cd%":/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
```

Run the app which exports logs, metrics and traces via OTLP to the collector
Expand Down
15 changes: 0 additions & 15 deletions opentelemetry-otlp/examples/basic-otlp/docker-compose.yaml

This file was deleted.

1 change: 1 addition & 0 deletions opentelemetry-otlp/tests/integration_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ testcontainers = { version = "0.23.1", features = ["http_wait"]}
once_cell.workspace = true
anyhow = "1.0.94"
ctor = "0.2.9"
uuid = { version = "1.3", features = ["v4"] }
tracing-subscriber = { workspace = true, features = ["env-filter","registry", "std", "fmt"] }
tracing = {workspace = true}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn init_tracing() {
// Initialize the tracing subscriber with the OpenTelemetry layer and the
// Fmt layer.
tracing_subscriber::registry().with(fmt_layer).init();
otel_info!(name: "tracing initializing completed!");
otel_info!(name: "tracing::fmt initializing completed! SDK internal logs will be printed to stdout.");
});
}

Expand Down
Loading

0 comments on commit f7f2e16

Please sign in to comment.