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

fix: Fixing Analyzer Rules and Updating Values #2738

Merged

Conversation

xoscar
Copy link
Collaborator

@xoscar xoscar commented Jun 15, 2023

This PR updates the analyzer rules to better match the semantic conventions.

Changes

  • Fixes issues with rules reporting the results
  • Updates required values for different span types
  • Updates name matching for Redis db spans
  • Updates pokeshop proto file to include the isFixed flag

Fixes

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

@xoscar xoscar added the backend label Jun 15, 2023
@xoscar xoscar self-assigned this Jun 15, 2023
@xoscar xoscar linked an issue Jun 15, 2023 that may be closed by this pull request
@xoscar xoscar marked this pull request as ready for review June 15, 2023 15:58
@@ -13,7 +13,8 @@ type ensuresDnsUsage struct {
}

var (
dnsFields = []string{"net.peer.name", "http.url", "db.connection_string", "net.sock.peer.addr", "net.host.name"}
clientDnsFields = []string{"net.peer.name"}
dnsFields = []string{"http.url", "db.connection_string"}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

net.peer.name is only required for client spans

@@ -22,7 +22,7 @@ func NewEnforceHttpsProtocolRule() model.Rule {
Name: "Enforce HTTPS Protocol",
Description: "Ensure all request use https",
Tips: []string{},
Weight: 40,
Weight: 20,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updating the weight

for _, span := range trace.Flat {
results = append(results, r.validateSpanName(ctx, span))
result := r.validateSpanName(ctx, span)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We had an issue here that we never reported 100% pass for this rule

} else {
expectedName = fmt.Sprintf("%s %s", dbOperation, dbName)
// TODO: fix this by adding proper validation for all other db systems
dbSystem := span.Attributes.Get("db.system")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For Redis, we have to match the prefix of the statement to validate the name. This should be improved in the future to run checks by db system

@@ -12,7 +12,7 @@ var (
httpAttrServer = []string{"http.target", "http.scheme", "net.host.name"}

databaseAttr = []string{"db.system"}
rpcAttr = []string{"rpc.system", "neet.peer.name"}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

NEEET

@@ -1,3 +1,3 @@
{
"proto": "syntax = \"proto3\";\n\noption java_multiple_files = true;\noption java_outer_classname = \"PokeshopProto\";\noption objc_class_prefix = \"PKS\";\n\npackage pokeshop;\n\nservice Pokeshop {\n rpc getPokemonList (GetPokemonRequest) returns (GetPokemonListResponse) {}\n rpc createPokemon (Pokemon) returns (Pokemon) {}\n rpc importPokemon (ImportPokemonRequest) returns (ImportPokemonRequest) {}\n}\n\nmessage ImportPokemonRequest {\n int32 id = 1;\n}\n\nmessage GetPokemonRequest {\n optional int32 skip = 1;\n optional int32 take = 2;\n}\n\nmessage GetPokemonListResponse {\n repeated Pokemon items = 1;\n int32 totalCount = 2;\n}\n\nmessage Pokemon {\n optional int32 id = 1;\n string name = 2;\n string type = 3;\n bool isFeatured = 4;\n optional string imageUrl = 5;\n}\n"
"proto": "syntax = \"proto3\";\n\noption java_multiple_files = true;\noption java_outer_classname = \"PokeshopProto\";\noption objc_class_prefix = \"PKS\";\n\npackage pokeshop;\n\nservice Pokeshop {\n rpc getPokemonList (GetPokemonRequest) returns (GetPokemonListResponse) {}\n rpc createPokemon (Pokemon) returns (Pokemon) {}\n rpc importPokemon (ImportPokemonRequest) returns (ImportPokemonRequest) {}\n}\n\nmessage ImportPokemonRequest {\n int32 id = 1;\n optional bool isFixed = 2;\n}\n\nmessage GetPokemonRequest {\n optional int32 skip = 1;\n optional int32 take = 2;\n optional bool isFixed = 3;\n}\n\nmessage GetPokemonListResponse {\n repeated Pokemon items = 1;\n int32 totalCount = 2;\n}\n\nmessage Pokemon {\n optional int32 id = 1;\n string name = 2;\n string type = 3;\n bool isFeatured = 4;\n optional string imageUrl = 5;\n}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding support for the isFixed flag

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the near future, we should change this to read it directly from the repo to have to do this copy paste

@xoscar xoscar merged commit 76e99bc into main Jun 15, 2023
24 checks passed
@xoscar xoscar deleted the 2714-analyzer-results-fix-pokeshop-api-to-yield-successful-scores branch June 15, 2023 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Analyzer Results] Fix Pokeshop API to yield successful scores
2 participants