dd-trace-js
dd-trace-js copied to clipboard
Add getSpanLimits() method
What does this PR do?
This PR adds the getSpanLimits method to the Tracer class in dd-trace to ensure compatibility with @opentelemetry/sdk-trace-base. This method is necessary for creating spans in @prisma/instrumentation.
Motivation
related issue #1244, getSpanLimits is not a function error
While integrating @prisma/instrumentation with dd-trace, an error was encountered due to the absence of the getSpanLimits method in dd-trace's Tracer class. The @opentelemetry/sdk-trace-base Span constructor calls this method, which led to the error. Implementing this method resolves the issue and allows the integration to work correctly.
Additional Notes
During the integration of @prisma/instrumentation, it was discovered that dd-trace lacks the getSpanLimits method required by @opentelemetry/sdk-trace-base. This PR addresses this by adding a basic implementation of the method. If dd-trace has its own span limits, they should be returned instead of the empty object.
Hey @stewartmalik,
I think you might be in luck with sampling rules here:
DD_TRACE_SAMPLING_RULES="[{"service": "pdo", "sample_rate": 0}]"
These sampling rules apply by default to the root span only, and so you seem to want to exclude root spans with the pdo service, which fits this perfectly.
Hi @bwoebi,
Apologies for the late response, I've added the changes to our application. In testing your suggestion seems to work as expected 👍
Thank you for your assistance.
Not sure if you want to keep this issue open? I still believe that DD_TRACE_REMOVE_AUTOINSTRUMENTATION_ORPHANS should be removing the singular PDO spans, but the workaround above works fine.
Confirming setting DD_TRACE_SAMPLING_RULES is working as expected in our system.
The queue worker runs and doesn't report PDO spans every time it checks the database for a new job, and spans are correctly still recorded when a job is processing.
Hey @stewartmalik :wave:
Happy to hear that the workaround addressed your issue :-)
Not sure if you want to keep this issue open? I still believe that DD_TRACE_REMOVE_AUTOINSTRUMENTATION_ORPHANS should be removing the singular PDO spans, but the workaround above works fine.
Yes. DD_TRACE_REMOVE_AUTOINSTRUMENTATION_ORPHANS should also remove these singular PDO spans so that no further configuration is needed.
Could you please confirm with me that the following would be the list of the operation names to be removed?
PDOStatement.execute
PDO.commit
PDO.prepare
PDO.__construct
PDO.exec
Thanks! 😃
Hi @stewartmalik We've just released version 1.2.0, which fixes this issue.