github.com/matrixorigin/matrixone@v0.7.0/pkg/util/trace/type.go (about) 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 // Portions of this file are additionally subject to the following 16 // copyright. 17 // 18 // Copyright (C) 2022 Matrix Origin. 19 // 20 // Modified the behavior and the interface of the step. 21 22 package trace 23 24 import "context" 25 26 type TracerProvider interface { 27 Tracer(instrumentationName string, opts ...TracerOption) Tracer 28 } 29 30 type Tracer interface { 31 // Start creates a span and a context.Context containing the newly-created span. 32 Start(ctx context.Context, spanName string, opts ...SpanOption) (context.Context, Span) 33 // Debug creates a span only with DebugMode 34 Debug(ctx context.Context, spanName string, opts ...SpanOption) (context.Context, Span) 35 // IsEnable return true, means do record 36 IsEnable() bool 37 } 38 39 type Span interface { 40 // End completes the Span. The Span is considered complete and ready to be 41 // delivered through the rest of the telemetry pipeline after this method 42 // is called. Therefore, updates to the Span are not allowed after this 43 // method has been called. 44 End(options ...SpanEndOption) 45 46 // SpanContext returns the SpanContext of the Span. The returned SpanContext 47 // is usable even after the End method has been called for the Span. 48 SpanContext() SpanContext 49 50 ParentSpanContext() SpanContext 51 } 52 53 type SpanProcessor interface { 54 OnStart(ctx context.Context, s Span) 55 OnEnd(s Span) 56 Shutdown(ctx context.Context) error 57 } 58 59 type IDGenerator interface { 60 NewIDs() (TraceID, SpanID) 61 NewSpanID() SpanID 62 }