Skip to content

Update go-sdk.mdx #81

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

Merged
merged 2 commits into from
Feb 11, 2021
Merged
Changes from all 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
33 changes: 19 additions & 14 deletions src/docs/getting-started/go-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,13 @@ The function should look something like this:
func initTracer() {

// Create new OTLP Exporter struct
exporter, err := otlp.NewExporter(
otlp.WithInsecure(),
otlp.WithAddress("localhost:30080"),
driver := otlpgrpc.NewDriver(
otlpgrpc.WithInsecure(),
otlpgrpc.WithEndpoint("localhost:30080"),
otlpgrpc.WithDialOption(grpc.WithBlock()), // useful for testing
)

exporter, err := otlp.NewExporter(ctx, driver)
if err != nil {
// Handle error here...
}
Expand Down Expand Up @@ -326,6 +329,7 @@ import (
"go.opentelemetry.io/contrib/propagators/aws/xray"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp"
"go.opentelemetry.io/otel/exporters/otlp/otlpgrpc"

sdktrace "go.opentelemetry.io/otel/sdk/trace"
)
Expand Down Expand Up @@ -362,10 +366,13 @@ func handler(w http.ResponseWriter, r *http.Request) {
func initTracer() {

// Create new OTLP Exporter struct
exporter, err := otlp.NewExporter(
otlp.WithInsecure(),
otlp.WithAddress("localhost:30080"),
)
driver := otlpgrpc.NewDriver(
otlpgrpc.WithInsecure(),
otlpgrpc.WithEndpoint("localhost:30080"),
otlpgrpc.WithDialOption(grpc.WithBlock()), // useful for testing
)

exporter, err := otlp.NewExporter(ctx, driver)
if err != nil {
// Handle error here...
}
Expand Down Expand Up @@ -414,15 +421,14 @@ The following code snippet demonstrates how to use the ECS resource detector.
```go lineNumbers=true
import (
"context"
"go.opentelemetry.io/contrib/detectors/ecs"
"go.opentelemetry.io/contrib/detectors/aws/ecs"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

func main() {

// Instantiate a new ECS Resource detector
ecsResourceDetector := new(ecs.ResourceDetector)

ecsResourceDetector := ecs.NewResourceDetector()
resource, err := ecsResourceDetector.Detect(context.Background())

//Associate resource with TracerProvider
Expand All @@ -449,15 +455,14 @@ The following code snippet demonstrates how to use the EKS Resource detector.
```go lineNumbers=true
import (
"context"
"go.opentelemetry.io/contrib/detectors/eks"
"go.opentelemetry.io/contrib/detectors/aws/eks"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

func main() {

// Instantiate a new EKS Resource detector
eksResourceDetector := new(eks.ResourceDetector)

eksResourceDetector := eks.NewResourceDetector()
resource, err := eksResourceDetector.Detect(context.Background())

//Associate resource with TracerProvider
Expand All @@ -473,4 +478,4 @@ func main() {
## Conclusion

After reading this guide you should now have a basic understand of how to instrument Go applications with OpenTelemetry and send traces
to AWS X-Ray. We also went through how to use the resource detectors to extract information specific to ECS and EKS environments into `resource` objects.
to AWS X-Ray. We also went through how to use the resource detectors to extract information specific to ECS and EKS environments into `resource` objects.