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

Has DataDog logger been successfully initialized / has a valid API token? #2611

Open
monsieurnebo opened this issue Feb 16, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@monsieurnebo
Copy link

Hello,

Context

While implementing the DataDog logger (@datadog/browser-logs), I'm trying to make sure that it has been successfully initialized with a valid API token.

What I tried

From my understanding:

  • The DD logger will initialized with or without a valid token
  • It has no internal way of providing this info (e.g. app_id like DD rum, isInitialized, ...)

The only way of getting the info seems to be the failing logging query resulting of a wrong token... Which is not really helping me.

The question

Did I miss something in the doc & issues regarding this topic? Is there a way of getting this information?

If not, wouldn't it be useful to provide this info somehow? What do you think?

@amortemousque
Copy link
Contributor

Hello @monsieurnebo,
On the client side the browser SDK only check if the clientToken is provided and if not display a console error:
Client Token is not configured, we will not send any data. The client token validity is done on the backend side and if not valid the requests to the Datadog intake will fail with 403 status code.
Can you elaborate on you context and what behaviours or APIs you are expecting?

@monsieurnebo
Copy link
Author

monsieurnebo commented Feb 21, 2024

Hello @amortemousque , thanks for your answer.

So there will be no initialization error if a clientToken is indeed passed but is invalid?

My "context" is to make sure that my production logger is up & running (including a valid token).
I would expect a console error in this scenario, to avoid a silent failing logger (before calling a log method, straight at the init).

@amortemousque
Copy link
Contributor

amortemousque commented Feb 21, 2024

Hello @monsieurnebo,
We understand that a console error could be more convenient than looking at the 403. We will keep it in mind. In the meantime, if you want to ensure that logs are still collected on your prod environment, you could create a monitor to alert you in case your ingested logs suddenly drop.

@monsieurnebo
Copy link
Author

monsieurnebo commented Feb 22, 2024

For instance, here is what Google Map is returning in such a case:

Google Maps JavaScript API error: InvalidKeyMapError
https://developers.google.com/maps/documentation/javascript/error-messages#invalid-key-map-error

Something similar would be neat, making things explicit (without having to create some custom monitor for that).

@amortemousque amortemousque added enhancement New feature or request and removed need-info labels Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants