Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
VinozzZ committed Aug 9, 2024
1 parent 38cdcc9 commit e84bf0e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
7 changes: 0 additions & 7 deletions instrumentation/net/http/otelhttp/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ const (
WriteErrorKey = attribute.Key("http.write_error") // if an error occurred while writing a reply, the string of the error (io.EOF is not recorded)
)

// Client HTTP metrics.
const (
clientRequestSize = "http.client.request.size" // Outgoing request bytes total
clientResponseSize = "http.client.response.size" // Outgoing response bytes total
clientDuration = "http.client.duration" // Outgoing end to end duration, milliseconds
)

// Filter is a predicate used to determine whether a given http.request should
// be traced. A Filter must return true if the request should be traced.
type Filter func(*http.Request) bool
Expand Down
6 changes: 0 additions & 6 deletions instrumentation/net/http/otelhttp/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ func (h *middleware) configure(c *config) {
h.semconv = semconv.NewHTTPServer(c.Meter)
}

func handleErr(err error) {
if err != nil {
otel.Handle(err)
}
}

// serveHTTP sets up tracing and calls the given next http.Handler with the span
// context injected into the request context.
func (h *middleware) serveHTTP(w http.ResponseWriter, r *http.Request, next http.Handler) {
Expand Down
16 changes: 7 additions & 9 deletions instrumentation/net/http/otelhttp/internal/semconv/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ func NewHTTPServer(meter metric.Meter) HTTPServer {
type HTTPClient struct {
duplicate bool

meter metric.Meter
// old metrics
requestBytesCounter metric.Int64Counter
responseBytesCounter metric.Int64Counter
Expand Down Expand Up @@ -182,30 +181,30 @@ func (c HTTPClient) ErrorType(err error) attribute.KeyValue {
return attribute.KeyValue{}
}

type metricOpts struct {
type MetricOpts struct {
measurement metric.MeasurementOption
addOptions []metric.AddOption
}

func (o metricOpts) MeasurementOption() metric.MeasurementOption {
func (o MetricOpts) MeasurementOption() metric.MeasurementOption {
return o.measurement
}

func (o metricOpts) AddOptions() []metric.AddOption {
func (o MetricOpts) AddOptions() []metric.AddOption {
return o.addOptions
}

func (c HTTPClient) MetricOptions(ma MetricAttributes) metricOpts {
func (c HTTPClient) MetricOptions(ma MetricAttributes) MetricOpts {
attributes := oldHTTPClient{}.MetricAttributes(ma.Req, ma.StatusCode, ma.AdditionalAttributes)
// TODO: Duplicate Metrics
set := metric.WithAttributeSet(attribute.NewSet(attributes...))
return metricOpts{
return MetricOpts{
measurement: set,
addOptions: []metric.AddOption{set},
}
}

func (s HTTPClient) RecordMetrics(ctx context.Context, md MetricData, opts metricOpts) {
func (s HTTPClient) RecordMetrics(ctx context.Context, md MetricData, opts MetricOpts) {
if s.requestBytesCounter == nil || s.latencyMeasure == nil {
// This will happen if an HTTPClient{} is used insted of NewHTTPClient().
return
Expand All @@ -223,7 +222,6 @@ func (s HTTPClient) RecordResponseSize(ctx context.Context, responseData int64,
return
}

s.responseBytesCounter.Add(ctx, int64(responseData), opts...)
s.responseBytesCounter.Add(ctx, responseData, opts...)
// TODO: Duplicate Metrics

}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func TestHTTPClientDoesNotPanic(t *testing.T) {
})
})
}

}

type testInst struct {
Expand Down

0 comments on commit e84bf0e

Please sign in to comment.