@@ -54,15 +54,13 @@ func (c *client) pushMetricsData(
54
54
if err != nil {
55
55
return exporterhelper .NumTimeSeries (md ), consumererror .Permanent (err )
56
56
}
57
- if len (splunkDataPoints ) == 0 {
58
- return numDroppedTimeseries , nil
59
- }
60
57
61
58
body , compressed , err := encodeBody (& c .zippers , splunkDataPoints , c .config .DisableCompression )
62
59
if err != nil {
63
60
return exporterhelper .NumTimeSeries (md ), consumererror .Permanent (err )
64
61
}
65
62
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.
66
64
req , err := http .NewRequest ("POST" , c .url .String (), body )
67
65
if err != nil {
68
66
return exporterhelper .NumTimeSeries (md ), consumererror .Permanent (err )
@@ -96,69 +94,6 @@ func (c *client) pushMetricsData(
96
94
return numDroppedTimeseries , nil
97
95
}
98
96
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
-
162
97
func encodeBody (zippers * sync.Pool , dps []* splunkMetric , disableCompression bool ) (bodyReader io.Reader , compressed bool , err error ) {
163
98
buf := new (bytes.Buffer )
164
99
encoder := json .NewEncoder (buf )
0 commit comments