operation_name_test.go 864 B

123456789101112131415161718192021222324252627
  1. package collector
  2. import (
  3. "testing"
  4. "go-common/app/service/main/dapper/model"
  5. protogen "go-common/library/net/trace/proto"
  6. )
  7. func TestOperationNameProcess(t *testing.T) {
  8. p := NewOperationNameProcess()
  9. sp1, _ := model.FromProtoSpan(&model.ProtoSpan{
  10. ServiceName: "http",
  11. OperationName: "http://www.example.com/echo",
  12. Tags: []*protogen.Tag{&protogen.Tag{Key: "span.kind", Kind: protogen.Tag_STRING, Value: []byte("client")}},
  13. }, false)
  14. p.Process(sp1)
  15. if sp1.OperationName != "HTTP:UNKONWN" || sp1.ProtoSpan.OperationName != "HTTP:UNKONWN" {
  16. t.Errorf("expect operationName == , get %s %s", sp1.OperationName, sp1.ProtoSpan.OperationName)
  17. }
  18. if sp1.StringTag("http.url") != "http://www.example.com/echo" {
  19. t.Errorf("expect http.url be set")
  20. }
  21. if sp1.StringTag("_peer.sign") != "/echo" {
  22. t.Errorf("expect _peer.sign be set")
  23. }
  24. }