Merge remote-tracking branch 'upstream/v3' into v3
This commit is contained in:
		
							
								
								
									
										6
									
								
								.github/workflows/job_coverage.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/job_coverage.yml
									
									
									
									
										vendored
									
									
								
							| @@ -3,14 +3,16 @@ name: coverage | |||||||
| on: | on: | ||||||
|   push: |   push: | ||||||
|     branches: [ main, v3, v4 ] |     branches: [ main, v3, v4 ] | ||||||
|  |     paths-ignore: | ||||||
|  |       - '.github/**' | ||||||
|  |       - '.gitea/**' | ||||||
|   pull_request: |   pull_request: | ||||||
|     branches: [ main, v3, v4 ] |     branches: [ main, v3, v4 ] | ||||||
|   # Allows you to run this workflow manually from the Actions tab |  | ||||||
|   workflow_dispatch: |  | ||||||
|  |  | ||||||
| jobs: | jobs: | ||||||
|  |  | ||||||
|   build: |   build: | ||||||
|  |     if: github.server_url != 'https://github.com' | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|     steps: |     steps: | ||||||
|     - name: checkout code |     - name: checkout code | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								.github/workflows/job_lint.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.github/workflows/job_lint.yml
									
									
									
									
										vendored
									
									
								
							| @@ -3,10 +3,10 @@ name: lint | |||||||
| on: | on: | ||||||
|   pull_request: |   pull_request: | ||||||
|     types: [opened, reopened, synchronize] |     types: [opened, reopened, synchronize] | ||||||
|     branches: |     branches: [ master, v3, v4 ] | ||||||
|       - master |     paths-ignore: | ||||||
|       - v3 |       - '.github/**' | ||||||
|       - v4 |       - '.gitea/**' | ||||||
|  |  | ||||||
| jobs: | jobs: | ||||||
|   lint: |   lint: | ||||||
|   | |||||||
							
								
								
									
										13
									
								
								.github/workflows/job_test.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								.github/workflows/job_test.yml
									
									
									
									
										vendored
									
									
								
							| @@ -3,15 +3,12 @@ name: test | |||||||
| on: | on: | ||||||
|   pull_request: |   pull_request: | ||||||
|     types: [opened, reopened, synchronize] |     types: [opened, reopened, synchronize] | ||||||
|     branches: |     branches: [ master, v3, v4 ] | ||||||
|     - master |  | ||||||
|     - v3 |  | ||||||
|     - v4 |  | ||||||
|   push: |   push: | ||||||
|     branches: |     branches: [ master, v3, v4 ] | ||||||
|     - master |     paths-ignore: | ||||||
|     - v3 |       - '.github/**' | ||||||
|     - v4 |       - '.gitea/**' | ||||||
|  |  | ||||||
| jobs: | jobs: | ||||||
|   test: |   test: | ||||||
|   | |||||||
							
								
								
									
										13
									
								
								.github/workflows/job_tests.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								.github/workflows/job_tests.yml
									
									
									
									
										vendored
									
									
								
							| @@ -3,15 +3,12 @@ name: test | |||||||
