diff --git a/api/gateway/middleware/tracing/v1/tracing.pb.go b/api/gateway/middleware/tracing/v1/tracing.pb.go index 99b7451..265f406 100644 --- a/api/gateway/middleware/tracing/v1/tracing.pb.go +++ b/api/gateway/middleware/tracing/v1/tracing.pb.go @@ -28,9 +28,14 @@ type Tracing struct { unknownFields protoimpl.UnknownFields // report endpoint url - HttpEndpoint string `protobuf:"bytes,1,opt,name=http_endpoint,json=httpEndpoint,proto3" json:"http_endpoint,omitempty"` + // + // Types that are assignable to Endpoint: + // + // *Tracing_HttpEndpoint + // *Tracing_HttpEndpointUrl + Endpoint isTracing_Endpoint `protobuf_oneof:"endpoint"` // sample ratio - SampleRatio *float32 `protobuf:"fixed32,2,opt,name=sample_ratio,json=sampleRatio,proto3,oneof" json:"sample_ratio,omitempty"` + SampleRatio *float32 `protobuf:"fixed32,3,opt,name=sample_ratio,json=sampleRatio,proto3,oneof" json:"sample_ratio,omitempty"` // report timeout Timeout *durationpb.Duration `protobuf:"bytes,4,opt,name=timeout,proto3" json:"timeout,omitempty"` // ssl @@ -69,13 +74,27 @@ func (*Tracing) Descriptor() ([]byte, []int) { return file_gateway_middleware_tracing_v1_tracing_proto_rawDescGZIP(), []int{0} } +func (m *Tracing) GetEndpoint() isTracing_Endpoint { + if m != nil { + return m.Endpoint + } + return nil +} + func (x *Tracing) GetHttpEndpoint() string { - if x != nil { + if x, ok := x.GetEndpoint().(*Tracing_HttpEndpoint); ok { return x.HttpEndpoint } return "" } +func (x *Tracing) GetHttpEndpointUrl() string { + if x, ok := x.GetEndpoint().(*Tracing_HttpEndpointUrl); ok { + return x.HttpEndpointUrl + } + return "" +} + func (x *Tracing) GetSampleRatio() float32 { if x != nil && x.SampleRatio != nil { return *x.SampleRatio @@ -97,6 +116,22 @@ func (x *Tracing) GetInsecure() bool { return false } +type isTracing_Endpoint interface { + isTracing_Endpoint() +} + +type Tracing_HttpEndpoint struct { + HttpEndpoint string `protobuf:"bytes,1,opt,name=http_endpoint,json=httpEndpoint,proto3,oneof"` +} + +type Tracing_HttpEndpointUrl struct { + HttpEndpointUrl string `protobuf:"bytes,2,opt,name=http_endpoint_url,json=httpEndpointUrl,proto3,oneof"` +} + +func (*Tracing_HttpEndpoint) isTracing_Endpoint() {} + +func (*Tracing_HttpEndpointUrl) isTracing_Endpoint() {} + var File_gateway_middleware_tracing_v1_tracing_proto protoreflect.FileDescriptor var file_gateway_middleware_tracing_v1_tracing_proto_rawDesc = []byte{ @@ -106,25 +141,28 @@ var file_gateway_middleware_tracing_v1_tracing_proto_rawDesc = []byte{ 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xca, 0x01, 0x0a, - 0x07, 0x54, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x23, 0x0a, 0x0d, 0x68, 0x74, 0x74, 0x70, - 0x5f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0c, 0x68, 0x74, 0x74, 0x70, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x26, 0x0a, - 0x0c, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x02, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x61, 0x74, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x86, 0x02, 0x0a, + 0x07, 0x54, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x25, 0x0a, 0x0d, 0x68, 0x74, 0x74, 0x70, + 0x5f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, + 0x00, 0x52, 0x0c, 0x68, 0x74, 0x74, 0x70, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, + 0x2c, 0x0a, 0x11, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0f, 0x68, 0x74, + 0x74, 0x70, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x55, 0x72, 0x6c, 0x12, 0x26, 0x0a, + 0x0c, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x02, 0x48, 0x01, 0x52, 0x0b, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x61, 0x74, 0x69, 0x6f, 0x88, 0x01, 0x01, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1f, 0x0a, 0x08, 0x69, 0x6e, - 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x48, 0x01, 0x52, 0x08, - 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, - 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x42, 0x0b, 0x0a, 0x09, - 0x5f, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x42, 0x40, 0x5a, 0x3e, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x6b, 0x72, 0x61, 0x74, 0x6f, - 0x73, 0x2f, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x61, - 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, - 0x2f, 0x74, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x48, 0x02, 0x52, 0x08, + 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x65, + 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x73, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x5f, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x69, 0x6e, 0x73, + 0x65, 0x63, 0x75, 0x72, 0x65, 0x42, 0x40, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2f, 0x67, 0x61, + 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, + 0x79, 0x2f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, + 0x63, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -172,7 +210,10 @@ func file_gateway_middleware_tracing_v1_tracing_proto_init() { } } } - file_gateway_middleware_tracing_v1_tracing_proto_msgTypes[0].OneofWrappers = []interface{}{} + file_gateway_middleware_tracing_v1_tracing_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Tracing_HttpEndpoint)(nil), + (*Tracing_HttpEndpointUrl)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/api/gateway/middleware/tracing/v1/tracing.proto b/api/gateway/middleware/tracing/v1/tracing.proto index 465e333..0037d69 100644 --- a/api/gateway/middleware/tracing/v1/tracing.proto +++ b/api/gateway/middleware/tracing/v1/tracing.proto @@ -8,12 +8,15 @@ import "google/protobuf/duration.proto"; // Tracing middleware config. message Tracing { - // report endpoint url - string http_endpoint = 1; - // sample ratio - optional float sample_ratio = 2; - // report timeout - google.protobuf.Duration timeout = 4; - // ssl - optional bool insecure = 5; + // report endpoint url + oneof endpoint { + string http_endpoint = 1; + string http_endpoint_url = 2; + } + // sample ratio + optional float sample_ratio = 3; + // report timeout + google.protobuf.Duration timeout = 4; + // ssl + optional bool insecure = 5; } diff --git a/middleware/tracing/tracing.go b/middleware/tracing/tracing.go index 18a1234..f311273 100644 --- a/middleware/tracing/tracing.go +++ b/middleware/tracing/tracing.go @@ -114,9 +114,14 @@ func newTracerProvider(ctx context.Context, options *v1.Tracing) trace.TracerPro } otlpoptions := []otlptracehttp.Option{ - otlptracehttp.WithEndpoint(options.HttpEndpoint), otlptracehttp.WithTimeout(timeout), } + switch options.Endpoint.(type) { + case *v1.Tracing_HttpEndpoint: + otlpoptions = append(otlpoptions, otlptracehttp.WithEndpoint(options.GetHttpEndpoint())) + case *v1.Tracing_HttpEndpointUrl: + otlpoptions = append(otlpoptions, otlptracehttp.WithEndpointURL(options.GetHttpEndpointUrl())) + } if options.Insecure != nil && *options.Insecure { otlpoptions = append(otlpoptions, otlptracehttp.WithInsecure()) }