-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate examples and redirect to contrib (#5854)
Towards #5801
- Loading branch information
Showing
43 changed files
with
36 additions
and
1,807 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,4 @@ | ||
// Deprecated: Examples are moved to https://github.com/open-telemetry/opentelemetry-go-contrib. | ||
module go.opentelemetry.io/otel/example/dice | ||
|
||
go 1.22 | ||
|
||
require ( | ||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 | ||
go.opentelemetry.io/otel v1.30.0 | ||
go.opentelemetry.io/otel/exporters/stdout/stdoutlog v0.6.0 | ||
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.30.0 | ||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.30.0 | ||
go.opentelemetry.io/otel/log v0.6.0 | ||
go.opentelemetry.io/otel/metric v1.30.0 | ||
go.opentelemetry.io/otel/sdk v1.30.0 | ||
go.opentelemetry.io/otel/sdk/log v0.6.0 | ||
go.opentelemetry.io/otel/sdk/metric v1.30.0 | ||
) | ||
|
||
require ( | ||
github.com/felixge/httpsnoop v1.0.4 // indirect | ||
github.com/go-logr/logr v1.4.2 // indirect | ||
github.com/go-logr/stdr v1.2.2 // indirect | ||
github.com/google/uuid v1.6.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.30.0 // indirect | ||
golang.org/x/sys v0.25.0 // indirect | ||
) | ||
|
||
replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../exporters/stdout/stdouttrace | ||
|
||
replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../exporters/stdout/stdoutmetric | ||
|
||
replace go.opentelemetry.io/otel => ../.. | ||
|
||
replace go.opentelemetry.io/otel/trace => ../../trace | ||
|
||
replace go.opentelemetry.io/otel/metric => ../../metric | ||
|
||
replace go.opentelemetry.io/otel/sdk/metric => ../../sdk/metric | ||
|
||
replace go.opentelemetry.io/otel/sdk => ../../sdk | ||
|
||
replace go.opentelemetry.io/otel/exporters/stdout/stdoutlog => ../../exporters/stdout/stdoutlog | ||
|
||
replace go.opentelemetry.io/otel/log => ../../log | ||
|
||
replace go.opentelemetry.io/otel/sdk/log => ../../sdk/log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +0,0 @@ | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= | ||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= | ||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= | ||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= | ||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= | ||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= | ||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | ||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= | ||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= | ||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | ||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 h1:ZIg3ZT/aQ7AfKqdwp7ECpOK6vHqquXXuyTjIO8ZdmPs= | ||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0/go.mod h1:DQAwmETtZV00skUwgD6+0U89g80NKsJE3DCKeLLPQMI= | ||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= | ||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,10 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Dice is the "Roll the dice" application. | ||
// | ||
// Deprecated: Examples are moved to https://github.com/open-telemetry/opentelemetry-go-contrib. | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"log" | ||
"net" | ||
"net/http" | ||
"os" | ||
"os/signal" | ||
"time" | ||
|
||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" | ||
) | ||
|
||
func main() { | ||
if err := run(); err != nil { | ||
log.Fatalln(err) | ||
} | ||
} | ||
|
||
func run() (err error) { | ||
// Handle SIGINT (CTRL+C) gracefully. | ||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) | ||
defer stop() | ||
|
||
// Set up OpenTelemetry. | ||
otelShutdown, err := setupOTelSDK(ctx) | ||
if err != nil { | ||
return | ||
} | ||
// Handle shutdown properly so nothing leaks. | ||
defer func() { | ||
err = errors.Join(err, otelShutdown(context.Background())) | ||
}() | ||
|
||
// Start HTTP server. | ||
srv := &http.Server{ | ||
Addr: ":8080", | ||
BaseContext: func(_ net.Listener) context.Context { return ctx }, | ||
ReadTimeout: time.Second, | ||
WriteTimeout: 10 * time.Second, | ||
Handler: newHTTPHandler(), | ||
} | ||
srvErr := make(chan error, 1) | ||
go func() { | ||
srvErr <- srv.ListenAndServe() | ||
}() | ||
|
||
// Wait for interruption. | ||
select { | ||
case err = <-srvErr: | ||
// Error when starting HTTP server. | ||
return | ||
case <-ctx.Done(): | ||
// Wait for first CTRL+C. | ||
// Stop receiving signal notifications as soon as possible. | ||
stop() | ||
} | ||
|
||
// When Shutdown is called, ListenAndServe immediately returns ErrServerClosed. | ||
err = srv.Shutdown(context.Background()) | ||
return | ||
} | ||
|
||
func newHTTPHandler() http.Handler { | ||
mux := http.NewServeMux() | ||
|
||
// handleFunc is a replacement for mux.HandleFunc | ||
// which enriches the handler's HTTP instrumentation with the pattern as the http.route. | ||
handleFunc := func(pattern string, handlerFunc func(http.ResponseWriter, *http.Request)) { | ||
// Configure the "http.route" for the HTTP instrumentation. | ||
handler := otelhttp.WithRouteTag(pattern, http.HandlerFunc(handlerFunc)) | ||
mux.Handle(pattern, handler) | ||
} | ||
|
||
// Register handlers. | ||
handleFunc("/rolldice/", rolldice) | ||
handleFunc("/rolldice/{player}", rolldice) | ||
|
||
// Add HTTP instrumentation for the whole server. | ||
handler := otelhttp.NewHandler(mux, "/") | ||
return handler | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.