| 93 | } |
| 94 | |
| 95 | func (a *PusherAppender) Commit() error { |
| 96 | a.totalWrites.Inc() |
| 97 | |
| 98 | req := cortexpb.ToWriteRequest(a.labels, a.samples, nil, nil, cortexpb.RULE) |
| 99 | req.AddHistogramTimeSeries(a.histogramLabels, a.histograms) |
| 100 | |
| 101 | // Set DiscardOutOfOrder flag if requested via AppendOptions |
| 102 | if a.opts != nil && a.opts.DiscardOutOfOrder { |
| 103 | req.DiscardOutOfOrder = true |
| 104 | } |
| 105 | |
| 106 | // Since a.pusher is distributor, client.ReuseSlice will be called in a.pusher.Push. |
| 107 | // We shouldn't call client.ReuseSlice here. |
| 108 | _, err := a.pusher.Push(user.InjectOrgID(a.ctx, a.userID), req) |
| 109 | if err != nil { |
| 110 | // Don't report errors that ended with 4xx HTTP status code (series limits, duplicate samples, out of order, etc.) |
| 111 | if resp, ok := httpgrpc.HTTPResponseFromError(err); !ok || resp.Code/100 == 5 { |
| 112 | a.failedWrites.Inc() |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | a.labels = nil |
| 117 | a.samples = nil |
| 118 | a.histogramLabels = nil |
| 119 | a.histograms = nil |
| 120 | return err |
| 121 | } |
| 122 | |
| 123 | func (a *PusherAppender) UpdateMetadata(_ storage.SeriesRef, _ labels.Labels, _ metadata.Metadata) (storage.SeriesRef, error) { |
| 124 | return 0, errors.New("update metadata unsupported") |