Skip to content

Commit

Permalink
docs(mockotlpserver): some light doc improvements now that we have a …
Browse files Browse the repository at this point in the history
…Docker image (#495)
  • Loading branch information
trentm authored Dec 19, 2024
1 parent 9d29836 commit 8fddaf7
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions packages/mockotlpserver/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
A mock OTLP server/receiver for development.
# @elastic/mockotlpserver

`mockotlpserver` starts HTTP and gRPC servers (on the default ports) for
A mock OTLP (OpenTelemetry Protocol) server/receiver for development and testing.

`mockotlpserver` starts HTTP and gRPC servers (on the default OTLP ports) for
receiving OTLP requests. The data in those requests are printed to the
console. Various output formats are supported.

Expand All @@ -12,22 +14,26 @@ It also supports being run from Node.js code. This is used in the
3. get the received OTLP data from the mock server and make assertions on that data.


# Install
# CLI Usage

To use the mock server, first **start the server**. You can start it via `npx`,
if you use that:

```
npm install @elastic/mockotlpserver
npx @elastic/mockotlpserver
```

# CLI Usage

To use the mock server, (a) start the server then (b) send OTLP data to it.
The package installs a `mockotlpserver` CLI tool.
or via the published `ghcr.io/elastic/elastic-otel-node/mockotlpserver` Docker image:

```
npx mockotlpserver
docker run --rm -it -p 4317:4317 -p 4318:4318 --name mockotlpserver \
ghcr.io/elastic/elastic-otel-node/mockotlpserver:latest
```

By default it will output received OTLP data in two forms:
Then, **send OTLP data to it**.


By default, mockotlpserver will output received OTLP data in two forms:

1. `inspect` format: Uses Node.js's `util.inspect()` (used under the hood for
`console.log`). This shows the complete object structure of the received
Expand Down Expand Up @@ -57,7 +63,6 @@ node -r @elastic/opentelemetry-node simple-http-request.js
% node lib/cli.js
{"name":"mockotlpserver","level":30,"msg":"OTLP/HTTP listening at http://[::1]:4318/","time":"2024-01-11T22:18:49.017Z"}
{"name":"mockotlpserver","level":30,"msg":"OTLP/HTTP listening at http://localhost:4317/","time":"2024-01-11T22:18:49.025Z"}
{"name":"mockotlpserver","level":30,"msg":"UI listening at http://[::1]:8080/","time":"2024-01-11T22:18:49.026Z"}
ExportTraceServiceRequest {
resourceSpans: [
ResourceSpans {
Expand Down

0 comments on commit 8fddaf7

Please sign in to comment.