샘플
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0: WithEndpoint
검증된 샘플 — golang go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0: WithEndpoint. go 1.26 · linux debian/x64 · docker에서 contract를 실행해…
sha256:663614c56b5d8a12a24b5ef42ed9e2fd662559bee1bb76eaafd52c4a58e9e55f
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 go
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-02 |
케이스
HOW- 목표
- verify otlptracegrpc.WithEndpoint in pkg:golang/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc@v1.35.0
- 심벌
-
- otlptracegrpc.WithEndpoint
- 생성일
- 2026-09-02T18:36:31Z
컨트랙트
- otlptracegrpc.WithEndpoint configures the target collector address without scheme or path
- otlptracegrpc.WithEndpoint option takes precedence over OTEL_EXPORTER_OTLP_ENDPOINT environment variable
- otlptracegrpc.WithEndpoint routes exported spans to the configured gRPC endpoint server
- otlptracegrpc.NewClient initializes a client configured with WithEndpoint and Insecure options
파일
- PROMPT.md
- csx.json
- endpoint.go
- go.mod
- go.sum
- spec.json
- test/contract.go
소스
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify otlptracegrpc.WithEndpoint in pkg:golang/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc@v1.35.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc@v1.35.0
Demonstrate these symbols/APIs:
- otlptracegrpc.WithEndpoint
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:a6de182bfcd3145151c2597aa0ca0580f991dc5f5fb9419dfa952457c381752e","contract":["otlptracegrpc.WithEndpoint configures the target collector address without scheme or path","otlptracegrpc.WithEndpoint option takes precedence over OTEL_EXPORTER_OTLP_ENDPOINT environment variable","otlptracegrpc.WithEndpoint routes exported spans to the configured gRPC endpoint server","otlptracegrpc.NewClient initializes a client configured with WithEndpoint and Insecure options"],"goal":"verify otlptracegrpc.WithEndpoint in pkg:golang/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc@v1.35.0","kind":"HOW","packages":["pkg:golang/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc@v1.35.0"],"schemaVersion":1,"symbols":["otlptracegrpc.WithEndpoint"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc@v1.35.0"],"schemaVersion":1,"subject":"pkg:golang/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc@v1.35.0","symbols":["otlptracegrpc.WithEndpoint"],"verifierAdapter":"golang@1"}
package endpointsample
import (
"context"
"time"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
)
// ExporterConfig configures an OTLP trace gRPC exporter.
type ExporterConfig struct {
Endpoint string
Insecure bool
Timeout time.Duration
}
// NewExporter creates an OTLP trace gRPC exporter configured with WithEndpoint.
func NewExporter(ctx context.Context, cfg ExporterConfig) (*otlptrace.Exporter, error) {
var opts []otlptracegrpc.Option
if cfg.Endpoint != "" {
opts = append(opts, otlptracegrpc.WithEndpoint(cfg.Endpoint))
}
if cfg.Insecure {
opts = append(opts, otlptracegrpc.WithInsecure())
}
if cfg.Timeout > 0 {
opts = append(opts, otlptracegrpc.WithTimeout(cfg.Timeout))
}
return otlptracegrpc.New(ctx, opts...)
}
// BuildOptions builds a slice of otlptracegrpc.Option with the given endpoint.
func BuildOptions(endpoint string, insecure bool) []otlptracegrpc.Option {
opts := []otlptracegrpc.Option{
otlptracegrpc.WithEndpoint(endpoint),
}
if insecure {
opts = append(opts, otlptracegrpc.WithInsecure())
}
return opts
}
module example.com/otlptracegrpc-endpoint-sample
go 1.26.6
require (
go.opentelemetry.io/otel v1.35.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0
go.opentelemetry.io/otel/sdk v1.35.0
go.opentelemetry.io/otel/trace v1.35.0
go.opentelemetry.io/proto/otlp v1.5.0
google.golang.org/grpc v1.71.0
)
require (
github.com/cenkalti/backoff/v4 v4.3.0 // 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
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel/metric v1.35.0 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect
google.golang.org/protobuf v1.36.5 // indirect
)
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
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/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/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
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/grpc-ecosystem/grpc-gateway/v2 v2.26.1 h1:e9Rjr40Z98/clHv5Yg79Is0NtosR5LXRvdr7o/6NwbA=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1/go.mod h1:tIxuGz/9mpox++sgp9fJjHO0+q1X9/UOWd798aAm22M=
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.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 h1:1fTNlAIJZGWLP5FVu0fikVry1IsiUnXjf7QFvoNN3Xw=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0/go.mod h1:zjPK58DtkqQFn+YUMbx0M2XV3QgKU0gS9LeGohREyK4=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0 h1:m639+BofXTvcY1q8CGs4ItwQarYtJPOWmVobfM1HpVI=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0/go.mod h1:LjReUci/F4BUyv+y4dwnq3h/26iNOeC3wAIqgvTIZVo=
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY=
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU/3i4=
go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a h1:nwKuGPlUAt+aR+pcrkfFRrTU1BVrSmYyYMxYbUIVHr0=
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a/go.mod h1:3kWAYMk1I75K4vykHtKt2ycnOgpA6974V7bREqbsenU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ=
google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
{
"schemaVersion": 1,
"goal": "verify otlptracegrpc.WithEndpoint in pkg:golang/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc@v1.35.0",
"kind": "HOW",
"packages": [
"pkg:golang/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc@v1.35.0"
],
"symbols": [
"otlptracegrpc.WithEndpoint"
]
}
package main
import (
"context"
"fmt"
"net"
"os"
"sync"
sample "example.com/otlptracegrpc-endpoint-sample"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/trace"
coltracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
"google.golang.org/grpc"
)
type mockTraceServer struct {
coltracepb.UnimplementedTraceServiceServer
mu sync.Mutex
requests []*coltracepb.ExportTraceServiceRequest
}
func (s *mockTraceServer) Export(ctx context.Context, req *coltracepb.ExportTraceServiceRequest) (*coltracepb.ExportTraceServiceResponse, error) {
s.mu.Lock()
defer s.mu.Unlock()
s.requests = append(s.requests, req)
return &coltracepb.ExportTraceServiceResponse{}, nil
}
func (s *mockTraceServer) getRequests() []*coltracepb.ExportTraceServiceRequest {
s.mu.Lock()
defer s.mu.Unlock()
out := make([]*coltracepb.ExportTraceServiceRequest, len(s.requests))
copy(out, s.requests)
return out
}
func main() {
ctx := context.Background()
// Assertion 1: otlptracegrpc.WithEndpoint configures the target collector address without scheme or path
exp1, err := sample.NewExporter(ctx, sample.ExporterConfig{
Endpoint: "127.0.0.1:4317",
Insecure: true,
})
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: failed to create exporter with endpoint: %v\n", err)
os.Exit(1)
}
if exp1 == nil {
fmt.Fprintf(os.Stderr, "FAIL: expected non-nil exporter\n")
os.Exit(1)
}
if err := exp1.Shutdown(ctx); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: exporter shutdown failed: %v\n", err)
os.Exit(1)
}
// Assertion 2: otlptracegrpc.WithEndpoint option takes precedence over OTEL_EXPORTER_OTLP_ENDPOINT environment variable
prevEnv, hadEnv := os.LookupEnv("OTEL_EXPORTER_OTLP_ENDPOINT")
os.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://overridden.example.com:4317")
exp2, err := sample.NewExporter(ctx, sample.ExporterConfig{
Endpoint: "127.0.0.1:4317",
Insecure: true,
})
if hadEnv {
os.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", prevEnv)
} else {
os.Unsetenv("OTEL_EXPORTER_OTLP_ENDPOINT")
}
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: WithEndpoint precedence over env variable failed: %v\n", err)
os.Exit(1)
}
if exp2 == nil {
fmt.Fprintf(os.Stderr, "FAIL: expected non-nil exporter with env override\n")
os.Exit(1)
}
if err := exp2.Shutdown(ctx); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: exporter 2 shutdown failed: %v\n", err)
os.Exit(1)
}
// Assertion 3: otlptracegrpc.WithEndpoint routes exported spans to the configured gRPC endpoint server
lis, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: net.Listen failed: %v\n", err)
os.Exit(1)
}
defer lis.Close()
srv := grpc.NewServer()
mockSrv := &mockTraceServer{}
coltracepb.RegisterTraceServiceServer(srv, mockSrv)
go func() {
_ = srv.Serve(lis)
}()
defer srv.Stop()
targetEndpoint := lis.Addr().String()
exp3, err := sample.NewExporter(ctx, sample.ExporterConfig{
Endpoint: targetEndpoint,
Insecure: true,
})
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: exporter creation for local server failed: %v\n", err)
os.Exit(1)
}
bsp := sdktrace.NewBatchSpanProcessor(exp3)
tp := sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(bsp))
tracer := tp.Tracer("contract-tracer")
spanName := "contract-endpoint-span"
_, testSpan := tracer.Start(ctx, spanName, trace.WithAttributes(
attribute.String("service.name", "contract-test"),
attribute.Int("endpoint.port", lis.Addr().(*net.TCPAddr).Port),
))
wantTraceID := testSpan.SpanContext().TraceID()
wantSpanID := testSpan.SpanContext().SpanID()
testSpan.End()
if err := tp.ForceFlush(ctx); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: TracerProvider ForceFlush failed: %v\n", err)
os.Exit(1)
}
reqs := mockSrv.getRequests()
if len(reqs) == 0 {
fmt.Fprintf(os.Stderr, "FAIL: expected mock server to receive ExportTraceServiceRequest\n")
os.Exit(1)
}
var foundSpan *tracepb.Span
for _, req := range reqs {
for _, rs := range req.GetResourceSpans() {
for _, ss := range rs.GetScopeSpans() {
for _, s := range ss.GetSpans() {
if s.GetName() == spanName {
foundSpan = s
break
}
}
}
}
}
if foundSpan == nil {
fmt.Fprintf(os.Stderr, "FAIL: exported span %q not received by endpoint server\n", spanName)
os.Exit(1)
}
if [16]byte(foundSpan.GetTraceId()) != wantTraceID {
fmt.Fprintf(os.Stderr, "FAIL: trace ID mismatch: got %x, want %x\n", foundSpan.GetTraceId(), wantTraceID)
os.Exit(1)
}
if [8]byte(foundSpan.GetSpanId()) != wantSpanID {
fmt.Fprintf(os.Stderr, "FAIL: span ID mismatch: got %x, want %x\n", foundSpan.GetSpanId(), wantSpanID)
os.Exit(1)
}
if err := tp.Shutdown(ctx); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: TracerProvider shutdown failed: %v\n", err)
os.Exit(1)
}
if err := exp3.Shutdown(ctx); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: exporter 3 shutdown failed: %v\n", err)
os.Exit(1)
}
// Assertion 4: otlptracegrpc.NewClient initializes a client configured with WithEndpoint and Insecure options
opts := sample.BuildOptions("127.0.0.1:4317", true)
client := otlptracegrpc.NewClient(opts...)
if client == nil {
fmt.Fprintf(os.Stderr, "FAIL: NewClient returned nil\n")
os.Exit(1)
}
exp4, err := otlptrace.New(ctx, client)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: otlptrace.New failed: %v\n", err)
os.Exit(1)
}
if exp4 == nil {
fmt.Fprintf(os.Stderr, "FAIL: otlptrace.New returned nil\n")
os.Exit(1)
}
if err := exp4.Shutdown(ctx); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: exporter 4 shutdown failed: %v\n", err)
os.Exit(1)
}
fmt.Println("PASS: otlptracegrpc.WithEndpoint contract passed")
}
오리진 시더
익명