web3.unity
web3.unity copied to clipboard
[V2] DataDog class
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.
Putting this on the backburner for now.
Should this somehow be tied into registration? Need coordination between @KBryan and @sneakzttv
Also need tests for this to make sure we're logging correctly.
This will be first priority next week for @KBryan
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
doable yes :D