Skip to content

Commit 891b1bc

Browse files
Revert "Export spans to hec (open-telemetry#359)" (open-telemetry#375)
This reverts commit 625973a. Reverting because this fails the build https://app.circleci.com/pipelines/github/open-telemetry/opentelemetry-collector-contrib/1563/workflows/e7c13c24-34ac-4fa6-85e9-da3fafb0fbbc and we have to make a release now.
1 parent 625973a commit 891b1bc

File tree

10 files changed

+24
-617
lines changed

10 files changed

+24
-617
lines changed

exporter/splunkhecexporter/client.go

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,13 @@ func (c *client) pushMetricsData(
5454
if err != nil {
5555
return exporterhelper.NumTimeSeries(md), consumererror.Permanent(err)
5656
}
57-
if len(splunkDataPoints) == 0 {
58-
return numDroppedTimeseries, nil
59-
}
6057

6158
body, compressed, err := encodeBody(&c.zippers, splunkDataPoints, c.config.DisableCompression)
6259
if err != nil {
6360
return exporterhelper.NumTimeSeries(md), consumererror.Permanent(err)
6461
}
6562

63+
// TODO the client sends synchronously data as of now. It would make more sense to buffer data coming in, and send batches as supported by Splunk. To batch effectively, a ring buffer approach would work well - based on time and number of messages queued.
6664
req, err := http.NewRequest("POST", c.url.String(), body)
6765
if err != nil {
6866
return exporterhelper.NumTimeSeries(md), consumererror.Permanent(err)
@@ -96,69 +94,6 @@ func (c *client) pushMetricsData(
9694
return numDroppedTimeseries, nil
9795
}
9896

99-
func (c *client) pushTraceData(
100-
ctx context.Context,
101-
td consumerdata.TraceData,
102-
) (droppedSpans int, err error) {
103-
c.wg.Add(1)
104-
defer c.wg.Done()
105-
106-
splunkEvents, numDroppedSpans := traceDataToSplunk(c.logger, td, c.config)
107-
if len(splunkEvents) == 0 {
108-
return numDroppedSpans, nil
109-
}
110-
111-
body, compressed, err := encodeBodyEvents(&c.zippers, splunkEvents, c.config.DisableCompression)
112-
if err != nil {
113-
return len(td.Spans), consumererror.Permanent(err)
114-
}
115-
116-
req, err := http.NewRequest("POST", c.url.String(), body)
117-
if err != nil {
118-
return len(td.Spans), consumererror.Permanent(err)
119-
}
120-
121-
for k, v := range c.headers {
122-
req.Header.Set(k, v)
123-
}
124-
125-
if compressed {
126-
req.Header.Set("Content-Encoding", "gzip")
127-
}
128-
129-
resp, err := c.client.Do(req)
130-
if err != nil {
131-
return len(td.Spans), err
132-
}
133-
134-
io.Copy(ioutil.Discard, resp.Body)
135-
resp.Body.Close()
136-
137-
// Splunk accepts all 2XX codes.
138-
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
139-
err = fmt.Errorf(
140-
"HTTP %d %q",
141-
resp.StatusCode,
142-
http.StatusText(resp.StatusCode))
143-
return len(td.Spans), err
144-
}
145-
146-
return numDroppedSpans, nil
147-
}
148-
149-
func encodeBodyEvents(zippers *sync.Pool, evs []*splunkEvent, disableCompression bool) (bodyReader io.Reader, compressed bool, err error) {
150-
buf := new(bytes.Buffer)
151-
encoder := json.NewEncoder(buf)
152-
for _, e := range evs {
153-
err := encoder.Encode(e)
154-
if err != nil {
155-
return nil, false, err
156-
}
157-
buf.WriteString("\r\n\r\n")
158-
}
159-
return getReader(zippers, buf, disableCompression)
160-
}
161-
16297
func encodeBody(zippers *sync.Pool, dps []*splunkMetric, disableCompression bool) (bodyReader io.Reader, compressed bool, err error) {
16398
buf := new(bytes.Buffer)
16499
encoder := json.NewEncoder(buf)

exporter/splunkhecexporter/client_test.go

Lines changed: 0 additions & 306 deletions
This file was deleted.

0 commit comments

Comments
 (0)