-
Notifications
You must be signed in to change notification settings - Fork 27
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
feature: make trace with jaeger & opentelemetry #26
base: main
Are you sure you want to change the base?
Conversation
Fleezesd
commented
Oct 13, 2023
- Use opentelemetry as the traceprovider for link tracking, but I hope to reduce the intrusion of the business code, so I chose the otelgin official middleware method to directly pass the trace information to jaeger. It depends on the author's choice.
- And the gateway code returns 200 business status code for rpc service errors. See if the error codes need to be unified like kratos framework later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the binary files
@@ -33,7 +33,7 @@ redis: | |||
redisNetwork: "tcp" | |||
|
|||
etcd: | |||
address: 127.0.0.1:2380 | |||
address: 127.0.0.1:2379 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't change this etcd address. the 2380 of etcd is for micro service, and the 2379 of etcd is for milvus.
@@ -15,20 +15,20 @@ func ListFavorite(ctx *gin.Context) { | |||
var req pb.FavoriteListReq | |||
if err := ctx.Bind(&req); err != nil { | |||
log.LogrusObj.Errorf("Bind:%v", err) | |||
ctx.JSON(http.StatusOK, ctl.RespError(ctx, err, "绑定参数错误")) | |||
ctx.JSON(http.StatusInternalServerError, ctl.RespError(ctx, err, "绑定参数错误")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't change this http.StatusOK
to http.StatusInternalServerError
, we all set the HTTP response code is 200, and we will set the logic of response code in response body, you can see the ctl.RespError()
"fmt" | ||
"github.com/CocaineCong/tangseng/pkg/trace" | ||
"net/http" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use the golangci-lint run
to standardize the sort of pkg import .
- ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2380 | ||
- ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2380 | ||
- ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 | ||
- ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2379 | ||
- "ALLOW_NONE_AUTHENTICATION=yes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you change this port back to 2380 ?🤣 you can think a little more before modifying the configuration file. 😂
) | ||
|
||
// TODO 若是想用x-request-id 方式连通链路, 也可看middleware下的trace, 按需求来选, 推荐官方的open-telemetry的方式 因jaeger-client已被舍弃 | ||
var ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job!! 👏
@@ -36,7 +41,7 @@ func NewMapReduceServiceClient(cc grpc.ClientConnInterface) MapReduceServiceClie | |||
|
|||
func (c *mapReduceServiceClient) MasterAssignTask(ctx context.Context, in *MapReduceTask, opts ...grpc.CallOption) (*MapReduceTask, error) { | |||
out := new(MapReduceTask) | |||
err := c.cc.Invoke(ctx, "/MapReduceService/MasterAssignTask", in, out, opts...) | |||
err := c.cc.Invoke(ctx, MapReduceService_MasterAssignTask_FullMethodName, in, out, opts...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tested these files yet? so many change🙂
) | ||
otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})) | ||
|
||
return exporter.Shutdown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested trace ? I think this should be appeared in the response body.
such as :
{
"status": 200,
"msg": "success",
"errors": null,
"data": {},
"timestamp": 1682042879,
"trace_id": "0a98685f6441efffb72d687be99381aa"
}