diff --git a/examples/language-sdk-instrumentation/golang-push/rideshare-k6/README.md b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/README.md index cf32412f7d..a461bb21f1 100644 --- a/examples/language-sdk-instrumentation/golang-push/rideshare-k6/README.md +++ b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/README.md @@ -29,3 +29,6 @@ test against the Rideshare service. ``` k6 run load.js ``` + +Finally, navigate to http://localhost:3000 and open the Explore Profiles app. After a small delay, k6 test metadata should begin to appears as labels on the +"ride-sharing-app" application tile. diff --git a/examples/language-sdk-instrumentation/golang-push/rideshare-k6/docker-compose.yml b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/docker-compose.yml index fb387b7802..3c28cff835 100644 --- a/examples/language-sdk-instrumentation/golang-push/rideshare-k6/docker-compose.yml +++ b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/docker-compose.yml @@ -41,6 +41,11 @@ services: image: grafana/pyroscope:latest ports: - 4040:4040 + volumes: + - ./grafana-provisioning/pyroscope:/etc/pyroscope + command: + - -config.file + - /etc/pyroscope/config.yml load-generator: build: diff --git a/examples/language-sdk-instrumentation/golang-push/rideshare-k6/go.mod b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/go.mod index 3a703530da..c8097575fe 100644 --- a/examples/language-sdk-instrumentation/golang-push/rideshare-k6/go.mod +++ b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/go.mod @@ -6,7 +6,7 @@ require ( github.com/agoda-com/opentelemetry-logs-go v0.4.1 github.com/grafana/otel-profiling-go v0.5.1 github.com/grafana/pyroscope-go v1.1.1 - github.com/grafana/pyroscope-go/x/k6 v0.0.0-20241003203156-a917cea171d3 + github.com/grafana/pyroscope-go/x/k6 v0.0.0-20241129154546-3e89ad952d8f go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 go.opentelemetry.io/otel v1.22.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0 diff --git a/examples/language-sdk-instrumentation/golang-push/rideshare-k6/go.sum b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/go.sum index dbc84ab586..2d83bfb1be 100644 --- a/examples/language-sdk-instrumentation/golang-push/rideshare-k6/go.sum +++ b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/go.sum @@ -26,8 +26,8 @@ github.com/grafana/pyroscope-go v1.1.1 h1:PQoUU9oWtO3ve/fgIiklYuGilvsm8qaGhlY4Vw github.com/grafana/pyroscope-go v1.1.1/go.mod h1:Mw26jU7jsL/KStNSGGuuVYdUq7Qghem5P8aXYXSXG88= github.com/grafana/pyroscope-go/godeltaprof v0.1.8 h1:iwOtYXeeVSAeYefJNaxDytgjKtUuKQbJqgAIjlnicKg= github.com/grafana/pyroscope-go/godeltaprof v0.1.8/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU= -github.com/grafana/pyroscope-go/x/k6 v0.0.0-20241003203156-a917cea171d3 h1:GtwQDlBz8aJHMy2Ko28UDRGgGzi7v4Vf20+ZyXaGy7M= -github.com/grafana/pyroscope-go/x/k6 v0.0.0-20241003203156-a917cea171d3/go.mod h1:nfbW6/4ke3ywlqLb+Zgr9t1z9Zv3m+2ImUp+vbkzHpc= +github.com/grafana/pyroscope-go/x/k6 v0.0.0-20241129154546-3e89ad952d8f h1:5v8jrCB7XCFPo4tXxqHyYbJfuRxTdCtkWYwGW54qpfM= +github.com/grafana/pyroscope-go/x/k6 v0.0.0-20241129154546-3e89ad952d8f/go.mod h1:nfbW6/4ke3ywlqLb+Zgr9t1z9Zv3m+2ImUp+vbkzHpc= github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 h1:6UKoz5ujsI55KNpsJH3UwCq3T8kKbZwNZBNPuTTje8U= github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1/go.mod h1:YvJ2f6MplWDhfxiUC3KpyTy76kYUZA4W3pTv/wdKQ9Y= github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= diff --git a/examples/language-sdk-instrumentation/golang-push/rideshare-k6/grafana-provisioning/pyroscope/config.yml b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/grafana-provisioning/pyroscope/config.yml new file mode 100644 index 0000000000..257748221e --- /dev/null +++ b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/grafana-provisioning/pyroscope/config.yml @@ -0,0 +1,2 @@ +self_profiling: + use_k6_middleware: true diff --git a/examples/language-sdk-instrumentation/golang-push/rideshare-k6/load.js b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/load.js index 6553e9dc7a..7d993d13b2 100644 --- a/examples/language-sdk-instrumentation/golang-push/rideshare-k6/load.js +++ b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/load.js @@ -1,6 +1,6 @@ import http from 'k6/http'; import { check } from 'k6'; -import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/1.0.0/index.js'; +import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/1.0.1/index.js'; pyroscope.instrumentHTTP(); diff --git a/examples/language-sdk-instrumentation/golang-push/rideshare-k6/main.go b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/main.go index e77afe055d..a44756b060 100644 --- a/examples/language-sdk-instrumentation/golang-push/rideshare-k6/main.go +++ b/examples/language-sdk-instrumentation/golang-push/rideshare-k6/main.go @@ -127,8 +127,8 @@ func registerRoutes(mux *http.ServeMux, handlers []route) { } func applyOtelMiddleware(routes []route) []route { - for _, route := range routes { - route.Handler = otelhttp.NewHandler(route.Handler, route.Name) + for i, route := range routes { + routes[i].Handler = otelhttp.NewHandler(route.Handler, route.Name) } return routes } @@ -136,8 +136,8 @@ func applyOtelMiddleware(routes []route) []route { // applyK6Middleware adds the k6 instrumentation middleware to all routes. This // enables the Pyroscope SDK to label the profiles with k6 test metadata. func applyK6Middleware(routes []route) []route { - for _, route := range routes { - route.Handler = k6.LabelsFromBaggageHandler(route.Handler) + for i, route := range routes { + routes[i].Handler = k6.LabelsFromBaggageHandler(route.Handler) } return routes }