web3.unity icon indicating copy to clipboard operation
web3.unity copied to clipboard

[V2] DataDog class

Open LuaxY opened this issue 2 years ago • 1 comments

To be able to send internal logs inside the SDK v2 (so that we're not just relying on the API for metrics, since the API will be going away), we need a class to submit the logs to DataDogs API.

The code should be placed in Web3Unity/Scripts/Library/Ethers/InternalLogs/DataDog.cs in v2-beta branch. Inspiration can be taken from PostHog class.

The class can take two arguments, the API key and the base URL. The default base URL is: https://http-intake.logs.datadoghq.com

A method Log (or similar) could take arguments like log level (enum?), and a message.

Here is the documentation and an example of CURL command to send the request:

https://docs.datadoghq.com/api/latest/logs/?code-lang=curl#send-logs

curl -X POST "https://http-intake.logs.datadoghq.com/api/v2/logs" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
[
  {
    "ddsource": "nginx",
    "ddtags": "env:staging,version:5.1",
    "hostname": "i-012345678",
    "message": "2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World",
    "service": "payment"
  }
]
EOF

To test the class, we could send some logs to DataDog and check if everything is correctly ingested.

LuaxY avatar Aug 17 '22 18:08 LuaxY

Putting this on the backburner for now.

alexvotofuture avatar Oct 03 '22 15:10 alexvotofuture

Should this somehow be tied into registration? Need coordination between @KBryan and @sneakzttv

alexvotofuture avatar Oct 21 '22 15:10 alexvotofuture

Also need tests for this to make sure we're logging correctly.

alexvotofuture avatar Oct 21 '22 15:10 alexvotofuture

This will be first priority next week for @KBryan

alexvotofuture avatar Oct 21 '22 15:10 alexvotofuture

We need to figure out how to provide the Datadog key to the Logger class.

Options: Bake it into a DLL - pros: Simple Cons: Extractable by the determined developer @sneakzttv suggested converting to some form of Binary serialization and then decoding in runtime

FSM1 avatar Nov 03 '22 15:11 FSM1

doable yes :D

sneakzttv avatar Nov 03 '22 16:11 sneakzttv