This answer suggests that you can access the data source instance using the getDatasourceSrv:
Would that work for your use case?