-
Notifications
You must be signed in to change notification settings - Fork 1
Attempt to instrument mongodb queries #2
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
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,6 @@ | |||
class LogEntry |
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.
LogEntry
is completely arbitrary - just the simplest example I could come up with.
span_naming: :job_class | ||
}, | ||
"OpenTelemetry::Instrumentation::Mongo" => { | ||
db_statement: :include |
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.
Turns out this is important. Without this, the instrumentation will substitute ?
for attributes.
Just make sure you don't use this on PII information or secrets...
end | ||
end | ||
attributes | ||
end |
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.
Recursive function to build up filter.message
etc
require "opentelemetry/exporter/otlp" | ||
require "opentelemetry/instrumentation/all" | ||
|
||
class BatchSpanProcessorWithDbStatementFlattening < OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor |
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.
I don't like to subclass generally, but this works. Probably a better way to do this with delegation, but it's just a proof of concept.
Why
I'm interested in parsing out MongoDB queries to see if we can correlate performance to certain types of query.
How
Add a custom span processor before the span gets to OpenTelemetry.
Subclass the batch span processor but customise it so if the
db.statement
attribute is there, it assumes it's in JSON format and parses out all the attributes.Test
In Honeycomb if we hit
/patterns/new
we see:It works!