~shabbyrobe/dogdump

f9e041abf8064d5e76fdb3c1c12c0311da353365 — Blake Williams 7 months ago 611af48
Add some error checks, remove stutter from span name
2 files changed, 11 insertions(+), 2 deletions(-)

M doggotel/trace.go
M doginflux/writer.go
M doggotel/trace.go => doggotel/trace.go +3 -0
@@ 51,6 51,9 @@ func MarshalTrace(o *JSONTrace) ([]byte, error) {
}

func otlpName(span dogproto.Span) string {
	if span.Resource == span.Name {
		return span.Name
	}
	return fmt.Sprintf("%s/%s", span.Resource, span.Name)
}


M doginflux/writer.go => doginflux/writer.go +8 -2
@@ 50,7 50,10 @@ func NewMetricWriterV2(baseURL string, token Token, org string, bucket string, o
}

func (mw *MetricWriterV2) url(s string, qs url.Values) string {
	u, _ := url.Parse(mw.baseURL)
	u, err := url.Parse(mw.baseURL)
	if err != nil {
		panic(err)
	}
	u.Path = path.Join(u.Path, "/api/v2/write")
	u.RawQuery = qs.Encode()
	return u.String()


@@ 88,7 91,10 @@ func (mw *MetricWriterV2) WriteMetrics(ctx context.Context, metrics []dogproto.M
	defer rs.Body.Close()

	if rs.StatusCode != 200 && rs.StatusCode != 204 {
		bts, _ := io.ReadAll(rs.Body)
		bts, err := io.ReadAll(rs.Body)
		if err != nil {
			return err
		}
		if len(bts) > 1000 {
			bts = bts[:1000]
		}