Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Export spans to hec (#359)" #375

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 1 addition & 66 deletions exporter/splunkhecexporter/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@ func (c *client) pushMetricsData(
if err != nil {
return exporterhelper.NumTimeSeries(md), consumererror.Permanent(err)
}
if len(splunkDataPoints) == 0 {
return numDroppedTimeseries, nil
}

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

// 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.
req, err := http.NewRequest("POST", c.url.String(), body)
if err != nil {
return exporterhelper.NumTimeSeries(md), consumererror.Permanent(err)
Expand Down Expand Up @@ -96,69 +94,6 @@ func (c *client) pushMetricsData(
return numDroppedTimeseries, nil
}

func (c *client) pushTraceData(
ctx context.Context,
td consumerdata.TraceData,
) (droppedSpans int, err error) {
c.wg.Add(1)
defer c.wg.Done()

splunkEvents, numDroppedSpans := traceDataToSplunk(c.logger, td, c.config)
if len(splunkEvents) == 0 {
return numDroppedSpans, nil
}

body, compressed, err := encodeBodyEvents(&c.zippers, splunkEvents, c.config.DisableCompression)
if err != nil {
return len(td.Spans), consumererror.Permanent(err)
}

req, err := http.NewRequest("POST", c.url.String(), body)
if err != nil {
return len(td.Spans), consumererror.Permanent(err)
}

for k, v := range c.headers {
req.Header.Set(k, v)
}

if compressed {
req.Header.Set("Content-Encoding", "gzip")
}

resp, err := c.client.Do(req)
if err != nil {
return len(td.Spans), err
}

io.Copy(ioutil.Discard, resp.Body)
resp.Body.Close()

// Splunk accepts all 2XX codes.
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
err = fmt.Errorf(
"HTTP %d %q",
resp.StatusCode,
http.StatusText(resp.StatusCode))
return len(td.Spans), err
}

return numDroppedSpans, nil
}

func encodeBodyEvents(zippers *sync.Pool, evs []*splunkEvent, disableCompression bool) (bodyReader io.Reader, compressed bool, err error) {
buf := new(bytes.Buffer)
encoder := json.NewEncoder(buf)
for _, e := range evs {
err := encoder.Encode(e)
if err != nil {
return nil, false, err
}
buf.WriteString("\r\n\r\n")
}
return getReader(zippers, buf, disableCompression)
}

func encodeBody(zippers *sync.Pool, dps []*splunkMetric, disableCompression bool) (bodyReader io.Reader, compressed bool, err error) {
buf := new(bytes.Buffer)
encoder := json.NewEncoder(buf)
Expand Down
306 changes: 0 additions & 306 deletions exporter/splunkhecexporter/client_test.go

This file was deleted.

Loading