From 6f9ad5319dd0afc502b09e04cf8b9f7ae6f16cd2 Mon Sep 17 00:00:00 2001 From: Igor Eulalio Date: Fri, 22 Nov 2024 13:36:51 -0300 Subject: [PATCH] chore: add detailed information about dice example, add source for all shell scripts from docs Signed-off-by: Igor Eulalio --- examples/dice/README.md | 4 +++- examples/dice/instrumented/.tool-versions | 1 + examples/dice/instrumented/get.sh | 17 +++++++++++++++++ examples/dice/instrumented/init.sh | 6 ++++++ examples/dice/instrumented/run.sh | 8 ++++++++ examples/dice/instrumented/tidy.sh | 6 ++++++ examples/dice/run.sh | 9 +++------ examples/dice/uninstrumented/run.sh | 6 ++++++ 8 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 examples/dice/instrumented/.tool-versions create mode 100755 examples/dice/instrumented/get.sh create mode 100755 examples/dice/instrumented/init.sh create mode 100755 examples/dice/instrumented/run.sh create mode 100755 examples/dice/instrumented/tidy.sh create mode 100755 examples/dice/uninstrumented/run.sh diff --git a/examples/dice/README.md b/examples/dice/README.md index 698e305d2ce..7540f3b8007 100644 --- a/examples/dice/README.md +++ b/examples/dice/README.md @@ -1,6 +1,8 @@ # Dice example -Instructions on how to run instrumented and uninstrumented examples. +This is the foundation example for [Getting Started](https://opentelemetry.io/docs/languages/go/getting-started/) with OpenTelemetry. + +Below, you will see instructions on how to run this application, either with or without instrumentation. ## Usage diff --git a/examples/dice/instrumented/.tool-versions b/examples/dice/instrumented/.tool-versions new file mode 100644 index 00000000000..f5264425ddd --- /dev/null +++ b/examples/dice/instrumented/.tool-versions @@ -0,0 +1 @@ +golang 1.22.0 diff --git a/examples/dice/instrumented/get.sh b/examples/dice/instrumented/get.sh new file mode 100755 index 00000000000..1dad879f7ed --- /dev/null +++ b/examples/dice/instrumented/get.sh @@ -0,0 +1,17 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +#!/bin/bash + +go get "go.opentelemetry.io/otel" \ + "go.opentelemetry.io/otel/exporters/stdout/stdoutmetric" \ + "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" \ + "go.opentelemetry.io/otel/exporters/stdout/stdoutlog" \ + "go.opentelemetry.io/otel/sdk/log" \ + "go.opentelemetry.io/otel/log/global" \ + "go.opentelemetry.io/otel/propagation" \ + "go.opentelemetry.io/otel/sdk/metric" \ + "go.opentelemetry.io/otel/sdk/resource" \ + "go.opentelemetry.io/otel/sdk/trace" \ + "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"\ + "go.opentelemetry.io/contrib/bridges/otelslog" \ No newline at end of file diff --git a/examples/dice/instrumented/init.sh b/examples/dice/instrumented/init.sh new file mode 100755 index 00000000000..2aa81adbbcf --- /dev/null +++ b/examples/dice/instrumented/init.sh @@ -0,0 +1,6 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +#!/bin/bash + +module go.opentelemetry.io/contrib/examples/dice/instrumented \ No newline at end of file diff --git a/examples/dice/instrumented/run.sh b/examples/dice/instrumented/run.sh new file mode 100755 index 00000000000..8477cd4bd19 --- /dev/null +++ b/examples/dice/instrumented/run.sh @@ -0,0 +1,8 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +#!/bin/bash + +go mod tidy +export OTEL_RESOURCE_ATTRIBUTES="service.name=dice,service.version=0.1.0" +go run . \ No newline at end of file diff --git a/examples/dice/instrumented/tidy.sh b/examples/dice/instrumented/tidy.sh new file mode 100755 index 00000000000..26beb7b358c --- /dev/null +++ b/examples/dice/instrumented/tidy.sh @@ -0,0 +1,6 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +#!/bin/bash + +go mod tidy \ No newline at end of file diff --git a/examples/dice/run.sh b/examples/dice/run.sh index 2d13f5f52a6..27cf0af192b 100755 --- a/examples/dice/run.sh +++ b/examples/dice/run.sh @@ -14,17 +14,14 @@ case "$1" in instrumented) echo "Running instrumented example..." cd instrumented || exit - go mod tidy + source tidy.sh go mod download - export OTEL_RESOURCE_ATTRIBUTES="service.name=dice,service.version=0.1.0" - go run . + source run.sh ;; uninstrumented) echo "Running uninstrumented example..." cd uninstrumented || exit - go mod tidy - go mod download - go run . + source run.sh ;; *) echo "Invalid argument: $1. Use 'instrumented' or 'uninstrumented'." diff --git a/examples/dice/uninstrumented/run.sh b/examples/dice/uninstrumented/run.sh new file mode 100755 index 00000000000..aeb8a8031ff --- /dev/null +++ b/examples/dice/uninstrumented/run.sh @@ -0,0 +1,6 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +#!/bin/bash + +go run . \ No newline at end of file