| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
package otelgrpc |
| 5 |
|
| 6 |
import ( |
| 7 |
"context" |
| 8 |
|
| 9 |
"google.golang.org/grpc" |
| 10 |
"google.golang.org/grpc/codes" |
| 11 |
"google.golang.org/grpc/status" |
| 12 |
|
| 13 |
"go.opentelemetry.io/collector/pdata/internal" |
| 14 |
) |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
type LogsServiceClient interface { |
| 20 |
Export(context.Context, *internal.ExportLogsServiceRequest, ...grpc.CallOption) (*internal.ExportLogsServiceResponse, error) |
| 21 |
} |
| 22 |
|
| 23 |
type logsServiceClient struct { |
| 24 |
cc *grpc.ClientConn |
| 25 |
} |
| 26 |
|
| 27 |
func NewLogsServiceClient(cc *grpc.ClientConn) LogsServiceClient { |
| 28 |
return &logsServiceClient{cc} |
| 29 |
} |
| 30 |
|
| 31 |
func (c *logsServiceClient) Export(ctx context.Context, in *internal.ExportLogsServiceRequest, opts ...grpc.CallOption) (*internal.ExportLogsServiceResponse, error) { |
| 32 |
out := new(internal.ExportLogsServiceResponse) |
| 33 |
err := c.cc.Invoke(ctx, "/opentelemetry.proto.collector.logs.v1.LogsService/Export", in, out, opts...) |
| 34 |
if err != nil { |
| 35 |
return nil, err |
| 36 |
} |
| 37 |
return out, nil |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
type LogsServiceServer interface { |
| 42 |
Export(context.Context, *internal.ExportLogsServiceRequest) (*internal.ExportLogsServiceResponse, error) |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
type UnimplementedLogsServiceServer struct{} |
| 47 |
|
| 48 |
func (*UnimplementedLogsServiceServer) Export(context.Context, *internal.ExportLogsServiceRequest) (*internal.ExportLogsServiceResponse, error) { |
| 49 |
return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") |
| 50 |
} |
| 51 |
|
| 52 |
func RegisterLogsServiceServer(s *grpc.Server, srv LogsServiceServer) { |
| 53 |
s.RegisterService(&logsServiceServiceDesc, srv) |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
func logsServiceExportHandler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { |
| 60 |
in := new(internal.ExportLogsServiceRequest) |
| 61 |
if err := dec(in); err != nil { |
| 62 |
return nil, err |
| 63 |
} |
| 64 |
if interceptor == nil { |
| 65 |
return srv.(LogsServiceServer).Export(ctx, in) |
| 66 |
} |
| 67 |
info := &grpc.UnaryServerInfo{ |
| 68 |
Server: srv, |
| 69 |
FullMethod: "/opentelemetry.proto.collector.logs.v1.LogsService/Export", |
| 70 |
} |
| 71 |
handler := func(ctx context.Context, req any) (any, error) { |
| 72 |
return srv.(LogsServiceServer).Export(ctx, req.(*internal.ExportLogsServiceRequest)) |
| 73 |
} |
| 74 |
return interceptor(ctx, in, info, handler) |
| 75 |
} |
| 76 |
|
| 77 |
var logsServiceServiceDesc = grpc.ServiceDesc{ |
| 78 |
ServiceName: "opentelemetry.proto.collector.logs.v1.LogsService", |
| 79 |
HandlerType: (*LogsServiceServer)(nil), |
| 80 |
Methods: []grpc.MethodDesc{ |
| 81 |
{ |
| 82 |
MethodName: "Export", |
| 83 |
Handler: logsServiceExportHandler, |
| 84 |
}, |
| 85 |
}, |
| 86 |
Streams: []grpc.StreamDesc{}, |
| 87 |
Metadata: "opentelemetry/proto/collector/logs/v1/logs_service.proto", |
| 88 |
} |