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

Method MongoDB\Driver Monitoring\CommandStartedEvent::getService()is deprecated #1467

Open
runtu666 opened this issue Jan 6, 2025 · 6 comments · May be fixed by open-telemetry/opentelemetry-php-contrib#324
Labels
bug Something isn't working

Comments

@runtu666
Copy link

runtu666 commented Jan 6, 2025

Method MongoDB\Driver Monitoring\CommandStartedEvent::getService()is deprecated by mongo ext 2.0

@runtu666 runtu666 added the bug Something isn't working label Jan 6, 2025
@runtu666
Copy link
Author

runtu666 commented Jan 6, 2025

@brettmc
Copy link
Collaborator

brettmc commented Jan 7, 2025

...the instrumentation also uses Server::getInfo() for some custom mongo trace attributes, which doesn't have a clear replacement.

@runtu666
Copy link
Author

runtu666 commented Jan 7, 2025

@brettmc Yes, I originally wanted to file a PR, but I found that I couldn't handle getInfo, so I raised an issue.

@brettmc
Copy link
Collaborator

brettmc commented Jan 7, 2025

Yes, I originally wanted to file a PR, but I found that I couldn't handle getInfo, so I raised an issue.

Could you create an issue in the upstream mongodb repo to find out whether getInfo will exist in the next version? It may have been overlooked, but if it's going away then we'll just need to drop support for those extra trace attributes.

If you do create an issue, can you link to it from this issue?

@runtu666
Copy link
Author

runtu666 commented Jan 7, 2025

php/doc-en#4367
@brettmc

@jmikola
Copy link

jmikola commented Jan 7, 2025

@brettmc: Copying in my response from php/doc-en#4367 (comment)

The related JIRA ticket is PHPC-2442. The getServer() method was only deprecated in 1.20 alongside the introduction of the getHost() and getPort() methods. PHPC-1741 tracks the removal of getServer(), which was only applied to the 2.0 branch.

There is no direct replacement for accessing a MongoDB\Driver\Server object from an event object; however, you can obtain a Server object by filtering the results of MongoDB\Driver\Manager::getServers() by the corresponding host and port.

If the Server object was only used for tracing, I would suggest just using the host and port going forward. The getInfo() method returned the entire hello command response from the driver's last monitoring call, which is likely way more data than most users would need or make use of.

I'm not familiar with how this library interacts with the driver, but if you need details about server connections and cluster topology that would be better collected via an SDAM subscriber. The hello response is accessible from both ServerHeartbeatSucceededEvent and ServerChangedEvent (via ServerDescription::getHelloResponse()). Since multiple heartbeats could occur over the course of a script, ServerChangedEvent is likely the more sensible event to log if you wish to minimize noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants