diff --git a/internal/cmd/client.go b/internal/cmd/client.go index 2a81004..e8b2132 100644 --- a/internal/cmd/client.go +++ b/internal/cmd/client.go @@ -11,6 +11,8 @@ import ( "github.com/go-faster/sdk/zctx" "github.com/spf13/cobra" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/sdk/resource" "go.uber.org/zap" "github.com/go-faster/simon/internal/app" @@ -47,7 +49,7 @@ func cmdClient() *cobra.Command { ticker := time.NewTicker(time.Second) tracer := t.TracerProvider().Tracer("") tick := func() { - ctx, cancel := context.WithTimeout(ctx, time.Second) + ctx, cancel := context.WithTimeout(ctx, time.Millisecond*250) defer cancel() ctx, span := tracer.Start(ctx, "client.tick") @@ -72,7 +74,20 @@ func cmdClient() *cobra.Command { tick() } } - }) + }, + sdka.WithResource(func(ctx context.Context) (*resource.Resource, error) { + return resource.New(ctx, + resource.WithOS(), + resource.WithFromEnv(), + resource.WithTelemetrySDK(), + resource.WithHost(), + resource.WithProcess(), + resource.WithAttributes( + attribute.String("service.name", "simon.client"), + ), + ) + }), + ) }, } } diff --git a/internal/cmd/server.go b/internal/cmd/server.go index b1dedac..1bd99fb 100644 --- a/internal/cmd/server.go +++ b/internal/cmd/server.go @@ -14,6 +14,8 @@ import ( "github.com/rs/cors" "github.com/spf13/cobra" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/sdk/resource" "go.uber.org/zap" "golang.org/x/sync/errgroup" @@ -105,7 +107,20 @@ func cmdServer() *cobra.Command { return nil }) return g.Wait() - }) + }, + sdka.WithResource(func(ctx context.Context) (*resource.Resource, error) { + return resource.New(ctx, + resource.WithOS(), + resource.WithFromEnv(), + resource.WithTelemetrySDK(), + resource.WithHost(), + resource.WithProcess(), + resource.WithAttributes( + attribute.String("service.name", "simon.server"), + ), + ) + }), + ) }, } }