| on: | on: | ||||||
|   pull_request: |   pull_request: | ||||||
|     types: [opened, reopened, synchronize] |     types: [opened, reopened, synchronize] | ||||||
|     branches: |     branches: [ master, v3, v4 ] | ||||||
|       - master |  | ||||||
|       - v3 |  | ||||||
|       - v4 |  | ||||||
|   push: |   push: | ||||||
|     branches: |     branches: [ master, v3, v4 ] | ||||||
|       - master |     paths-ignore: | ||||||
|       - v3 |       - '.github/**' | ||||||
|       - v4 |       - '.gitea/**' | ||||||
|  |  | ||||||
| jobs: | jobs: | ||||||
|   test: |   test: | ||||||
|   | |||||||
| @@ -46,6 +46,10 @@ func (s memoryStringer) String() string { | |||||||
| 	return s.s | 	return s.s | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (t *Tracer) Enabled() bool { | ||||||
|  | 	return t.opts.Enabled | ||||||
|  | } | ||||||
|  |  | ||||||
| func (t *Tracer) Flush(_ context.Context) error { | func (t *Tracer) Flush(_ context.Context) error { | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|   | |||||||
| @@ -18,6 +18,10 @@ func (t *noopTracer) Spans() []Span { | |||||||
| 	return t.spans | 	return t.spans | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (t *noopTracer) Enabled() bool { | ||||||
|  | 	return t.opts.Enabled | ||||||
|  | } | ||||||
|  |  | ||||||
| func (t *noopTracer) Start(ctx context.Context, name string, opts ...SpanOption) (context.Context, Span) { | func (t *noopTracer) Start(ctx context.Context, name string, opts ...SpanOption) (context.Context, Span) { | ||||||
| 	options := NewSpanOptions(opts...) | 	options := NewSpanOptions(opts...) | ||||||
| 	span := &noopSpan{ | 	span := &noopSpan{ | ||||||
|   | |||||||
| @@ -142,6 +142,8 @@ type Options struct { | |||||||
| 	Name string | 	Name string | ||||||
| 	// ContextAttrFuncs contains funcs that provides tracing | 	// ContextAttrFuncs contains funcs that provides tracing | ||||||
| 	ContextAttrFuncs []ContextAttrFunc | 	ContextAttrFuncs []ContextAttrFunc | ||||||
|  | 	// Enabled specify trace status | ||||||
|  | 	Enabled bool | ||||||
| } | } | ||||||
|  |  | ||||||
| // Option func signature | // Option func signature | ||||||
| @@ -181,6 +183,7 @@ func NewOptions(opts ...Option) Options { | |||||||
| 		Logger:           logger.DefaultLogger, | 		Logger:           logger.DefaultLogger, | ||||||
| 		Context:          context.Background(), | 		Context:          context.Background(), | ||||||
| 		ContextAttrFuncs: DefaultContextAttrFuncs, | 		ContextAttrFuncs: DefaultContextAttrFuncs, | ||||||
|  | 		Enabled:          true, | ||||||
| 	} | 	} | ||||||
| 	for _, o := range opts { | 	for _, o := range opts { | ||||||
| 		o(&options) | 		o(&options) | ||||||
| @@ -194,3 +197,10 @@ func Name(n string) Option { | |||||||
| 		o.Name = n | 		o.Name = n | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Disabled disable tracer | ||||||
|  | func Disabled(b bool) Option { | ||||||
|  | 	return func(o *Options) { | ||||||
|  | 		o.Enabled = !b | ||||||
|  | 	} | ||||||
|  | } | ||||||
|   | |||||||
| @@ -51,6 +51,8 @@ type Tracer interface { | |||||||
| 	// Extract(ctx context.Context) | 	// Extract(ctx context.Context) | ||||||
| 	// Flush flushes spans | 	// Flush flushes spans | ||||||
| 	Flush(ctx context.Context) error | 	Flush(ctx context.Context) error | ||||||
|  | 	// Enabled returns tracer status | ||||||
|  | 	Enabled() bool | ||||||
| } | } | ||||||
|  |  | ||||||
| type Span interface { | type Span interface { | ||||||
|   | |||||||
| @@ -67,6 +67,12 @@ func (b *SeekerBuffer) Close() error { | |||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Reset clears all the data out of the buffer and sets the read position to 0. | ||||||
|  | func (b *SeekerBuffer) Reset() { | ||||||
|  | 	b.data = nil | ||||||
|  | 	b.pos = 0 | ||||||
|  | } | ||||||
|  |  | ||||||
| // Len returns the length of data remaining to be read. | // Len returns the length of data remaining to be read. | ||||||
| func (b *SeekerBuffer) Len() int { | func (b *SeekerBuffer) Len() int { | ||||||
| 	return len(b.data[b.pos:]) | 	return len(b.data[b.pos:]) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user