1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3 4 package otelhttp // import "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
5 6 import (
7 "net/http"
8 9 "go.opentelemetry.io/otel/attribute"
10 "go.opentelemetry.io/otel/trace"
11 )
12 13 // Attribute keys that can be added to a span.
14 const (
15 ReadBytesKey = attribute.Key("http.read_bytes") // if anything was read from the request body, the total number of bytes read
16 ReadErrorKey = attribute.Key("http.read_error") // If an error occurred while reading a request, the string of the error (io.EOF is not recorded)
17 WroteBytesKey = attribute.Key("http.wrote_bytes") // if anything was written to the response writer, the total number of bytes written
18 WriteErrorKey = attribute.Key("http.write_error") // if an error occurred while writing a reply, the string of the error (io.EOF is not recorded)
19 )
20 21 // Filter is a predicate used to determine whether a given http.request should
22 // be traced. A Filter must return true if the request should be traced.
23 type Filter func(*http.Request) bool
24 25 func newTracer(tp trace.TracerProvider) trace.Tracer {
26 return tp.Tracer(ScopeName, trace.WithInstrumentationVersion(Version()))
27 }
28