Skip to content

Commit

Permalink
shippingservice: add http client request span (#610)
Browse files Browse the repository at this point in the history
* shippingservice: Add http client request span

The commit adds new http client span for outgoing calls to `/getquote`
endpoint of quoteservice via the `reqwests` client middleware instrumentation.
This provides a bit of the server/client tasks separation visibility
as well as enables span pairing with the downstream quoteservice server span.
The instrumentation uses the available `reqwests-tracing` and `tracing-opentelementry` crates.

* update shippingservice docs

* update changelog

* update doc section position

* apply syntax change suggestion

Co-authored-by: Juliano Costa <julianocosta89@outlook.com>
  • Loading branch information
styblope and julianocosta89 committed Dec 5, 2022
1 parent 90cfc97 commit 48892f5
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 32 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,5 @@ significant modifications will be credited to OpenTelemetry Authors.
([#587](https://github.com/open-telemetry/opentelemetry-demo/pull/587))
* Pass product's `categories` as an input for the Ad service
([#600](https://github.com/open-telemetry/opentelemetry-demo/pull/600))
* Add HTTP client instrumentation to shippingservice
([#610](https://github.com/open-telemetry/opentelemetry-demo/pull/610))
17 changes: 16 additions & 1 deletion docs/services/shippingservice.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Be mindful of async runtime, [context
guards](https://docs.rs/opentelemetry/latest/opentelemetry/struct.ContextGuard.html),
and inability to move and clone `spans` when replicating from these samples.

### Adding gRPC/HTTP instrumentation
### Adding gRPC instrumentation

This service receives gRPC requests, which are instrumented in the middleware.

Expand Down Expand Up @@ -107,6 +107,21 @@ You may also notice the `attributes` set on the span in this example, and
context) the [OpenTelemetry API](https://docs.rs/opentelemetry/0.17.0/opentelemetry/trace/struct.SpanRef.html)
will work.

### Adding HTTP instrumentation

A child *client* span is also produced for the outoing HTTP call to
`quoteservice` via the `reqwest` client. This span pairs up with the
corresponding `quoteservice` *server* span. The tracing instrumentation is
implemented in the client middleware making use of the available
`reqwest-middleware`, `reqwest-tracing` and `tracing-opentelementry` libraries:

```rust
let reqwest_client = reqwest::Client::new();
let client = ClientBuilder::new(reqwest_client)
.with(TracingMiddleware::<SpanBackendWithUrl>::new())
.build();
```

### Add span attributes

Provided you are on the same thread, or in a context passed from a
Expand Down
Loading

0 comments on commit 48892f5

Please sign in to comment.