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

Get multiple pg instances showing up as separate services #977

Closed
patrykwojtynski opened this issue Jun 5, 2020 · 2 comments · Fixed by #1110
Closed

Get multiple pg instances showing up as separate services #977

patrykwojtynski opened this issue Jun 5, 2020 · 2 comments · Fixed by #1110

Comments

@patrykwojtynski
Copy link

patrykwojtynski commented Jun 5, 2020

Hey, I'm using pg-promise and I'm facing issue with using two databases, similar to #317. I have two separate connections and no matter what I do it's always under the same service name ${tracer._service}-postgres. So far I was trying to do:
DD_SERVICE_NAME = 'api'
first ddPgServiceName = 'main'
second ddPgServiceName = 'micro'

  const initOptions = {
    promiseLib: Promise,
    extend: obj => {
      obj.traceableOne = (query, values) => {
        const service = tracer._tracer._service
        tracer._tracer._service = ddPgServiceName
        
        one = obj.one(query, values)

        tracer._tracer._service = service

        return one
      }
    }

But in DD it's always api-postgres (also it wraps tcp and dns services which is bad and should be only focused on query)

Any idea what I'm missing? I know that it should be done as close as possible to query function.

@rochdev
Copy link
Member

rochdev commented Jun 6, 2020

In order to do this without relying on the tracer internals, the best approach would be to add support for this directly to the tracer. We've been thinking about adding a splitByInstance option to database integrations. Are main and micro the instance names? Would that fit your use case?

@patrykwojtynski
Copy link
Author

It would be awesome to splitByInstance and pass true or object with 'instanceName': 'newServiceName'. This way it will allow to bind all services properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants