1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-30 21:20:04 +02:00

Add "peer.service" semantic to standard attributes (#898)

Co-authored-by: Liz Fong-Jones <lizf@honeycomb.io>
This commit is contained in:
ET 2020-07-06 08:36:49 -07:00 committed by GitHub
parent 8d1f448ade
commit bd1e174e60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 2 deletions

View File

@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [Unreleased]
### Added
- Add `peer.service` semantic attribute. (#898)
### Changed
- Update `CONTRIBUTING.md` to ask for updates to `CHANGELOG.md` with each pull request. (#879)

View File

@ -50,6 +50,13 @@ var (
NetTransportOther = NetTransportKey.String("other")
)
// General attribute keys for spans.
const (
// Service name of the remote service. Should equal the actual
// `service.name` resource attribute of the remote service, if any.
PeerServiceKey = kv.Key("peer.service")
)
// Standard attribute keys used to identify an authorized enduser.
const (
// Username or the client identifier extracted from the access token or

View File

@ -22,6 +22,8 @@ import (
"log"
"go.opentelemetry.io/otel/api/kv"
"go.opentelemetry.io/otel/api/standard"
"go.opentelemetry.io/otel/api/trace"
"net/http"
"time"
@ -80,7 +82,8 @@ func main() {
_ = res.Body.Close()
return err
})
},
trace.WithAttributes(standard.PeerServiceKey.String("ExampleService")))
if err != nil {
panic(err)

View File

@ -21,9 +21,11 @@ import (
"go.opentelemetry.io/otel/api/correlation"
"go.opentelemetry.io/otel/api/global"
"go.opentelemetry.io/otel/api/standard"
"go.opentelemetry.io/otel/api/trace"
"go.opentelemetry.io/otel/exporters/trace/stdout"
"go.opentelemetry.io/otel/instrumentation/httptrace"
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)
@ -38,7 +40,8 @@ func initTracer() {
// For the demonstration, use sdktrace.AlwaysSample sampler to sample all traces.
// In a production application, use sdktrace.ProbabilitySampler with a desired probability.
tp, err := sdktrace.NewProvider(sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}),
sdktrace.WithSyncer(exporter))
sdktrace.WithSyncer(exporter),
sdktrace.WithResource(resource.New(standard.ServiceNameKey.String("ExampleService"))))
if err != nil {
log.Fatal(err)
}