Skip to content

Commit f916476

Browse files
Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210)
* Adds MallocNanoZone=0 env var as race detector run fails on OS X Monterey otherwise * adds first implementation of baggage handling for grpc and http middlewares * adds baggage implementation unit tests * adds baggage integration test with grpc * bumps license headers copyright year Co-authored-by: Crypt Keeper <[email protected]>
1 parent 6ac4138 commit f916476

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1071
-145
lines changed

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 The OpenZipkin Authors
1+
# Copyright 2022 The OpenZipkin Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -16,7 +16,8 @@
1616

1717
.PHONY: test
1818
test:
19-
go test -v -race -cover ./...
19+
# MallocNanoZone env var avoids problems in macOS Monterey: golang/go#49138
20+
MallocNanoZone=0 go test -v -race -cover ./...
2021

2122
.PHONY: bench
2223
bench:
@@ -25,8 +26,8 @@ bench:
2526
.PHONY: protoc
2627
protoc:
2728
protoc --go_out=module=github.com/openzipkin/zipkin-go:. proto/zipkin_proto3/zipkin.proto
28-
protoc --go_out=module=github.com/openzipkin/zipkin-go:. proto/testing/service.proto
29-
protoc --go-grpc_out=module=github.com/openzipkin/zipkin-go:. proto/testing/service.proto
29+
protoc --go_out=module=github.com/openzipkin/zipkin-go:. proto/testing/*.proto
30+
protoc --go-grpc_out=module=github.com/openzipkin/zipkin-go:. proto/testing/*.proto
3031

3132
.PHONY: lint
3233
lint:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
Copyright 2021 The OpenZipkin Authors
2+
Copyright 2022 The OpenZipkin Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

bench_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The OpenZipkin Authors
1+
// Copyright 2022 The OpenZipkin Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

context.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The OpenZipkin Authors
1+
// Copyright 2022 The OpenZipkin Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@ package zipkin
1616

1717
import (
1818
"context"
19+
20+
"github.com/openzipkin/zipkin-go/model"
1921
)
2022

2123
var defaultNoopSpan = &noopSpan{}
@@ -47,6 +49,15 @@ func NewContext(ctx context.Context, s Span) context.Context {
4749
return context.WithValue(ctx, spanKey, s)
4850
}
4951

52+
// BaggageFromContext takes a context and returns access to BaggageFields if
53+
// available. Returns nil if there are no BaggageFields found in context.
54+
func BaggageFromContext(ctx context.Context) model.BaggageFields {
55+
if span := SpanFromContext(ctx); span != nil {
56+
return span.Context().Baggage
57+
}
58+
return nil
59+
}
60+
5061
type ctxKey struct{}
5162

5263
var spanKey = ctxKey{}

context_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The OpenZipkin Authors
1+
// Copyright 2022 The OpenZipkin Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The OpenZipkin Authors
1+
// Copyright 2022 The OpenZipkin Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

endpoint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The OpenZipkin Authors
1+
// Copyright 2022 The OpenZipkin Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

endpoint_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The OpenZipkin Authors
1+
// Copyright 2022 The OpenZipkin Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The OpenZipkin Authors
1+
// Copyright 2022 The OpenZipkin Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

examples/httpserver_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The OpenZipkin Authors
1+
// Copyright 2022 The OpenZipkin Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)