span.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2022 The OpenZipkin Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package zipkin
  15. import (
  16. "time"
  17. "github.com/openzipkin/zipkin-go/model"
  18. )
  19. // Span interface as returned by Tracer.StartSpan()
  20. type Span interface {
  21. // Context returns the Span's SpanContext.
  22. Context() model.SpanContext
  23. // SetName updates the Span's name.
  24. SetName(string)
  25. // SetRemoteEndpoint updates the Span's Remote Endpoint.
  26. SetRemoteEndpoint(*model.Endpoint)
  27. // Annotate adds a timed event to the Span.
  28. Annotate(time.Time, string)
  29. // Tag sets Tag with given key and value to the Span. If key already exists in
  30. // the Span the value will be overridden except for error tags where the first
  31. // value is persisted.
  32. Tag(string, string)
  33. // Finish the Span and send to Reporter. If DelaySend option was used at
  34. // Span creation time, Finish will not send the Span to the Reporter. It then
  35. // becomes the user's responsibility to get the Span reported (by using
  36. // span.Flush).
  37. Finish()
  38. // Finish the Span with duration and send to Reporter. If DelaySend option was used at
  39. // Span creation time, FinishedWithDuration will not send the Span to the Reporter. It then
  40. // becomes the user's responsibility to get the Span reported (by using
  41. // span.Flush).
  42. FinishedWithDuration(duration time.Duration)
  43. // Flush the Span to the Reporter (regardless of being finished or not).
  44. // This can be used if the DelaySend SpanOption was set or when dealing with
  45. // one-way RPC tracing where duration might not be measured.
  46. Flush()
  47. }