gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

snapshot.go (4210B)


      1 // Copyright The OpenTelemetry 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 
     15 package trace // import "go.opentelemetry.io/otel/sdk/trace"
     16 
     17 import (
     18 	"time"
     19 
     20 	"go.opentelemetry.io/otel/attribute"
     21 	"go.opentelemetry.io/otel/sdk/instrumentation"
     22 	"go.opentelemetry.io/otel/sdk/resource"
     23 	"go.opentelemetry.io/otel/trace"
     24 )
     25 
     26 // snapshot is an record of a spans state at a particular checkpointed time.
     27 // It is used as a read-only representation of that state.
     28 type snapshot struct {
     29 	name                  string
     30 	spanContext           trace.SpanContext
     31 	parent                trace.SpanContext
     32 	spanKind              trace.SpanKind
     33 	startTime             time.Time
     34 	endTime               time.Time
     35 	attributes            []attribute.KeyValue
     36 	events                []Event
     37 	links                 []Link
     38 	status                Status
     39 	childSpanCount        int
     40 	droppedAttributeCount int
     41 	droppedEventCount     int
     42 	droppedLinkCount      int
     43 	resource              *resource.Resource
     44 	instrumentationScope  instrumentation.Scope
     45 }
     46 
     47 var _ ReadOnlySpan = snapshot{}
     48 
     49 func (s snapshot) private() {}
     50 
     51 // Name returns the name of the span.
     52 func (s snapshot) Name() string {
     53 	return s.name
     54 }
     55 
     56 // SpanContext returns the unique SpanContext that identifies the span.
     57 func (s snapshot) SpanContext() trace.SpanContext {
     58 	return s.spanContext
     59 }
     60 
     61 // Parent returns the unique SpanContext that identifies the parent of the
     62 // span if one exists. If the span has no parent the returned SpanContext
     63 // will be invalid.
     64 func (s snapshot) Parent() trace.SpanContext {
     65 	return s.parent
     66 }
     67 
     68 // SpanKind returns the role the span plays in a Trace.
     69 func (s snapshot) SpanKind() trace.SpanKind {
     70 	return s.spanKind
     71 }
     72 
     73 // StartTime returns the time the span started recording.
     74 func (s snapshot) StartTime() time.Time {
     75 	return s.startTime
     76 }
     77 
     78 // EndTime returns the time the span stopped recording. It will be zero if
     79 // the span has not ended.
     80 func (s snapshot) EndTime() time.Time {
     81 	return s.endTime
     82 }
     83 
     84 // Attributes returns the defining attributes of the span.
     85 func (s snapshot) Attributes() []attribute.KeyValue {
     86 	return s.attributes
     87 }
     88 
     89 // Links returns all the links the span has to other spans.
     90 func (s snapshot) Links() []Link {
     91 	return s.links
     92 }
     93 
     94 // Events returns all the events that occurred within in the spans
     95 // lifetime.
     96 func (s snapshot) Events() []Event {
     97 	return s.events
     98 }
     99 
    100 // Status returns the spans status.
    101 func (s snapshot) Status() Status {
    102 	return s.status
    103 }
    104 
    105 // InstrumentationScope returns information about the instrumentation
    106 // scope that created the span.
    107 func (s snapshot) InstrumentationScope() instrumentation.Scope {
    108 	return s.instrumentationScope
    109 }
    110 
    111 // InstrumentationLibrary returns information about the instrumentation
    112 // library that created the span.
    113 func (s snapshot) InstrumentationLibrary() instrumentation.Library {
    114 	return s.instrumentationScope
    115 }
    116 
    117 // Resource returns information about the entity that produced the span.
    118 func (s snapshot) Resource() *resource.Resource {
    119 	return s.resource
    120 }
    121 
    122 // DroppedAttributes returns the number of attributes dropped by the span
    123 // due to limits being reached.
    124 func (s snapshot) DroppedAttributes() int {
    125 	return s.droppedAttributeCount
    126 }
    127 
    128 // DroppedLinks returns the number of links dropped by the span due to limits
    129 // being reached.
    130 func (s snapshot) DroppedLinks() int {
    131 	return s.droppedLinkCount
    132 }
    133 
    134 // DroppedEvents returns the number of events dropped by the span due to
    135 // limits being reached.
    136 func (s snapshot) DroppedEvents() int {
    137 	return s.droppedEventCount
    138 }
    139 
    140 // ChildSpanCount returns the count of spans that consider the span a
    141 // direct parent.
    142 func (s snapshot) ChildSpanCount() int {
    143 	return s.childSpanCount
    144 }