Skip to content

Commit

Permalink
Add "peer.service" semantic to standard attributes (#898)
Browse files Browse the repository at this point in the history
Co-authored-by: Liz Fong-Jones <lizf@honeycomb.io>
  • Loading branch information
evantorrie and lizthegrey committed Jul 6, 2020
1 parent 8d1f448 commit bd1e174
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions api/standard/trace.go
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion example/http/client/client.go
Expand Up @@ -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"
Expand Down Expand Up @@ -80,7 +82,8 @@ func main() {
_ = res.Body.Close()

return err
})
},
trace.WithAttributes(standard.PeerServiceKey.String("ExampleService")))

if err != nil {
panic(err)
Expand Down
5 changes: 4 additions & 1 deletion example/http/server/server.go
Expand Up @@ -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"
)

Expand All @@ -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)
}
Expand Down

0 comments on commit bd1e174

Please sign in to comment.