Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example/dice: Do not use semconv #4849

Merged
merged 6 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion example/dice/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Dice is the "Roll the dice" getting started example application.
// Dice is the "Roll the dice" application.
//
// [Getting Started] uses this example to demonstrate OpenTelemetry Go.
//
// [Getting Started]: https://opentelemetry.io/docs/languages/net/automatic/getting-started/
package main
4 changes: 1 addition & 3 deletions example/dice/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ func run() (err error) {
defer stop()

// Set up OpenTelemetry.
serviceName := "dice"
serviceVersion := "0.1.0"
otelShutdown, err := setupOTelSDK(ctx, serviceName, serviceVersion)
otelShutdown, err := setupOTelSDK(ctx)
if err != nil {
return
}
Expand Down
17 changes: 4 additions & 13 deletions example/dice/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ import (
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/resource"
"go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
)

// setupOTelSDK bootstraps the OpenTelemetry pipeline.
// If it does not return an error, make sure to call shutdown for proper cleanup.
func setupOTelSDK(ctx context.Context, serviceName, serviceVersion string) (shutdown func(context.Context) error, err error) {
func setupOTelSDK(ctx context.Context) (shutdown func(context.Context) error, err error) {
var shutdownFuncs []func(context.Context) error

// shutdown calls cleanup functions registered via shutdownFuncs.
Expand All @@ -52,11 +51,7 @@ func setupOTelSDK(ctx context.Context, serviceName, serviceVersion string) (shut
}

// Set up resource.
res, err := newResource(serviceName, serviceVersion)
if err != nil {
handleErr(err)
return
}
res := newResource()

// Set up propagator.
prop := newPropagator()
Expand All @@ -83,12 +78,8 @@ func setupOTelSDK(ctx context.Context, serviceName, serviceVersion string) (shut
return
}

func newResource(serviceName, serviceVersion string) (*resource.Resource, error) {
return resource.Merge(resource.Default(),
resource.NewWithAttributes(semconv.SchemaURL,
semconv.ServiceName(serviceName),
semconv.ServiceVersion(serviceVersion),
))
func newResource() *resource.Resource {
pellared marked this conversation as resolved.
Show resolved Hide resolved
return resource.Default()
}

func newPropagator() propagation.TextMapPropagator {
Expand Down
Loading