Skip to content

Commit

Permalink
chore(examples/web): modernize the docker compose & collector setup f…
Browse files Browse the repository at this point in the history
…or this example

Also add some more notes to README to show the steps to get some traces
and view them.
  • Loading branch information
trentm committed Nov 26, 2024
1 parent 6ee7e7f commit 031b1fd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions examples/web/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
14 changes: 13 additions & 1 deletion examples/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,26 @@ This example shows how to use [@opentelemetry/sdk-trace-web][] with different in
npm install
```

## Start a collector and trace viewer

Optionally, you can use the provided Docker Compose file to start an OpenTelemetry Collector and a Zipkin to view collected traces.
You can skip this step if you have your own collector already setup.

```sh
npm run docker:start
```

## Run the Application

```sh
# from this directory
npm start
```

By default, the application will run on port `8090`.
- Open the application at <http://localhost:8090>.
- Click around in each of the example sub-paths to create some tracing data.
- Open Zipkin at <http://127.0.0.1:9411/zipkin/> and search for some traces (click "Run Query").


## More information

Expand Down
7 changes: 4 additions & 3 deletions examples/web/docker/collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ receivers:
protocols:
grpc:
http:
cors_allowed_origins:
- http://*
- https://*
cors:
allowed_origins:
- http://*
- https://*

exporters:
zipkin:
Expand Down
5 changes: 1 addition & 4 deletions examples/web/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
version: "3"
services:
# Collector
collector:
image: otel/opentelemetry-collector:0.38.0
image: otel/opentelemetry-collector:0.99.0
command: ["--config=/conf/collector-config.yaml"]
volumes:
- ./collector-config.yaml:/conf/collector-config.yaml
Expand All @@ -13,7 +11,6 @@ services:
depends_on:
- zipkin-all-in-one

# Zipkin
zipkin-all-in-one:
image: openzipkin/zipkin:latest
ports:
Expand Down
4 changes: 2 additions & 2 deletions examples/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"description": "Example of using web plugins in browser",
"main": "index.js",
"scripts": {
"docker:start": "cd ./docker && docker-compose down && docker-compose up",
"docker:startd": "cd ./docker && docker-compose down && docker-compose up -d",
"docker:start": "cd ./docker && docker compose down && docker compose up",
"docker:startd": "cd ./docker && docker compose down && docker compose up -d",
"start": "webpack-dev-server --progress --color --port 8090 --config ./webpack.config.js --hot --host 0.0.0.0"
},
"repository": {
Expand Down

0 comments on commit 031b1fd

Please sign in to comment.