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

Adds to REDIS instrumentation message value as tag #1972

Closed

Conversation

yartat
Copy link

@yartat yartat commented Apr 11, 2021

Changes

Current implementation detects database number and command (like GET, EXISTS and other) but does not present information about key(s). This implementation of the RedisProfilerEntryToActivityConverter analyzes command and tries extract Message value (like [0]:GET key1) using reflection . In case extract message operation completed successfully the value will be placed to tag with name SemanticConventions.AttributeDbOperation.

@yartat yartat requested a review from a team April 11, 2021 10:37
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 11, 2021

CLA Signed

The committers are authorized under a signed CLA.

Fix unit tests
Fix file format
@codecov
Copy link

codecov bot commented Apr 11, 2021

Codecov Report

Merging #1972 (d08ca4f) into main (44cd88e) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1972      +/-   ##
==========================================
+ Coverage   83.57%   83.59%   +0.01%     
==========================================
  Files         192      192              
  Lines        6162     6169       +7     
==========================================
+ Hits         5150     5157       +7     
  Misses       1012     1012              
Impacted Files Coverage Δ
...mentation/RedisProfilerEntryToActivityConverter.cs 95.45% <100.00%> (+0.85%) ⬆️

if (!string.IsNullOrEmpty(message))
{
// Example: "db.operation": [0]:GET key1
activity.SetTag(SemanticConventions.AttributeDbOperation, message);
Copy link
Member

Choose a reason for hiding this comment

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

From semantic conventions doc, db.operation is required only if db.statement is not applicable. (https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/database.md#call-level-attributes)
Since we already populate the db.statement, we need to have good reason for populating db.operation considering its not free to obtain the value for it.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks a lot for review.
I've tested and had have next results

Read data from REDIS
db.redis.database_index=0
db.redis.flags=1024
db.statement=GET
peer.service=xx.xx.xx.xx:6379
net.peer.ip=xx.xx.xx.xx
db.operation=[0]:GET sso:templates:String:USERRESET (RedisValueProcessor)
Delete key in REDIS
db.redis.database_index=0
db.redis.flags=1028
db.statement=UNLINK
peer.service=xx.xx.xx.xx:6379
net.peer.ip=xx.xx.xx.xx
db.operation=[0]:UNLINK sso:templates:String:USERRESET (DemandZeroOrOneProcessor)
Write JSON to REDIS
db.redis.database_index=0
db.redis.flags=1028
db.statement=SETEX
peer.service=xx.xx.xx.xx:6379
net.peer.ip=xx.xx.xx.xx
db.operation=[0]:SETEX sso:templates:String:USERRESET (BooleanProcessor)

So, db.operation contains REDIS operation, db number and key. Semantic conventions doc contains next text

When setting this to an SQL keyword, it is not recommended to attempt any client-side parsing of db.statement just to get this property, but it should be set if the operation name is provided by the library being instrumented.

For Redis, the value provided for db.statement SHOULD correspond to the syntax of the Redis CLI. If, for example, the HMSET command is invoked, "HMSET myhash field1 'Hello' field2 'World'" would be a suitable value for db.statement.

db.statement does not contain key and value. db.operation contains key but does not contain value. It is much more information to analyze!
How would you like an idea if I add parsing db.operation to get Redis CLI-like to match the semantic conventions doc?

@ejsmith
Copy link
Contributor

ejsmith commented May 15, 2021

Yes! This would be so useful!!

@ejsmith
Copy link
Contributor

ejsmith commented Sep 2, 2021

This PR can be closed as it was implemented in #2198

@yartat yartat closed this Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants