Skip to content
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

feat: support rocketMQ #231

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions agent/protocol/rocketmq/filter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package rocketmq

import (
"kyanos/agent/protocol"
"kyanos/bpf"
)

type Filter struct {
}

func (m Filter) Filter(req protocol.ParsedMessage, resp protocol.ParsedMessage) bool {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add some filter options and implement the filter logic here.

return true
}

func (m Filter) FilterByProtocol(p bpf.AgentTrafficProtocolT) bool {
return p == bpf.AgentTrafficProtocolTKProtocolRocketMQ
}

func (m Filter) FilterByRequest() bool {
return false
}

func (m Filter) FilterByResponse() bool {
return false
}

var _ protocol.ProtocolFilter = Filter{}
105 changes: 105 additions & 0 deletions agent/protocol/rocketmq/language_code.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package rocketmq

import (
"errors"
"fmt"
)

type LanguageCode byte

const (
JAVA LanguageCode = iota // 0
CPP // 1
DOTNET // 2
PYTHON // 3
DELPHI // 4
ERLANG // 5
RUBY // 6
OTHER // 7
HTTP // 8
GO // 9
PHP // 10
OMS // 11
RUST // 12
NODE_JS // 13
UNKNOWN
)

// convertToLanguageCode converts a string to a LanguageCode.
func convertToLanguageCode(language string) (LanguageCode, error) {
switch language {
case "JAVA":
return JAVA, nil
case "CPP":
return CPP, nil
case "DOTNET":
return DOTNET, nil
case "PYTHON":
return PYTHON, nil
case "DELPHI":
return DELPHI, nil
case "ERLANG":
return ERLANG, nil
case "RUBY":
return RUBY, nil
case "OTHER":
return OTHER, nil
case "HTTP":
return HTTP, nil
case "GO":
return GO, nil
case "PHP":
return PHP, nil
case "OMS":
return OMS, nil
case "RUST":
return RUST, nil
case "NODE_JS":
return NODE_JS, nil
default:
return 13, errors.New("unknown language: " + language)
}
}

// convertToLanguageCodeFromByte converts a byte to a LanguageCode.
func convertToLanguageCodeFromByte(flag byte) (LanguageCode, error) {
if flag > 13 {
return 0, errors.New("unknown language flag: " + fmt.Sprint(flag))
}
return LanguageCode(flag), nil
}

func (lc LanguageCode) String() string {
switch lc {
case JAVA:
return "JAVA"
case CPP:
return "CPP"
case DOTNET:
return "DOTNET"
case PYTHON:
return "PYTHON"
case DELPHI:
return "DELPHI"
case ERLANG:
return "ERLANG"
case RUBY:
return "RUBY"
case OTHER:
return "OTHER"
case HTTP:
return "HTTP"
case GO:
return "GO"
case PHP:
return "PHP"
case OMS:
return "OMS"
case RUST:
return "RUST"
case NODE_JS:
return "NODE_JS"
default:
return "UNKNOWN"
}
}
Loading
Loading