(endpoint string, timeout time.Duration, retries, batchSize int, flushEvery time.Duration)
| 29 | } |
| 30 | |
| 31 | func NewOTLPHTTPExporter(endpoint string, timeout time.Duration, retries, batchSize int, flushEvery time.Duration) *OTLPHTTPExporter { |
| 32 | if timeout <= 0 { |
| 33 | timeout = 1 * time.Second |
| 34 | } |
| 35 | if retries < 0 { |
| 36 | retries = 0 |
| 37 | } |
| 38 | if batchSize <= 0 { |
| 39 | batchSize = 10 |
| 40 | } |
| 41 | if flushEvery <= 0 { |
| 42 | flushEvery = 1 * time.Second |
| 43 | } |
| 44 | return &OTLPHTTPExporter{ |
| 45 | endpoint: endpoint, |
| 46 | httpClient: &http.Client{ |
| 47 | Timeout: timeout, |
| 48 | }, |
| 49 | retries: retries, |
| 50 | batchSize: batchSize, |
| 51 | flushEvery: flushEvery, |
| 52 | buffer: map[string][]map[string]any{ |
| 53 | "metrics": {}, |
| 54 | "events": {}, |
| 55 | "traces": {}, |
| 56 | }, |
| 57 | lastFlush: time.Now(), |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func (e *OTLPHTTPExporter) EmitMetric(name string, value float64, labels map[string]string) { |
| 62 | e.enqueue("metrics", map[string]any{ |
no outgoing calls