-
Notifications
You must be signed in to change notification settings - Fork 0
/
writer_http_datadog.go
35 lines (29 loc) · 1.07 KB
/
writer_http_datadog.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright © 2021. All rights reserved.
// Author: Ilya Stroy.
// Contacts: iyuryevich@pm.me, https://github.com/qioalice
// License: https://opensource.org/licenses/MIT
package ekalog_writer_http
import (
"github.com/valyala/fasthttp"
)
//noinspection GoSnakeCaseUsage
const (
DATADOG_ADDR_US = "https://http-intake.logs.datadoghq.com/v1/input"
DATADOG_ADDR_EU = "https://http-intake.logs.datadoghq.eu/v1/input"
)
// UseProviderDataDog setups CI_WriterHttp for DataDog log service provider
// ( https://www.datadoghq.com/ ).
//
// You MUST specify 'addr' as desired DataDog's HTTP addr (you may use predefined
// constants DATADOG_ADDR_US, DATADOG_ADDR_EU) or use your own and DataDog
// service's token as 'token'.
//
// Nil safe. There is no-op if CI_WriterHttp already initialized.
func (dw *CI_WriterHttp) UseProviderDataDog(addr, token string) *CI_WriterHttp {
cb1 := func(req *fasthttp.Request) {
req.SetRequestURI(addr)
req.Header.SetContentType("application/json")
req.Header.Set("DD-API-KEY", token)
}
return dw.AddBeforeAfterBetweenS("[],").UseProviderManual(cb1)
}