message:
feat(Like Button): animate the variants bottom sheet view
* Also refactor the Bottom sheet view to let it be in its own View
* Add the behaviour inside the ItemDetailView for the main Like button,
so it fixes the "doing nothing" behaviour

diff:
4C30BFC3249627FD003E96A2 /* Sequence+Unique.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C30BFC2249627FC003E96A2 /* Sequence+Unique.swift */; };
4C6E95FD24842F690074433B /* Collection+SafeDirectAccess.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C6E95FC24842F690074433B /* Collection+SafeDirectAccess.swift */; };
4C7F555D248B91C80089F26C /* TodayVillagerVisitsSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C7F555C248B91C80089F26C /* TodayVillagerVisitsSection.swift */; };
+ 4CB1E3D925A0BB8F0021A175 /* VariantsForLikeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CB1E3D825A0BB8F0021A175 /* VariantsForLikeView.swift */; };
69157B7E2471A5A1005B9002 /* TodayMysteryIslandsSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69157B6D247121ED005B9002 /* TodayMysteryIslandsSection.swift */; };
69157B802471A5A1005B9002 /* UserListFormView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69875F5424654EB900B1D46C /* UserListFormView.swift */; };
69157B812471A5A1005B9002 /* RowLoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 693E2BBD2465B65D00B85CB8 /* RowLoadingView.swift */; };
4C7F2F772461F10300930928 /* TurnipsChartVerticalLegend.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnipsChartVerticalLegend.swift; sourceTree = "<group>"; };
4C7F555C248B91C80089F26C /* TodayVillagerVisitsSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayVillagerVisitsSection.swift; sourceTree = "<group>"; };
4C7FE788245B57A10011E8AB /* AdaptsToSoftwareKeyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdaptsToSoftwareKeyboard.swift; sourceTree = "<group>"; };
+ 4CB1E3D825A0BB8F0021A175 /* VariantsForLikeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VariantsForLikeView.swift; sourceTree = "<group>"; };
4CF14B74246B3E9E00F740BF /* TurnipsChartValuesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnipsChartValuesView.swift; sourceTree = "<group>"; };
4CF8049A24635E54005C6C63 /* Path.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Path.swift; sourceTree = "<group>"; };
4F92A4522470AC01003A2911 /* CollectionRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionRowView.swift; sourceTree = "<group>"; };
69CA5F00244F1AD300B275B6 /* SectionHeaderView.swift */,
69875F4F24652A4700B1D46C /* Sheet.swift */,
69E67EFA2494C35B00ED7AC8 /* ButtonImageCounterOverlay.swift */,
+ 4CB1E3D825A0BB8F0021A175 /* VariantsForLikeView.swift */,
);
path = shared;
sourceTree = "<group>";
69157BB02471A5A1005B9002 /* TodayView.swift in Sources */,
69157BB12471A5A1005B9002 /* CategoriesView.swift in Sources */,
69157BB22471A5A1005B9002 /* Sheet.swift in Sources */,
+ 4CB1E3D925A0BB8F0021A175 /* VariantsForLikeView.swift in Sources */,
6950EB37249D03C7002A4902 /* CommentsSection.swift in Sources */,
69157BB32471A5A1005B9002 /* CategoriesSearchViewModel.swift in Sources */,
69157BB42471A5A1005B9002 /* UserListRow.swift in Sources */,

diff:
@@ -140,36 +140,8 @@ struct ItemsView: View {
.listStyle(GroupedListStyle())
.id(viewModel.sort)
}
- likedItemWithVariants.map { item in
- ZStack {
- Color.black
- .opacity(1/6)
- .onTapGesture { likedItemWithVariants = nil }
- VStack {
- Spacer()
- itemVariants(for: item)
- }
- }
- }
- }
- }
-
- private func itemVariants(for item: Item) -> some View {
- VStack {
- SectionHeaderView(text: "Variants", icon: "paintbrush.fill").padding()
- ScrollView(.horizontal, showsIndicators: false) {
- HStack {
- ForEach(item.variations ?? []) { variant in
- ZStack(alignment: .topLeading) {
- ItemImage(path: variant.content.image, size: 75)
- LikeButtonView(item: item, variant: variant)
- }
- }
- }.padding()
- }
- .listRowInsets(EdgeInsets())
+ VariantsForLikeView(item: $likedItemWithVariants)
}
- .background(Color.acSecondaryBackground)
}
}

diff:
@@ -20,6 +20,7 @@ struct ItemDetailView: View {
@State private var displayedVariant: Variant?
@State private var selectedSheet: Sheet.SheetType?
+ @State private var itemToDisplayVariantsLike: Item?
init(item: Item) {
self._itemViewModel = StateObject(wrappedValue: ItemDetailViewModel(item: item))
@@ -46,6 +47,13 @@ struct ItemDetailView: View {
// MARK: - Boby
var body: some View {
+ ZStack {
+ content
+ VariantsForLikeView(item: $itemToDisplayVariantsLike)
+ }
+ }
+
+ var content: some View {
List {
ItemDetailInfoView(item: itemViewModel.item,
recipe: itemViewModel.recipe,
@@ -123,13 +131,23 @@ extension ItemDetailView {
private var navButtons: some View {
HStack {
- LikeButtonView(item: itemViewModel.item,
- variant: displayedVariant).imageScale(.large)
+ LikeButtonView(
+ item: itemViewModel.item,
+ variant: displayedVariant,
+ customAction: tapOnMainLikeButton
+ )
+ .imageScale(.large)
.safeHoverEffectBarItem(position: .trailing)
+
shareButton
}
}
+ private func tapOnMainLikeButton() {
+ // Display variants bottom sheet only if the item has some variants
+ itemToDisplayVariantsLike = itemViewModel.item.hasSomeVariations ? itemViewModel.item : nil
+ }
+
private var keywordsSection: some View {
Section(header: SectionHeaderView(text: "Keywords", icon: "link")) {
ScrollView(.horizontal, showsIndicators: false) {

diff:
@@ -12,14 +12,17 @@ import Backend
struct LikeButtonView: View {
@StateObject private var viewModel: LikeButtonViewModel
@Binding private var likedItemWithVariants: Item?
+ private var customAction: () -> Void = { }
init(
item: Item,
variant: Variant?,
- likedItemWithVariants: Binding<Item?> = .constant(nil)
+ likedItemWithVariants: Binding<Item?> = .constant(nil),
+ customAction: @escaping () -> Void = { }
) {
_viewModel = StateObject(wrappedValue: LikeButtonViewModel(item: item, variant: variant))
_likedItemWithVariants = likedItemWithVariants
+ self.customAction = customAction
}
init(villager: Villager) {
@@ -64,6 +67,7 @@ struct LikeButtonView: View {
let added = self.viewModel.toggleCollection()
FeedbackGenerator.shared.triggerNotification(type: added ? .success : .warning)
}
+ customAction()
}) {
Image(systemName: imageName).foregroundColor(color)
}

diff:
@@ -152,10 +152,10 @@ public class UserCollection: ObservableObject {
if !items.contains(item) && variants.completionStatus(for: item) != .unstarted {
// We add the item to the liked items if at least one of its variant is added
- toggleItem(item: item)
+ _ = toggleItem(item: item)
} else if items.contains(item) && variants.completionStatus(for: item) == .unstarted {
// We remove the item from the liked items if there is none of its variants liked
- toggleItem(item: item)
+ _ = toggleItem(item: item)
}
return isAdded

diff:
@@ -272,7 +272,20 @@ public let static_item = Item(name: "Acoustic guitar",
dIY: true,
customize: true,
movementSpeed: nil,
- variations: nil,
+ variations: [
+ Variant(id: 49134, content: Variant.Content(
+ image: "https://acnhcdn.com/latest/FtrIcon/FtrAcorsticguitar_Remake_0_0.png",
+ colors: ["Beige", "Brown"]
+ )),
+ Variant(id: 49135, content: Variant.Content(
+ image: "https://acnhcdn.com/latest/FtrIcon/FtrAcorsticguitar_Remake_1_0.png",
+ colors: ["Red", "Black"]
+ )),
+ Variant(id: 49136, content: Variant.Content(
+ image: "https://acnhcdn.com/latest/FtrIcon/FtrAcorsticguitar_Remake_2_0.png",
+ colors: ["Brown", "Black"]
+ )),
+ ],
category: "Housewares",
materials: nil,
buy: 200,


message:
feat(Variants): add rounded corner on top of the view
* As I see more and more this kind of view in apps nowadays, I think it
would be good to apply this to this bottom sheet view as well.

change_type: MODIFY

diff:
4C6E95FD24842F690074433B /* Collection+SafeDirectAccess.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C6E95FC24842F690074433B /* Collection+SafeDirectAccess.swift */; };
4C7F555D248B91C80089F26C /* TodayVillagerVisitsSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C7F555C248B91C80089F26C /* TodayVillagerVisitsSection.swift */; };
4CB1E3D925A0BB8F0021A175 /* VariantsForLikeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CB1E3D825A0BB8F0021A175 /* VariantsForLikeView.swift */; };
+ 4CB37F8C25C5D1C1004E4B0A /* RoundedRectangleOnTop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CB37F8B25C5D1C1004E4B0A /* RoundedRectangleOnTop.swift */; };
69157B7E2471A5A1005B9002 /* TodayMysteryIslandsSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69157B6D247121ED005B9002 /* TodayMysteryIslandsSection.swift */; };
69157B802471A5A1005B9002 /* UserListFormView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69875F5424654EB900B1D46C /* UserListFormView.swift */; };
69157B812471A5A1005B9002 /* RowLoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 693E2BBD2465B65D00B85CB8 /* RowLoadingView.swift */; };
4C7F555C248B91C80089F26C /* TodayVillagerVisitsSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayVillagerVisitsSection.swift; sourceTree = "<group>"; };
4C7FE788245B57A10011E8AB /* AdaptsToSoftwareKeyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdaptsToSoftwareKeyboard.swift; sourceTree = "<group>"; };
4CB1E3D825A0BB8F0021A175 /* VariantsForLikeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VariantsForLikeView.swift; sourceTree = "<group>"; };
+ 4CB37F8B25C5D1C1004E4B0A /* RoundedRectangleOnTop.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundedRectangleOnTop.swift; sourceTree = "<group>"; };
4CF14B74246B3E9E00F740BF /* TurnipsChartValuesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnipsChartValuesView.swift; sourceTree = "<group>"; };
4CF8049A24635E54005C6C63 /* Path.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Path.swift; sourceTree = "<group>"; };
4F92A4522470AC01003A2911 /* CollectionRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionRowView.swift; sourceTree = "<group>"; };
69875F4F24652A4700B1D46C /* Sheet.swift */,
69E67EFA2494C35B00ED7AC8 /* ButtonImageCounterOverlay.swift */,
4CB1E3D825A0BB8F0021A175 /* VariantsForLikeView.swift */,
+ 4CB37F8B25C5D1C1004E4B0A /* RoundedRectangleOnTop.swift */,
);
path = shared;
sourceTree = "<group>";
4C062B12252BB5BE004DCFA3 /* CurrentDateEnvironment.swift in Sources */,
69157BC22471A5A1005B9002 /* TodayEventsSection.swift in Sources */,
69157BC32471A5A1005B9002 /* FeedbackGenerator.swift in Sources */,
+ 4CB37F8C25C5D1C1004E4B0A /* RoundedRectangleOnTop.swift in Sources */,
3DFC04E824D6DABC002A6CED /* DreamCodeDetailView.swift in Sources */,
694C8B4724861D4E000B9B5F /* LikeButtonViewModel.swift in Sources */,
69EF2FFF24A88C1300BC0D42 /* PlayerMode.swift in Sources */,

diff:
@@ -18,7 +18,7 @@ struct VariantsForLikeView: View {
Color.black
.opacity(item != nil ? 1/6 : 0)
.onTapGesture { item = nil }
- if let item = item {
+ item.map { item in
VStack {
Spacer()
VStack {
@@ -36,6 +36,7 @@ struct VariantsForLikeView: View {
.listRowInsets(EdgeInsets())
}
.background(Color.acSecondaryBackground.shadow(radius: 2, x: 0, y: -2))
+ .clipShape(RoundedRectangleOnTop(cornerRadius: 32))
}
.transition(.move(edge: .bottom))
}

license: Apache License 2.0

repo: dimillian/achnbrowserui


message: added logic for pre-release builds

diff:
@@ -26,3 +26,4 @@ jobs:
- run: sudo npm install -g jsdoc-to-markdown@^4.0.0
- run: make test
- run: if [ "${CIRCLE_BRANCH}" == "master" ]; then make release && $HOME/ci-scripts/circleci/github-release $GH_RELEASE_TOKEN release; fi;
+ - run: if [ "${CIRCLE_BRANCH}" == "wag-nightly-build" ]; then make release && $HOME/ci-scripts/circleci/github-release --pre-release $GH_RELEASE_TOKEN release; fi;

old_path: VERSION

new_path: VERSION

diff:
-v8.2.1
+v9.0.0-alpha
v8.2.1 Sort attributes list used in v8.2.0 to reduce diffs

repo: clever/wag

original_message: added logic for pre-release builds


message: Removed breaking replace from go.mod

diff:
@@ -2,8 +2,6 @@ module github.com/Clever/wag/samples/v8
go 1.16
-replace github.com/Clever/discovery-go => /Users/chris.martin/go/src/github.com/Clever/discovery-go
-
require (
github.com/Clever/discovery-go v1.7.2
github.com/Clever/go-process-metrics v0.2.0

original_message: Removed breaking replace from go.mod


message: Removed kayvee deps on generated client. No logging anymore...

diff:
@@ -15,7 +15,6 @@ import (
"github.com/afex/hystrix-go/hystrix"
"github.com/donovanhide/eventsource"
- "golang.org/x/net/context/ctxhttp"
logger "gopkg.in/Clever/kayvee-go.v6/logger"
)
@@ -30,7 +29,8 @@ type opNameCtx struct{}
type baseDoer struct{}
func (d baseDoer) Do(c *http.Client, r *http.Request) (*http.Response, error) {
- return ctxhttp.Do(r.Context(), c, r)
+ return c.Do(r)
+ // return ctxhttp.Do(r.Context(), c, r)
}
// retryHandler retries 50X http requests

diff:
@@ -32,7 +32,7 @@ type clientCodeTemplate struct {
var clientCodeTemplateStr = `
package client
-// Using Alpha version of WAG
+// Using Alpha version of WAG Yay!
import (
"context"
@@ -50,7 +50,6 @@ import (
"{{.PackageName}}/tracing"
discovery "github.com/Clever/discovery-go"
"github.com/afex/hystrix-go/hystrix"
- logger "gopkg.in/Clever/kayvee-go.v6/logger"
)
var _ = json.Marshal
@@ -74,7 +73,7 @@ type WagClient struct {
// Keep the circuit doer around so that we can turn it on / off
circuitDoer *circuitBreakerDoer
defaultTimeout time.Duration
- logger logger.KayveeLogger
+ // logger logger.KayveeLogger
}
var _ Client = (*WagClient)(nil)
@@ -86,14 +85,14 @@ func New(basePath string) *WagClient {
// For the short-term don't use the default retry policy since its 5 retries can 5X
// the traffic. Once we've enabled circuit breakers by default we can turn it on.
retry := retryDoer{d: base, retryPolicy: SingleRetryPolicy{}}
- logger := logger.New("{{.ServiceName}}-wagclient")
+ // logger := logger.New("{{.ServiceName}}-wagclient")
circuit := &circuitBreakerDoer{
d: &retry,
// TODO: INFRANG-4404 allow passing circuitBreakerOptions
debug: true,
// one circuit for each service + url pair
circuitName: fmt.Sprintf("{{.ServiceName}}-%%s", shortHash(basePath)),
- logger: logger,
+ // logger: logger,
}
circuit.init()
client := &WagClient{
@@ -105,7 +104,7 @@ func New(basePath string) *WagClient {
retryDoer: &retry,
circuitDoer: circuit,
defaultTimeout: 5 * time.Second,
- logger: logger,
+ // logger: logger,
}
client.SetCircuitBreakerSettings(DefaultCircuitBreakerSettings)
return client
@@ -135,10 +134,10 @@ func (c *WagClient) SetCircuitBreakerDebug(b bool) {
}
// SetLogger allows for setting a custom logger
-func (c *WagClient) SetLogger(logger logger.KayveeLogger) {
- c.logger = logger
- c.circuitDoer.logger = logger
-}
+// func (c *WagClient) SetLogger(logger logger.KayveeLogger) {
+// c.logger = logger
+// c.circuitDoer.logger = logger
+// }
// CircuitBreakerSettings are the parameters that govern the client's circuit breaker.
type CircuitBreakerSettings struct {
@@ -429,19 +428,19 @@ func (c *WagClient) do%sRequest(ctx context.Context, req *http.Request, headers
}
// log all client failures and non-successful HT
- logData := logger.M{
- "backend": "%s",
- "method": req.Method,
- "uri": req.URL,
- "status_code": retCode,
- }
+ // logData := logger.M{
+ // "backend": "%s",
+ // "method": req.Method,
+ // "uri": req.URL,
+ // "status_code": retCode,
+ // }
if err == nil && retCode > 399 {
- logData["message"] = resp.Status
- c.logger.ErrorD("client-request-finished", logData)
+ // logData["message"] = resp.Status
+ // c.logger.ErrorD("client-request-finished", logData)
}
if err != nil {
- logData["message"] = err.Error()
- c.logger.ErrorD("client-request-finished", logData)
+ // logData["message"] = err.Error()
+ // c.logger.ErrorD("client-request-finished", logData)
return %serr
}
defer resp.Body.Close()

change_type: ADD

old_path: wag

new_path: wag

diff: Binary files /dev/null and b/wag differ


message: Removed tracing and logging from client, generates go.mod files for client and models now.

diff:
@@ -15,7 +15,6 @@ import (
"github.com/afex/hystrix-go/hystrix"
"github.com/donovanhide/eventsource"
- logger "gopkg.in/Clever/kayvee-go.v6/logger"
)
// doer is an interface for "doing" http requests possibly with wrapping
@@ -160,7 +159,7 @@ type circuitBreakerDoer struct {
d doer
debug bool
circuitName string
- logger logger.KayveeLogger
+ // logger logger.KayveeLogger
}
var circuitSSEOnce sync.Once
@@ -185,24 +184,24 @@ type HystrixSSEEvent struct {
LatencyTotalMean int `json:"latencyTotal_mean"`
}
-func logEvent(l logger.KayveeLogger, e HystrixSSEEvent) {
- l.InfoD(e.Name, map[string]interface{}{
- "requestCount": e.RequestCount,
- "errorCount": e.ErrorCount,
- "errorPercentage": e.ErrorPercentage,
- "isCircuitBreakerOpen": e.IsCircuitBreakerOpen,
- "rollingCountFailure": e.RollingCountFailure,
- "rollingCountFallbackFailure": e.RollingCountFallbackFailure,
- "rollingCountFallbackSuccess": e.RollingCountFallbackSuccess,
- "rollingCountShortCircuited": e.RollingCountShortCircuited,
- "rollingCountSuccess": e.RollingCountSuccess,
- "rollingCountThreadPoolRejected": e.RollingCountThreadPoolRejected,
- "rollingCountTimeout": e.RollingCountTimeout,
- "currentConcurrentExecutionCount": e.CurrentConcurrentExecutionCount,
- "latencyTotalMean": e.LatencyTotalMean,
- })
-
-}
+// func logEvent(l logger.KayveeLogger, e HystrixSSEEvent) {
+// l.InfoD(e.Name, map[string]interface{}{
+// "requestCount": e.RequestCount,
+// "errorCount": e.ErrorCount,
+// "errorPercentage": e.ErrorPercentage,
+// "isCircuitBreakerOpen": e.IsCircuitBreakerOpen,
+// "rollingCountFailure": e.RollingCountFailure,
+// "rollingCountFallbackFailure": e.RollingCountFallbackFailure,
+// "rollingCountFallbackSuccess": e.RollingCountFallbackSuccess,
+// "rollingCountShortCircuited": e.RollingCountShortCircuited,
+// "rollingCountSuccess": e.RollingCountSuccess,
+// "rollingCountThreadPoolRejected": e.RollingCountThreadPoolRejected,
+// "rollingCountTimeout": e.RollingCountTimeout,
+// "currentConcurrentExecutionCount": e.CurrentConcurrentExecutionCount,
+// "latencyTotalMean": e.LatencyTotalMean,
+// })
+
+// }
func (d *circuitBreakerDoer) init() {
// Periodically log internal circuit state to assist in setting
@@ -268,15 +267,15 @@ func (d *circuitBreakerDoer) init() {
// (3) 10 seconds have passed since we logged something for the circuit
if !ok {
lastEventLogTime[e.Name] = time.Now()
- logEvent(d.logger, e)
+ // logEvent(d.logger, e)
continue
}
if lastSeen.IsCircuitBreakerOpen != e.IsCircuitBreakerOpen {
lastEventLogTime[e.Name] = time.Now()
- logEvent(d.logger, e)
+ // logEvent(d.logger, e)
} else if time.Now().Sub(lastEventLogTime[e.Name]) > logFrequency {
lastEventLogTime[e.Name] = time.Now()
- logEvent(d.logger, e)
+ // logEvent(d.logger, e)
}
}
}

diff:
@@ -3,7 +3,9 @@ package goclient
import (
"bytes"
"fmt"
+ "os"
"path"
+ "path/filepath"
"strings"
"github.com/go-openapi/spec"
@@ -47,7 +49,6 @@ import (
"crypto/md5"
"{{.PackageName}}/models"
- "{{.PackageName}}/tracing"
discovery "github.com/Clever/discovery-go"
"github.com/afex/hystrix-go/hystrix"
)
@@ -99,7 +100,7 @@ func New(basePath string) *WagClient {
basePath: basePath,
requestDoer: circuit,
client: &http.Client{
- Transport: tracing.NewTransport(http.DefaultTransport, opNameCtx{}),
+ // Transport: tracing.NewTransport(http.DefaultTransport, opNameCtx{}),
},
retryDoer: &retry,
circuitDoer: circuit,
@@ -186,7 +187,7 @@ func (c *WagClient) SetTimeout(timeout time.Duration){
// SetTransport sets the http transport used by the client.
func (c *WagClient) SetTransport(t http.RoundTripper){
- c.client.Transport = tracing.NewTransport(t, opNameCtx{})
+ // c.client.Transport = tracing.NewTransport(t, opNameCtx{})
}
{{range $operationCode := .Operations}}
@@ -230,7 +231,78 @@ func generateClient(packageName, packagePath string, s spec.Swagger) error {
g := swagger.Generator{PackagePath: packagePath}
g.Printf(clientCode)
- return g.WriteFile("client/client.go")
+ err = g.WriteFile("client/client.go")
+ if err != nil {
+ return err
+ }
+
+ return CreateModFile("client/go.mod", packagePath)
+
+}
+
+//CreateModFile creates a go.mod file for the client module.
+func CreateModFile(path string, packagePath string) error {
+
+ absPath := filepath.Join(os.Getenv("GOPATH"), "src", packagePath, path)
+ f, err := os.Create(absPath)
+
+ if err != nil {
+ return err
+ }
+
+ defer f.Close()
+ modFileString := `
+module github.com/Clever/dapple/client
+
+go 1.16
+
+require (
+ github.com/Clever/dapple/gen-go/models v0.0.0-00010101000000-000000000000
+ github.com/Clever/discovery-go v1.7.2
+ github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
+ github.com/donovanhide/eventsource v0.0.0-20171031113327-3ed64d21fb0b
+)
+
+require (
+ github.com/PuerkitoBio/purell v1.1.1 // indirect
+ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
+ github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect
+ github.com/go-openapi/analysis v0.21.2 // indirect
+ github.com/go-openapi/errors v0.20.2 // indirect
+ github.com/go-openapi/jsonpointer v0.19.5 // indirect
+ github.com/go-openapi/jsonreference v0.19.6 // indirect
+ github.com/go-openapi/loads v0.21.1 // indirect
+ github.com/go-openapi/spec v0.20.4 // indirect
+ github.com/go-openapi/strfmt v0.21.2 // indirect
+ github.com/go-openapi/swag v0.21.1 // indirect
+ github.com/go-openapi/validate v0.22.0 // indirect
+ github.com/go-stack/stack v1.8.0 // indirect
+ github.com/google/go-cmp v0.5.5 // indirect
+ github.com/google/uuid v1.1.2 // indirect
+ github.com/josharian/intern v1.0.0 // indirect
+ github.com/mailru/easyjson v0.7.6 // indirect
+ github.com/mitchellh/mapstructure v1.4.1 // indirect
+ github.com/oklog/ulid v1.3.1 // indirect
+ github.com/smartystreets/goconvey v1.7.2 // indirect
+ github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
+ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
+ github.com/xeipuuv/gojsonschema v1.2.1-0.20200424115421-065759f9c3d7 // indirect
+ go.mongodb.org/mongo-driver v1.7.5 // indirect
+ golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
+ golang.org/x/text v0.3.7 // indirect
+ gopkg.in/Clever/kayvee-go.v6 v6.27.0 // indirect //Still want to remove this once I merge discovery-go PR.
+ gopkg.in/yaml.v2 v2.4.0 // indirect
+)
+
+replace github.com/Clever/dapple/gen-go/models => ../models
+`
+ _, err = f.WriteString(modFileString)
+
+ if err != nil {
+ return err
+ }
+
+ return nil
}
// IsBinaryBody returns true if the format of the body of the operation is binary

diff:
@@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"os"
+ "path/filepath"
"sort"
"strings"
@@ -51,9 +52,47 @@ func Generate(packagePath string, s spec.Swagger) error {
if err := generateInputs(packagePath, s); err != nil {
return fmt.Errorf("error generating inputs: %s", err)
}
+ if err := CreateModFile("models/go.mod", packagePath); err != nil {
+ return fmt.Errorf("error creating go.mod file: %s", err)
+ }
return nil
}
+//CreateModFile creates a go.mod file for the client module.
+func CreateModFile(path string, packagePath string) error {
+
+ absPath := filepath.Join(os.Getenv("GOPATH"), "src", packagePath, path)
+ f, err := os.Create(absPath)
+
+ if err != nil {
+ return err
+ }
+
+ defer f.Close()
+ modFileString := `
+module github.com/Clever/dapple/models
+
+go 1.16
+
+require (
+ github.com/go-openapi/errors v0.20.2
+ github.com/go-openapi/strfmt v0.21.2
+ github.com/go-openapi/swag v0.21.1
+ github.com/go-openapi/validate v0.22.0
+ github.com/google/go-cmp v0.5.5 // indirect
+ github.com/google/uuid v1.1.2 // indirect
+ golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
+)
+
+ `
+ _, err = f.WriteString(modFileString)
+
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
func generateInputs(packagePath string, s spec.Swagger) error {
g := swagger.Generator{PackagePath: packagePath}

diff: Binary files a/wag and b/wag differ


message: removed refs to local logger and now using separate module in logger dir

diff:
@@ -47,6 +47,7 @@ import (
"fmt"
"crypto/md5"
+ "github.com/Clever/wag/logger"
"{{.PackageName}}/models"
discovery "github.com/Clever/discovery-go"
"github.com/afex/hystrix-go/hystrix"
@@ -63,29 +64,6 @@ const Version = "{{ .Version }}"
// VersionHeader is sent with every request.
const VersionHeader = "X-Client-Version"
-func NewLogger(id string, level int) WagClientLogger {
- return WagClientPrintlnLogger{id: id, level: level}
-}
-
-type WagClientPrintlnLogger struct {
- level int
- id string
-}
-
-func (w WagClientPrintlnLogger) Log(level int, message string, m map[string]interface{}) {
- if w.level >= level {
- fmt.Print(w.id, ": ")
- fmt.Print(message)
- for k, v := range m {
- fmt.Print(" ", k, " : ", v)
- }
- fmt.Println()
- }
-}
-
-type WagClientLogger interface {
- Log(level int, message string, pairs map[string]interface{})
-}
var CRITICALD int = 0
var ERRORD int = 1
var WARND int = 2
@@ -102,7 +80,7 @@ type WagClient struct {
// Keep the circuit doer around so that we can turn it on / off
circuitDoer *circuitBreakerDoer
defaultTimeout time.Duration
- logger WagClientLogger
+ logger logger.WagClientLogger
}
var _ Client = (*WagClient)(nil)
@@ -163,9 +141,9 @@ func (c *WagClient) SetCircuitBreakerDebug(b bool) {
}
// SetLogger allows for setting a custom logger
-func (c *WagClient) SetLogger(logger WagClientLogger) {
- c.logger = logger
- c.circuitDoer.logger = logger
+func (c *WagClient) SetLogger(l logger.WagClientLogger) {
+ c.logger = l
+ c.circuitDoer.logger = l
}
// CircuitBreakerSettings are the parameters that govern the client's circuit breaker.

diff:
@@ -14,6 +14,7 @@ import (
"time"
discovery "github.com/Clever/discovery-go"
+ "github.com/Clever/wag/logger"
"github.com/Clever/wag/samples/v8/gen-go-blog/models"
"github.com/afex/hystrix-go/hystrix"
)
@@ -29,30 +30,6 @@ const Version = "0.1.0"
// VersionHeader is sent with every request.
const VersionHeader = "X-Client-Version"
-func NewLogger(id string, level int) WagClientLogger {
- return WagClientPrintlnLogger{id: id, level: level}
-}
-
-type WagClientPrintlnLogger struct {
- level int
- id string
-}
-
-func (w WagClientPrintlnLogger) Log(level int, message string, m map[string]interface{}) {
- if w.level >= level {
- fmt.Print(w.id, ": ")
- fmt.Print(message)
- for k, v := range m {
- fmt.Print(" ", k, " : ", v)
- }
- fmt.Println()
- }
-}
-
-type WagClientLogger interface {
- Log(level int, message string, pairs map[string]interface{})
-}
-
var CRITICALD int = 0
var ERRORD int = 1
var WARND int = 2
@@ -69,7 +46,7 @@ type WagClient struct {
// Keep the circuit doer around so that we can turn it on / off
circuitDoer *circuitBreakerDoer
defaultTimeout time.Duration
- logger WagClientLogger
+ logger logger.WagClientLogger
}
var _ Client = (*WagClient)(nil)
@@ -130,9 +107,9 @@ func (c *WagClient) SetCircuitBreakerDebug(b bool) {
}
// SetLogger allows for setting a custom logger
-func (c *WagClient) SetLogger(logger WagClientLogger) {
- c.logger = logger
- c.circuitDoer.logger = logger
+func (c *WagClient) SetLogger(l logger.WagClientLogger) {
+ c.logger = l
+ c.circuitDoer.logger = l
}
// CircuitBreakerSettings are the parameters that govern the client's circuit breaker.

diff:
@@ -14,6 +14,7 @@ import (
"time"
discovery "github.com/Clever/discovery-go"
+ "github.com/Clever/wag/logger"
"github.com/Clever/wag/samples/v8/gen-go-client-only/models"
"github.com/afex/hystrix-go/hystrix"
)
@@ -29,30 +30,6 @@ const Version = "0.1.0"
// VersionHeader is sent with every request.
const VersionHeader = "X-Client-Version"
-func NewLogger(id string, level int) WagClientLogger {
- return WagClientPrintlnLogger{id: id, level: level}
-}
-
-type WagClientPrintlnLogger struct {
- level int
- id string
-}
-
-func (w WagClientPrintlnLogger) Log(level int, message string, m map[string]interface{}) {
- if w.level >= level {
- fmt.Print(w.id, ": ")
- fmt.Print(message)
- for k, v := range m {
- fmt.Print(" ", k, " : ", v)
- }
- fmt.Println()
- }
-}
-
-type WagClientLogger interface {
- Log(level int, message string, pairs map[string]interface{})
-}
-
var CRITICALD int = 0
var ERRORD int = 1
var WARND int = 2
@@ -69,7 +46,7 @@ type WagClient struct {
// Keep the circuit doer around so that we can turn it on / off
circuitDoer *circuitBreakerDoer
defaultTimeout time.Duration
- logger WagClientLogger
+ logger logger.WagClientLogger
}
var _ Client = (*WagClient)(nil)
@@ -130,9 +107,9 @@ func (c *WagClient) SetCircuitBreakerDebug(b bool) {
}
// SetLogger allows for setting a custom logger
-func (c *WagClient) SetLogger(logger WagClientLogger) {
- c.logger = logger
- c.circuitDoer.logger = logger
+func (c *WagClient) SetLogger(l logger.WagClientLogger) {
+ c.logger = l
+ c.circuitDoer.logger = l
}
// CircuitBreakerSettings are the parameters that govern the client's circuit breaker.

diff:
@@ -14,6 +14,7 @@ import (
"time"
discovery "github.com/Clever/discovery-go"
+ "github.com/Clever/wag/logger"
"github.com/Clever/wag/samples/v8/gen-go-db-custom-path/models"
"github.com/afex/hystrix-go/hystrix"
)
@@ -29,30 +30,6 @@ const Version = "0.1.0"
// VersionHeader is sent with every request.
const VersionHeader = "X-Client-Version"
-func NewLogger(id string, level int) WagClientLogger {
- return WagClientPrintlnLogger{id: id, level: level}
-}
-
-type WagClientPrintlnLogger struct {
- level int
- id string
-}
-
-func (w WagClientPrintlnLogger) Log(level int, message string, m map[string]interface{}) {
- if w.level >= level {
- fmt.Print(w.id, ": ")
- fmt.Print(message)
- for k, v := range m {
- fmt.Print(" ", k, " : ", v)
- }
- fmt.Println()
- }
-}
-
-type WagClientLogger interface {
- Log(level int, message string, pairs map[string]interface{})
-}
-
var CRITICALD int = 0
var ERRORD int = 1
var WARND int = 2
@@ -69,7 +46,7 @@ type WagClient struct {
// Keep the circuit doer around so that we can turn it on / off
circuitDoer *circuitBreakerDoer
defaultTimeout time.Duration
- logger WagClientLogger
+ logger logger.WagClientLogger
}
var _ Client = (*WagClient)(nil)
@@ -130,9 +107,9 @@ func (c *WagClient) SetCircuitBreakerDebug(b bool) {
}
// SetLogger allows for setting a custom logger
-func (c *WagClient) SetLogger(logger WagClientLogger) {
- c.logger = logger
- c.circuitDoer.logger = logger
+func (c *WagClient) SetLogger(l logger.WagClientLogger) {
+ c.logger = l
+ c.circuitDoer.logger = l
}
// CircuitBreakerSettings are the parameters that govern the client's circuit breaker.

diff:
@@ -14,6 +14,7 @@ import (
"time"
discovery "github.com/Clever/discovery-go"
+ "github.com/Clever/wag/logger"
"github.com/Clever/wag/samples/v8/gen-go-db/models"
"github.com/afex/hystrix-go/hystrix"
)
@@ -29,30 +30,6 @@ const Version = "0.1.0"
// VersionHeader is sent with every request.
const VersionHeader = "X-Client-Version"
-func NewLogger(id string, level int) WagClientLogger {
- return WagClientPrintlnLogger{id: id, level: level}
-}
-
-type WagClientPrintlnLogger struct {
- level int
- id string
-}
-
-func (w WagClientPrintlnLogger) Log(level int, message string, m map[string]interface{}) {
- if w.level >= level {
- fmt.Print(w.id, ": ")
- fmt.Print(message)
- for k, v := range m {
- fmt.Print(" ", k, " : ", v)
- }
- fmt.Println()
- }
-}
-
-type WagClientLogger interface {
- Log(level int, message string, pairs map[string]interface{})
-}
-
var CRITICALD int = 0
var ERRORD int = 1
var WARND int = 2
@@ -69,7 +46,7 @@ type WagClient struct {
// Keep the circuit doer around so that we can turn it on / off
circuitDoer *circuitBreakerDoer
defaultTimeout time.Duration
- logger WagClientLogger
+ logger logger.WagClientLogger
}
var _ Client = (*WagClient)(nil)
@@ -130,9 +107,9 @@ func (c *WagClient) SetCircuitBreakerDebug(b bool) {
}
// SetLogger allows for setting a custom logger
-func (c *WagClient) SetLogger(logger WagClientLogger) {
- c.logger = logger
- c.circuitDoer.logger = logger
+func (c *WagClient) SetLogger(l logger.WagClientLogger) {
+ c.logger = l
+ c.circuitDoer.logger = l
}
// CircuitBreakerSettings are the parameters that govern the client's circuit breaker.

diff:
@@ -14,6 +14,7 @@ import (
"time"
discovery "github.com/Clever/discovery-go"
+ "github.com/Clever/wag/logger"
"github.com/Clever/wag/samples/v8/gen-go-deprecated/models"
"github.com/afex/hystrix-go/hystrix"
)
@@ -29,30 +30,6 @@ const Version = "0.1.0"
// VersionHeader is sent with every request.
const VersionHeader = "X-Client-Version"
-func NewLogger(id string, level int) WagClientLogger {
- return WagClientPrintlnLogger{id: id, level: level}
-}
-
-type WagClientPrintlnLogger struct {
- level int
- id string
-}
-
-func (w WagClientPrintlnLogger) Log(level int, message string, m map[string]interface{}) {
- if w.level >= level {
- fmt.Print(w.id, ": ")
- fmt.Print(message)
- for k, v := range m {
- fmt.Print(" ", k, " : ", v)
- }
- fmt.Println()
- }
-}
-
-type WagClientLogger interface {
- Log(level int, message string, pairs map[string]interface{})
-}
-
var CRITICALD int = 0
var ERRORD int = 1
var WARND int = 2
@@ -69,7 +46,7 @@ type WagClient struct {
// Keep the circuit doer around so that we can turn it on / off
circuitDoer *circuitBreakerDoer
defaultTimeout time.Duration
- logger WagClientLogger
+ logger logger.WagClientLogger
}
var _ Client = (*WagClient)(nil)
@@ -130,9 +107,9 @@ func (c *WagClient) SetCircuitBreakerDebug(b bool) {
}
// SetLogger allows for setting a custom logger
-func (c *WagClient) SetLogger(logger WagClientLogger) {
- c.logger = logger
- c.circuitDoer.logger = logger
+func (c *WagClient) SetLogger(l logger.WagClientLogger) {
+ c.logger = l
+ c.circuitDoer.logger = l
}
// CircuitBreakerSettings are the parameters that govern the client's circuit breaker.

diff:
@@ -14,6 +14,7 @@ import (
"time"
discovery "github.com/Clever/discovery-go"
+ "github.com/Clever/wag/logger"
"github.com/Clever/wag/samples/v8/gen-go-errors/models"
"github.com/afex/hystrix-go/hystrix"
)
@@ -29,30 +30,6 @@ const Version = "0.1.0"
// VersionHeader is sent with every request.
const VersionHeader = "X-Client-Version"
-func NewLogger(id string, level int) WagClientLogger {
- return WagClientPrintlnLogger{id: id, level: level}
-}
-
-type WagClientPrintlnLogger struct {
- level int
- id string
-}
-
-func (w WagClientPrintlnLogger) Log(level int, message string, m map[string]interface{}) {
- if w.level >= level {
- fmt.Print(w.id, ": ")
- fmt.Print(message)
- for k, v := range m {
- fmt.Print(" ", k, " : ", v)
- }
- fmt.Println()
- }
-}
-
-type WagClientLogger interface {
- Log(level int, message string, pairs map[string]interface{})
-}
-
var CRITICALD int = 0
var ERRORD int = 1
var WARND int = 2
@@ -69,7 +46,7 @@ type WagClient struct {
// Keep the circuit doer around so that we can turn it on / off
circuitDoer *circuitBreakerDoer
defaultTimeout time.Duration
- logger WagClientLogger
+ logger logger.WagClientLogger
}
var _ Client = (*WagClient)(nil)
@@ -130,9 +107,9 @@ func (c *WagClient) SetCircuitBreakerDebug(b bool) {
}
// SetLogger allows for setting a custom logger
-func (c *WagClient) SetLogger(logger WagClientLogger) {
- c.logger = logger
- c.circuitDoer.logger = logger
+func (c *WagClient) SetLogger(l logger.WagClientLogger) {
+ c.logger = l
+ c.circuitDoer.logger = l
}
// CircuitBreakerSettings are the parameters that govern the client's circuit breaker.

diff:
@@ -14,6 +14,7 @@ import (
"time"
discovery "github.com/Clever/discovery-go"
+ "github.com/Clever/wag/logger"
"github.com/Clever/wag/samples/v8/gen-go-nils/models"
"github.com/afex/hystrix-go/hystrix"
)
@@ -29,30 +30,6 @@ const Version = "0.1.0"
// VersionHeader is sent with every request.
const VersionHeader = "X-Client-Version"
-func NewLogger(id string, level int) WagClientLogger {
- return WagClientPrintlnLogger{id: id, level: level}
-}
-
-type WagClientPrintlnLogger struct {
- level int
- id string
-}
-
-func (w WagClientPrintlnLogger) Log(level int, message string, m map[string]interface{}) {
- if w.level >= level {
- fmt.Print(w.id, ": ")
- fmt.Print(message)
- for k, v := range m {
- fmt.Print(" ", k, " : ", v)
- }
- fmt.Println()
- }
-}
-
-type WagClientLogger interface {
- Log(level int, message string, pairs map[string]interface{})
-}
-
var CRITICALD int = 0
var ERRORD int = 1
var WARND int = 2
@@ -69,7 +46,7 @@ type WagClient struct {
// Keep the circuit doer around so that we can turn it on / off
circuitDoer *circuitBreakerDoer
defaultTimeout time.Duration
- logger WagClientLogger
+ logger logger.WagClientLogger
}
var _ Client = (*WagClient)(nil)
@@ -130,9 +107,9 @@ func (c *WagClient) SetCircuitBreakerDebug(b bool) {
}
// SetLogger allows for setting a custom logger
-func (c *WagClient) SetLogger(logger WagClientLogger) {
- c.logger = logger
- c.circuitDoer.logger = logger
+func (c *WagClient) SetLogger(l logger.WagClientLogger) {
+ c.logger = l
+ c.circuitDoer.logger = l
}
// CircuitBreakerSettings are the parameters that govern the client's circuit breaker.

diff:
@@ -14,6 +14,7 @@ import (
"time"
discovery "github.com/Clever/discovery-go"
+ "github.com/Clever/wag/logger"
"github.com/Clever/wag/samples/v8/gen-go/models"
"github.com/afex/hystrix-go/hystrix"
)
@@ -29,30 +30,6 @@ const Version = "0.1.0"
// VersionHeader is sent with every request.
const VersionHeader = "X-Client-Version"
-func NewLogger(id string, level int) WagClientLogger {
- return WagClientPrintlnLogger{id: id, level: level}
-}
-
-type WagClientPrintlnLogger struct {
- level int
- id string
-}
-
-func (w WagClientPrintlnLogger) Log(level int, message string, m map[string]interface{}) {
- if w.level >= level {
- fmt.Print(w.id, ": ")
- fmt.Print(message)
- for k, v := range m {
- fmt.Print(" ", k, " : ", v)
- }
- fmt.Println()
- }
-}
-
-type WagClientLogger interface {
- Log(level int, message string, pairs map[string]interface{})
-}
-
var CRITICALD int = 0
var ERRORD int = 1
var WARND int = 2
@@ -69,7 +46,7 @@ type WagClient struct {
// Keep the circuit doer around so that we can turn it on / off
circuitDoer *circuitBreakerDoer
defaultTimeout time.Duration
- logger WagClientLogger
+ logger logger.WagClientLogger
}
var _ Client = (*WagClient)(nil)
@@ -130,9 +107,9 @@ func (c *WagClient) SetCircuitBreakerDebug(b bool) {
}
// SetLogger allows for setting a custom logger
-func (c *WagClient) SetLogger(logger WagClientLogger) {
- c.logger = logger
- c.circuitDoer.logger = logger
+func (c *WagClient) SetLogger(l logger.WagClientLogger) {
+ c.logger = l
+ c.circuitDoer.logger = l
}
// CircuitBreakerSettings are the parameters that govern the client's circuit breaker.


message: removing some broken stuff from the go.mod. Eventually will have to create this differently.

diff:
@@ -263,7 +263,8 @@ module ` + packageName + `/client
go 1.16
require (
- ` + packageName + `/models v0.0.0
+ //removed this because it can never get the right version. Adding with a go get instead.
+ // ` + packageName + `/models v0.0.0
github.com/Clever/discovery-go v1.7.2
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/donovanhide/eventsource v0.0.0-20171031113327-3ed64d21fb0b
@@ -299,7 +300,6 @@ require (
gopkg.in/Clever/kayvee-go.v6 v6.27.0 // indirect //Still want to remove this once I merge discovery-go PR.
gopkg.in/yaml.v2 v2.4.0 // indirect
- replace ` + packageName + `/models => ../models
)
`
_, err = f.WriteString(modFileString)


message: changed path of printlogger

diff:
@@ -263,7 +263,7 @@ module ` + packageName + `/client
go 1.16
require (
- //removed this because it can never get the right version. Adding with: go get github.com/Clever/wag/logger@wag-nightly-build
+ //removed this because it can never get the right version. Adding with: go get github.com/Clever/dapple/gen-go/models@INFRANG-4918-Testing-nested-modules
// ` + packageName + `/models v0.0.0
github.com/Clever/discovery-go v1.7.2
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5

diff:
-module github.com/Clever/wag/printLogger
+module github.com/Clever/wag/logger/printlogger
go 1.16

original_message: changed path of printlogger


message: fixed printlogger dep go.mod

diff:
@@ -4,6 +4,7 @@ go 1.16
require (
github.com/Clever/go-utils v0.0.0-20180917210021-2dac0ec6f2ac
+ github.com/Clever/wag/loggers/printlogger v0.0.0-20220627165618-1bd4f73bc4d8 // indirect
github.com/Clever/wag/loggers/waglogger v0.0.0-20220627165333-1da7fb040613 // indirect
github.com/awslabs/goformation/v2 v2.3.1
github.com/go-openapi/errors v0.19.4

diff:
@@ -3,6 +3,8 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Clever/go-utils v0.0.0-20180917210021-2dac0ec6f2ac h1:eoofDGlVjiTro1kr97QnRkW4b/MGDSmm4E0ta2rqFos=
github.com/Clever/go-utils v0.0.0-20180917210021-2dac0ec6f2ac/go.mod h1:XXTA9F/953CGhnDRslFaBp7S0560745gMZSDm+C4ebw=
+github.com/Clever/wag/loggers/printlogger v0.0.0-20220627165618-1bd4f73bc4d8 h1:QCFuEtQTXXPxVXpdzD9ZsSvsb7pg2vSPnbW86ljur40=
+github.com/Clever/wag/loggers/printlogger v0.0.0-20220627165618-1bd4f73bc4d8/go.mod h1:KkPJFcnprzj2UNUue87W5+LrjaRMt00jEoKav0RWh20=
github.com/Clever/wag/loggers/waglogger v0.0.0-20220627165333-1da7fb040613 h1:qd6x0QWFZ+6mYJ/n2eOdlHR5lfz1WKC0eR4IeYgn8Z4=
github.com/Clever/wag/loggers/waglogger v0.0.0-20220627165333-1da7fb040613/go.mod h1:wCYwOynv1y5ePqwkSdVcjrO6AZn99vCixp6NDqO6QFQ=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=

diff:
module github.com/Clever/wag/loggers/printlogger
go 1.16
+
+require github.com/Clever/wag/loggers/waglogger v0.0.0-20220627165618-1bd4f73bc4d8 // indirect

diff:
@@ -14,7 +14,8 @@ import (
"time"
discovery "github.com/Clever/discovery-go"
- "github.com/Clever/wag/logger"
+ "github.com/Clever/wag/loggers/printlogger"
+ "github.com/Clever/wag/loggers/waglogger"
"github.com/Clever/wag/samples/v8/gen-go/models"
"github.com/afex/hystrix-go/hystrix"
)
@@ -52,13 +53,16 @@ type WagClient struct {
var _ Client = (*WagClient)(nil)
// New creates a new client. The base path and http transport are configurable.
-func New(basePath string) *WagClient {
+func New(basePath string, opts ...Option) *WagClient {
basePath = strings.TrimSuffix(basePath, "/")
base := baseDoer{}
// For the short-term don't use the default retry policy since its 5 retries can 5X
// the traffic. Once we've enabled circuit breakers by default we can turn it on.
retry := retryDoer{d: base, retryPolicy: SingleRetryPolicy{}}
- logger := NewLogger("swagger-test-wagclient", 3)
+ options := options{
+ cache: defaultCache,
+ logger: printlogger.NewLogger("swagger-test-wagclient", 3),
+ }
circuit := &circuitBreakerDoer{
d: &retry,
// TODO: INFRANG-4404 allow passing circuitBreakerOptions

original_message: fixed printlogger dep go.mod


message: moved broken tracing to it's own module thus breaking a LOT of stuff

diff:
@@ -13,9 +13,10 @@ import (
"strings"
"time"
- discovery "github.com/Clever/discovery-go"
"github.com/Clever/wag/loggers/printlogger"
"github.com/Clever/wag/loggers/waglogger"
+
+ discovery "github.com/Clever/discovery-go"
"github.com/Clever/wag/samples/v8/gen-go/models"
"github.com/afex/hystrix-go/hystrix"
)
@@ -47,29 +48,69 @@ type WagClient struct {
// Keep the circuit doer around so that we can turn it on / off
circuitDoer *circuitBreakerDoer
defaultTimeout time.Duration
- logger logger.WagClientLogger
+ logger waglogger.WagClientLogger
}
var _ Client = (*WagClient)(nil)
+//This pattern is used instead of using closures for greater transparency and the ability to implement additional interfaces.
+type options struct {
+ tracing interface{}
+ logger waglogger.WagClientLogger
+}
+
+type Option interface {
+ apply(*options)
+}
+
+//WithLogger sets client logger option.
+func WithLogger(log waglogger.WagClientLogger) Option {
+ return loggerOption{Log: log}
+}
+
+type loggerOption struct {
+ Log *waglogger.WagClientLogger
+}
+
+func (l loggerOption) apply(opts *options) {
+ opts.logger = l.Log
+}
+
+type tracingOption interface{}
+
+func (t tracingOption) apply(opts *options) {
+ opts.tracing = t //This is where I would normally have a : tracing.NewTransport(http.DefaultTransport, opNameCtx{})
+}
+
+//WithTracingProvider defines the tracing provider for
+func WithTracingProvider(t interface{}) Option {
+ return tracingOption(t)
+}
+
// New creates a new client. The base path and http transport are configurable.
-func New(basePath string, opts ...Option) *WagClient {
+func New(basePath string) *WagClient {
+ defaultTracing := tracing.NewTransport(http.DefaultTransport, opNameCtx{})
basePath = strings.TrimSuffix(basePath, "/")
base := baseDoer{}
// For the short-term don't use the default retry policy since its 5 retries can 5X
// the traffic. Once we've enabled circuit breakers by default we can turn it on.
retry := retryDoer{d: base, retryPolicy: SingleRetryPolicy{}}
options := options{
- cache: defaultCache,
+ tracing: defaultTracing,
logger: printlogger.NewLogger("swagger-test-wagclient", 3),
}
+
+ for _, o := range opts {
+ o.apply(&options)
+ }
+
circuit := &circuitBreakerDoer{
d: &retry,
// TODO: INFRANG-4404 allow passing circuitBreakerOptions
debug: true,
// one circuit for each service + url pair
circuitName: fmt.Sprintf("swagger-test-%s", shortHash(basePath)),
- logger: logger,
+ logger: options.logger,
}
circuit.init()
client := &WagClient{
@@ -81,7 +122,7 @@ func New(basePath string, opts ...Option) *WagClient {
retryDoer: &retry,
circuitDoer: circuit,
defaultTimeout: 5 * time.Second,
- logger: logger,
+ logger: options.logger,
}
client.SetCircuitBreakerSettings(DefaultCircuitBreakerSettings)
return client

diff:
@@ -13,7 +13,7 @@ import (
"sync"
"time"
- "github.com/Clever/wag/logger"
+ "github.com/Clever/wag/loggers/waglogger"
"github.com/afex/hystrix-go/hystrix"
"github.com/donovanhide/eventsource"
)

diff:
-
module github.com/Clever/wag/samples/v8/gen-go/client
go 1.16
require (
- //removed this because it can never get the right version. Adding with: go get github.com/Clever/wag/logger@wag-nightly-build
+ //removed this because it can never get the right version. Adding with: go get github.com/Clever/dapple/gen-go/models@INFRANG-4918-Testing-nested-modules
// github.com/Clever/wag/samples/v8/gen-go/models v0.0.0
- github.com/Clever/discovery-go v1.7.2
+ github.com/Clever/discovery-go v1.8.1
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/donovanhide/eventsource v0.0.0-20171031113327-3ed64d21fb0b
)
require (
+ github.com/Clever/wag/loggers/printlogger v0.0.0-20220627211420-961d6411e74f // indirect
+ github.com/Clever/wag/loggers/waglogger v0.0.0-20220627211420-961d6411e74f // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect
@@ -38,7 +39,6 @@ require (
go.mongodb.org/mongo-driver v1.7.5 // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/text v0.3.7 // indirect
- gopkg.in/Clever/kayvee-go.v6 v6.27.0 // indirect //Still want to remove this once I merge discovery-go PR.
gopkg.in/yaml.v2 v2.4.0 // indirect
)

diff:
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/Clever/discovery-go v1.8.1 h1:bT2q5IkEZnQviXEvC6iij9KNlJTPyLXPOQQCvvpX2Rg=
+github.com/Clever/discovery-go v1.8.1/go.mod h1:2W318WszWlVde/hKBvxM3xrQKcmxWwv+6ysUu8Rfx0I=
+github.com/Clever/wag/loggers/printlogger v0.0.0-20220627211420-961d6411e74f h1:fHUwC/AoU5vMH/xB9KbdcJf1xv+jn7/cAgCIZQ6HwMg=
+github.com/Clever/wag/loggers/printlogger v0.0.0-20220627211420-961d6411e74f/go.mod h1:a81vL2Do64xZLXSdqrYZugAzgKfCyuX+DObjBzmbZGI=
+github.com/Clever/wag/loggers/waglogger v0.0.0-20220627165618-1bd4f73bc4d8 h1:teoGIApJ4Xh4gRXJ2FhavOfB5PcBxkBKSCW0X1+FEBQ=
+github.com/Clever/wag/loggers/waglogger v0.0.0-20220627165618-1bd4f73bc4d8/go.mod h1:wCYwOynv1y5ePqwkSdVcjrO6AZn99vCixp6NDqO6QFQ=
+github.com/Clever/wag/loggers/waglogger v0.0.0-20220627211420-961d6411e74f h1:xWqDojyPHwgNTxzHBgph6XzSG4t/cW8UlhXmT2QwBvg=
+github.com/Clever/wag/loggers/waglogger v0.0.0-20220627211420-961d6411e74f/go.mod h1:wCYwOynv1y5ePqwkSdVcjrO6AZn99vCixp6NDqO6QFQ=
+github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
+github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
+github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
+github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
+github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/donovanhide/eventsource v0.0.0-20171031113327-3ed64d21fb0b/go.mod h1:56wL82FO0bfMU5RvfXoIwSOP2ggqqxT+tAfNEIyxuHw=
+github.com/go-openapi/analysis v0.21.2/go.mod h1:HZwRk4RRisyG8vx2Oe6aqeSQcoxRp47Xkp3+K6q+LdY=
+github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
+github.com/go-openapi/errors v0.19.9/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
+github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
+github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
+github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
+github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns=
+github.com/go-openapi/loads v0.21.1/go.mod h1:/DtAMXXneXFjbQMGEtbamCZb+4x7eGwkvZCvBmwUG+g=
+github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I=
+github.com/go-openapi/strfmt v0.21.0/go.mod h1:ZRQ409bWMj+SOgXofQAGTIo2Ebu72Gs+WaRADcS5iNg=
+github.com/go-openapi/strfmt v0.21.1/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k=
+github.com/go-openapi/strfmt v0.21.2/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k=
+github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
+github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
+github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
+github.com/go-openapi/validate v0.22.0/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUriMu5/zuPSQ1hg=
+github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
+github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0=
+github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY=
+github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg=
+github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
+github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
+github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs=
+github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI=
+github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI=
+github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk=
+github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28=
+github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo=
+github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk=
+github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw=
+github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360=
+github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg=
+github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE=
+github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8=
+github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc=
+github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc=
+github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
+github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
+github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ=
+github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0=
+github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
+github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
+github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
+github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
+github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
+github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
+github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
+github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
+github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
+github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
+github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
+github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
+github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
+github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
+github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
+github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
+github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
+github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
+github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
+github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
+github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
+github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
+github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
+github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM=
+github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
+github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
+github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
+github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
+github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
+github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
+github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
+github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
+github.com/xeipuuv/gojsonschema v1.2.1-0.20200424115421-065759f9c3d7/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
+github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
+go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg=
+go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng=
+golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
+golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
+golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
+golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+gopkg.in/Clever/kayvee-go.v6 v6.27.0/go.mod h1:G0m6nBZj7Kdz+w2hiIaawmhXl5zp7E/K0ashol3Kb2A=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=


message: More changes to tracing.go redoing the whole bloody thing

diff:
@@ -9,9 +9,10 @@ require (
go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.32.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0
go.opentelemetry.io/otel v1.7.0
+ go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.7.0
go.opentelemetry.io/otel/sdk v1.7.0
go.opentelemetry.io/otel/trace v1.7.0
- golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
+ golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect
gopkg.in/Clever/kayvee-go.v6 v6.27.0
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.2.3 // indirect

diff:
@@ -34,6 +34,8 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0 h1:mac9BKR
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0/go.mod h1:5eCOqeGphOyz6TsY3ZDNjE33SM/TFAK3RGuCL2naTgY=
go.opentelemetry.io/otel v1.7.0 h1:Z2lA3Tdch0iDcrhJXDIlC94XE+bxok1F9B+4Lz/lGsM=
go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk=
+go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.7.0 h1:8hPcgCg0rUJiKE6VWahRvjgLUrNl7rW2hffUEPKXVEM=
+go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.7.0/go.mod h1:K4GDXPY6TjUiwbOh+DkKaEdCF8y+lvMoM6SeAPyfCCM=
go.opentelemetry.io/otel/metric v0.30.0 h1:Hs8eQZ8aQgs0U49diZoaS6Uaxw3+bBE3lcMUKBFIk3c=
go.opentelemetry.io/otel/metric v0.30.0/go.mod h1:/ShZ7+TS4dHzDFmfi1kSXMhMVubNoP0oIaBp70J6UXU=
go.opentelemetry.io/otel/sdk v1.7.0 h1:4OmStpcKVOfvDOgCt7UriAPtKolwIhxpnSNI/yK+1B0=
@@ -41,8 +43,8 @@ go.opentelemetry.io/otel/sdk v1.7.0/go.mod h1:uTEOTwaqIVuTGiJN7ii13Ibp75wJmYUDe3
go.opentelemetry.io/otel/trace v1.7.0 h1:O37Iogk1lEkMRXewVtZ1BBTVn5JEp8GrJvP92bJqC6o=
go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU=
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
-golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8=
+golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/Clever/kayvee-go.v6 v6.27.0 h1:UBbWrJ6l4ghaxpM5JZ5X23cCXWrqKAaO0RyCHctJ7b0=
gopkg.in/Clever/kayvee-go.v6 v6.27.0/go.mod h1:G0m6nBZj7Kdz+w2hiIaawmhXl5zp7E/K0ashol3Kb2A=

diff:
@@ -5,15 +5,22 @@ import (
"encoding/binary"
"encoding/hex"
"fmt"
+ "io"
+ "log"
"net/http"
"os"
"strconv"
- "time"
"github.com/davecgh/go-spew/spew"
"go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel"
+ "go.opentelemetry.io/otel/attribute"
+ "go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
+ "go.opentelemetry.io/otel/sdk/resource"
+ "go.opentelemetry.io/otel/trace"
+
+ semconv "go.opentelemetry.io/otel/semconv/v1.10.0"
"go.opentelemetry.io/otel/propagation"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
@@ -22,6 +29,11 @@ import (
"gopkg.in/Clever/kayvee-go.v6/logger"
)
+const (
+ instrumentationName = "github.com/Clever/wag/instrumentation"
+ instrumentationVersion = "v0.1.0"
+)
+
// propagator to use.
var propagator propagation.TextMapPropagator = propagation.TraceContext{} // traceparent header
@@ -29,6 +41,30 @@ var propagator propagation.TextMapPropagator = propagation.TraceContext{} // tra
// hasn't been updated when it is updated we can use otlp.DefaultCollectorPort
var defaultCollectorPort uint16 = 4317
+func newExporter(w io.Writer) (trace.SpanExporter, error) {
+ return stdouttrace.New(
+ stdouttrace.WithWriter(w),
+ // Use human-readable output.
+ stdouttrace.WithPrettyPrint(),
+ // Do not print timestamps for the demo.
+ // stdouttrace.WithoutTimestamps(),
+ )
+}
+
+// newResource returns a resource describing this application.
+func newResource() *resource.Resource {
+ r, _ := resource.Merge(
+ resource.Default(),
+ resource.NewWithAttributes(
+ semconv.SchemaURL,
+ semconv.ServiceNameKey.String("fib"),
+ semconv.ServiceVersionKey.String("v0.1.0"),
+ attribute.String("environment", "demo"),
+ ),
+ )
+ return r
+}
+
// SetupGlobalTraceProviderAndExporter sets up an exporter to export,
// as well as the opentelemetry global trace provider for trace generators to use.
// The exporter and provider are returned in order for the caller to defer shutdown.
@@ -39,6 +75,7 @@ func SetupGlobalTraceProviderAndExporter(ctx context.Context) (sdktrace.SpanExpo
// If we're running locally, then turn off sampling. Otherwise sample
// 1% or whatever TRACING_SAMPLING_PROBABILITY specifies.
+ DefaultCollectorHost := "localhost"
samplingProbability := 0.01
isLocal := os.Getenv("_IS_LOCAL") == "true"
if isLocal {
@@ -52,40 +89,60 @@ func SetupGlobalTraceProviderAndExporter(ctx context.Context) (sdktrace.SpanExpo
samplingProbability = samplingProbabilityFromEnv
}
- addr := fmt.Sprintf("%s:%d", otlp.DefaultCollectorHost, defaultCollectorPort)
+ addr := fmt.Sprintf("%s:%d", DefaultCollectorHost, defaultCollectorPort)
// Every 15 seconds we'll try to connect to opentelemetry collector at
// the default location of localhost:4317
// When running in production this is a sidecar, and when running
// locally this is a locally running opetelemetry-collector.
- driver := otlpgrpc.NewDriver(
- otlpgrpc.WithReconnectionPeriod(15*time.Second),
- otlpgrpc.WithEndpoint(addr),
- otlpgrpc.WithInsecure(),
- )
- fmt.Println("---driver---")
- spew.Dump(driver)
- exporter, err := otlp.NewExporter(
- ctx,
- driver,
- )
+ // driver := otlpgrpc.NewDriver(
+ // otlpgrpc.WithReconnectionPeriod(15*time.Second),
+ // otlpgrpc.WithEndpoint(addr),
+ // otlpgrpc.WithInsecure(),
+ // )
+ // fmt.Println("---driver---")
+ // spew.Dump(driver)
+ // exporter, err := otlp.NewExporter(
+ // ctx,
+ // driver,
+ // )
+ // if err != nil {
+ // return nil, nil, fmt.Errorf("error creating exporter: %v", err)
+ // }
+ // fmt.Println("---exporter---")
+ // spew.Dump(exporter)
+
+ l := log.New(os.Stdout, "", 0)
+ f, err := os.Create("traces.txt")
+ if err != nil {
+ l.Fatal(err)
+ }
+ defer f.Close()
+ exp, err := newExporter(f)
if err != nil {
- return nil, nil, fmt.Errorf("error creating exporter: %v", err)
+ l.Fatal(err)
}
- fmt.Println("---exporter---")
- spew.Dump(exporter)
- tp := newTracerProvider(exporter, samplingProbability)
+ tp := trace.NewTracerProvider(
+ samplingProbability,
+ trace.WithBatcher(exp),
+ trace.WithResource(newResource()),
+ )
fmt.Println("---trace provider---")
spew.Dump(tp)
+ defer func() {
+ if err := tp.Shutdown(context.Background()); err != nil {
+ l.Fatal(err)
+ }
+ }()
otel.SetTracerProvider(tp)
logger.FromContext(ctx).InfoD("starting-tracer", logger.M{
"address": addr,
"sampling-rate": samplingProbability,
})
- return exporter, tp, nil
+ return exp, tp, nil
}
// SetupGlobalTraceProviderAndExporterForTest is meant to be used in unit testing,
@@ -158,9 +215,11 @@ type roundTripper struct {
}
func (rt roundTripper) RoundTrip(r *http.Request) (*http.Response, error) {
+
return otelhttp.NewTransport(
rt.baseTransport,
otelhttp.WithTracerProvider(otel.GetTracerProvider()),
+ // otelhttp.WithTracerProvider(tracer),
otelhttp.WithPropagators(propagator),
otelhttp.WithSpanNameFormatter(func(method string, r *http.Request) string {
v, ok := r.Context().Value(rt.spanNameCtxValue).(string)


message: why is bindata.go only huge on push?

diff:
@@ -136,8 +136,8 @@ func newResource() *resource.Resource {
resource.Default(),
resource.NewWithAttributes(
semconv.SchemaURL,
- semconv.ServiceNameKey.String("dapple"),
- semconv.ServiceVersionKey.String("1.11.0"),
+ semconv.ServiceNameKey.String("blog"),
+ semconv.ServiceVersionKey.String("0.1.0"),
),
)
return r

diff:
@@ -6,7 +6,7 @@ go 1.16
require (
//removed this because it can never get the right version. Adding with: go get github.com/Clever/dapple/gen-go/models@INFRANG-4918-Testing-nested-modules
// github.com/Clever/wag/samples/v8/gen-go-blog/models v0.0.0
- github.com/Clever/discovery-go v1.7.2
+ github.com/Clever/discovery-go v1.8.1
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/donovanhide/eventsource v0.0.0-20171031113327-3ed64d21fb0b
)

change_type: DELETE

diff:
-// Code generated by MockGen. DO NOT EDIT.
-// Source: interface.go
-
-// Package server is a generated GoMock package.
-package server
-
-import (
- context "context"
- reflect "reflect"
-
- models "github.com/Clever/wag/samples/v8/gen-go-blog/models"
- gomock "github.com/golang/mock/gomock"
-)
-
-// MockController is a mock of Controller interface.
-type MockController struct {
- ctrl *gomock.Controller
- recorder *MockControllerMockRecorder
-}
-
-// MockControllerMockRecorder is the mock recorder for MockController.
-type MockControllerMockRecorder struct {
- mock *MockController
-}
-
-// NewMockController creates a new mock instance.
-func NewMockController(ctrl *gomock.Controller) *MockController {
- mock := &MockController{ctrl: ctrl}
- mock.recorder = &MockControllerMockRecorder{mock}
- return mock
-}
-
-// EXPECT returns an object that allows the caller to indicate expected use.
-func (m *MockController) EXPECT() *MockControllerMockRecorder {
- return m.recorder
-}
-
-// GetSectionsForStudent mocks base method.
-func (m *MockController) GetSectionsForStudent(ctx context.Context, studentID string) ([]models.Section, error) {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "GetSectionsForStudent", ctx, studentID)
- ret0, _ := ret[0].([]models.Section)
- ret1, _ := ret[1].(error)
- return ret0, ret1
-}
-
-// GetSectionsForStudent indicates an expected call of GetSectionsForStudent.
-func (mr *MockControllerMockRecorder) GetSectionsForStudent(ctx, studentID interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSectionsForStudent", reflect.TypeOf((*MockController)(nil).GetSectionsForStudent), ctx, studentID)
-}
-
-// PostGradeFileForStudent mocks base method.
-func (m *MockController) PostGradeFileForStudent(ctx context.Context, i *models.PostGradeFileForStudentInput) error {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "PostGradeFileForStudent", ctx, i)
- ret0, _ := ret[0].(error)
- return ret0
-}
-
-// PostGradeFileForStudent indicates an expected call of PostGradeFileForStudent.
-func (mr *MockControllerMockRecorder) PostGradeFileForStudent(ctx, i interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostGradeFileForStudent", reflect.TypeOf((*MockController)(nil).PostGradeFileForStudent), ctx, i)
-}
-
-// PostSectionsForStudent mocks base method.
-func (m *MockController) PostSectionsForStudent(ctx context.Context, i *models.PostSectionsForStudentInput) ([]models.Section, error) {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "PostSectionsForStudent", ctx, i)
- ret0, _ := ret[0].([]models.Section)
- ret1, _ := ret[1].(error)
- return ret0, ret1
-}
-
-// PostSectionsForStudent indicates an expected call of PostSectionsForStudent.
-func (mr *MockControllerMockRecorder) PostSectionsForStudent(ctx, i interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostSectionsForStudent", reflect.TypeOf((*MockController)(nil).PostSectionsForStudent), ctx, i)
-}

diff:
@@ -136,8 +136,8 @@ func newResource() *resource.Resource {
resource.Default(),
resource.NewWithAttributes(
semconv.SchemaURL,
- semconv.ServiceNameKey.String("dapple"),
- semconv.ServiceVersionKey.String("1.11.0"),
+ semconv.ServiceNameKey.String("swagger-test"),
+ semconv.ServiceVersionKey.String("0.1.0"),
),
)
return r

diff:
@@ -6,7 +6,7 @@ go 1.16
require (
//removed this because it can never get the right version. Adding with: go get github.com/Clever/dapple/gen-go/models@INFRANG-4918-Testing-nested-modules
// github.com/Clever/wag/samples/v8/gen-go-client-only/models v0.0.0
- github.com/Clever/discovery-go v1.7.2
+ github.com/Clever/discovery-go v1.8.1
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/donovanhide/eventsource v0.0.0-20171031113327-3ed64d21fb0b
)

diff:
@@ -6,7 +6,7 @@ go 1.16
require (
//removed this because it can never get the right version. Adding with: go get github.com/Clever/dapple/gen-go/models@INFRANG-4918-Testing-nested-modules
// github.com/Clever/wag/samples/v8/gen-go-db-custom-path/models v0.0.0
- github.com/Clever/discovery-go v1.7.2
+ github.com/Clever/discovery-go v1.8.1
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/donovanhide/eventsource v0.0.0-20171031113327-3ed64d21fb0b
)

diff:
@@ -6,7 +6,7 @@ go 1.16
require (
//removed this because it can never get the right version. Adding with: go get github.com/Clever/dapple/gen-go/models@INFRANG-4918-Testing-nested-modules
// github.com/Clever/wag/samples/v8/gen-go-db/models v0.0.0
- github.com/Clever/discovery-go v1.7.2
+ github.com/Clever/discovery-go v1.8.1
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/donovanhide/eventsource v0.0.0-20171031113327-3ed64d21fb0b
)

diff:
@@ -136,8 +136,8 @@ func newResource() *resource.Resource {
resource.Default(),
resource.NewWithAttributes(
semconv.SchemaURL,
- semconv.ServiceNameKey.String("dapple"),
- semconv.ServiceVersionKey.String("1.11.0"),
+ semconv.ServiceNameKey.String("nil-test"),
+ semconv.ServiceVersionKey.String("0.1.0"),
),
)
return r

diff:
+// Code generated by MockGen. DO NOT EDIT.
+// Source: interface.go
+
+// Package server is a generated GoMock package.
+package server
+
+import (
+ context "context"
+ reflect "reflect"
+
+ models "github.com/Clever/wag/samples/v8/gen-go-nils/models"
+ gomock "github.com/golang/mock/gomock"
+)
+
+// MockController is a mock of Controller interface.
+type MockController struct {
+ ctrl *gomock.Controller
+ recorder *MockControllerMockRecorder
+}
+
+// MockControllerMockRecorder is the mock recorder for MockController.
+type MockControllerMockRecorder struct {
+ mock *MockController
+}
+
+// NewMockController creates a new mock instance.
+func NewMockController(ctrl *gomock.Controller) *MockController {
+ mock := &MockController{ctrl: ctrl}
+ mock.recorder = &MockControllerMockRecorder{mock}
+ return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *MockController) EXPECT() *MockControllerMockRecorder {
+ return m.recorder
+}
+
+// NilCheck mocks base method.
+func (m *MockController) NilCheck(ctx context.Context, i *models.NilCheckInput) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "NilCheck", ctx, i)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// NilCheck indicates an expected call of NilCheck.
+func (mr *MockControllerMockRecorder) NilCheck(ctx, i interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NilCheck", reflect.TypeOf((*MockController)(nil).NilCheck), ctx, i)
+}

original_message: why is bindata.go only huge on push?


message: changes to remove semconv dependency

diff:
@@ -97,13 +97,14 @@ type options struct {
logger waglogger.WagClientLogger
instrumentor Instrumentor
exporter sdktrace.SpanExporter
+ resourceMaker ResourceMaker
+
}
type Option interface {
apply(*options)
}
-//Logger
//WithLogger sets client logger option.
func WithLogger(log waglogger.WagClientLogger) Option {
@@ -118,7 +119,6 @@ func (l loggerOption) apply(opts *options) {
opts.logger = l.Log
}
-//RoundTripper
type roundTripperOption struct {
rt http.RoundTripper
@@ -163,23 +163,25 @@ func (se exporterOption) apply(opts *options) {
opts.exporter = se.exporter
}
-//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------
+//WithResource sets the otel resource (includes service name and version for traces)
+func WithResourceMaker(r ResourceMaker) Option {
+ return resourceMakerOption{resourceMaker: r}
+}
-// newResource returns a resource describing this application.
-// Used for setting up tracer provider
-func newResource() *resource.Resource {
- r, _ := resource.Merge(
- resource.Default(),
- resource.NewWithAttributes(
- semconv.SchemaURL,
- semconv.ServiceNameKey.String("{{.ServiceName}}"),
- semconv.ServiceVersionKey.String("{{ .Version }}"),
- ),
- )
- return r
+type ResourceMaker func(service, version string) *resource.Resource
+
+type resourceMakerOption struct {
+ resourceMaker ResourceMaker
+}
+
+func (r resourceMakerOption) apply(opts *options) {
+ opts.resourceMaker = r.resourceMaker
}
-func newTracerProvider(exporter sdktrace.SpanExporter, samplingProbability float64) *sdktrace.TracerProvider {
+//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------
+
+
+func newTracerProvider(exporter sdktrace.SpanExporter, samplingProbability float64, res *resource.Resource) *sdktrace.TracerProvider {
return sdktrace.NewTracerProvider(
// We use the default ID generator. In order for sampling to work (at least with this sampler)
// the ID generator must generate trace IDs uniformly at random from the entire space of uint64.
@@ -194,12 +196,13 @@ func newTracerProvider(exporter sdktrace.SpanExporter, samplingProbability float
//Batcher is more efficient, switch to it after testing
sdktrace.WithSyncer(exporter),
//sdktrace.WithBatcher(exporter),
- sdktrace.WithResource(newResource()),
+ sdktrace.WithResource(res),
)
}
func doNothing(baseTransport http.RoundTripper, spanNameCtxValue interface{}, tp sdktrace.TracerProvider) http.RoundTripper {
return baseTransport
}
+
func determineSampling() (samplingProbability float64, err error) {
// // If we're running locally, then turn off sampling. Otherwise sample
@@ -254,6 +257,13 @@ func New(basePath string, opts ...Option) *WagClient {
// samplingProbability := determineSampling()
tp := newTracerProvider(options.exporter, samplingProbability)
+ var res *resource.Resource
+ if options.resourceMaker == nil {
+ res = resource.Default()
+ } else {
+ res = options.resourceMaker("{{.ServiceName}}", "{{.Version}}")
+ }
+ tp := newTracerProvider(options.exporter, samplingProbability, res)
options.transport = options.instrumentor(options.transport, context.TODO(), *tp)
circuit := &circuitBreakerDoer{

diff:
-module github.com/Clever/wag/otelResource1.10.0
+module github.com/Clever/wag/otelresource1.10.0
go 1.16

diff:
-package otelResource
+package otelresource
import (
"go.opentelemetry.io/otel/sdk/resource"

original_message: changes to remove semconv dependency


message: Updated OtlpGrpcExporter to take an optional WithAddress argument

diff:
@@ -270,8 +270,8 @@ func doNothing(baseTransport http.RoundTripper, spanNameCtxValue interface{}, tp
func determineSampling() (samplingProbability float64, err error) {
- // // If we're running locally, then turn off sampling. Otherwise sample
- // // 1% or whatever TRACING_SAMPLING_PROBABILITY specifies.
+ // If we're running locally, then turn off sampling. Otherwise sample
+ // 1% or whatever TRACING_SAMPLING_PROBABILITY specifies.
samplingProbability = 0.01
isLocal := os.Getenv("_IS_LOCAL") == "true"
if isLocal {

diff:
@@ -25,14 +25,41 @@ const (
//propagator to use
var propagator propagation.TextMapPropagator = propagation.TraceContext{} // traceparent header
+type Option interface {
+ apply(*options)
+}
+type options struct {
+ address string
+}
+
+//WithAddress takes an address in the form of Host:Port
+func WithAddress(addr string) Option {
+ return addrOption{address: addr}
+}
+
+type addrOption struct {
+ address string
+}
+
+func (o addrOption) apply(opts *options) {
+ opts.address = o.address
+}
//OtlpGrpcExporter uses the otlptracegrpc modules and the otlptrace module to produce a new exporter at our default addr
-func OtlpGrpcExporter(ctx context.Context) sdktrace.SpanExporter {
+func OtlpGrpcExporter(ctx context.Context, opts ...Option) sdktrace.SpanExporter {
+
DefaultCollectorHost := "localhost"
var defaultCollectorPort uint16 = 4317
-
addr := fmt.Sprintf("%s:%d", DefaultCollectorHost, defaultCollectorPort)
+ options := options{
+ address: addr,
+ }
+
+ for _, o := range opts {
+ o.apply(&options)
+ }
+
otlpClient := otlptracegrpc.NewClient(
otlptracegrpc.WithEndpoint(addr), //Not strictly needed as we use the defaults
otlptracegrpc.WithReconnectionPeriod(15*time.Second),
@@ -52,11 +79,6 @@ func OtlpGrpcExporter(ctx context.Context) sdktrace.SpanExporter {
}
-//RoundTripperInstrumentor is probably a redundant wrap around a wrap.
-func RoundTripperInstrumentor(tp sdktrace.TracerProvider, baseRT http.RoundTripper, ctx context.Context) (http.RoundTripper, error) {
- return InstrumentedTransport(baseRT, ctx, tp), nil
-}
-
func newTracerProvider(exporter sdktrace.SpanExporter, samplingProbability float64, resource *resource.Resource) *sdktrace.TracerProvider {
return sdktrace.NewTracerProvider(
// We use the default ID generator. In order for sampling to work (at least with this sampler)


message: Removing stuff that isn't necessary anymore since we are just going to use the otel module dep

diff:
@@ -162,91 +162,24 @@ func (se exporterOption) apply(opts *options) {
opts.exporter = se.exporter
}
-//WithResource sets the otel resource (includes service name and version for traces)
-func WithResourceMaker(r ResourceMaker) Option {
- return resourceMakerOption{resourceMaker: r}
-}
-
-type ResourceMaker func(service, version string) *resource.Resource
-
-type resourceMakerOption struct {
- resourceMaker ResourceMaker
-}
-
-func (r resourceMakerOption) apply(opts *options) {
- opts.resourceMaker = r.resourceMaker
-}
-
//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------
-//Start Basic SpanExporter to os.Stdout
-
-var zeroTime time.Time
-
-var _ sdktrace.SpanExporter = &stdoutExporter{}
-
-type stdoutExporter struct {
- encoder *json.Encoder
- encoderMu sync.Mutex
- stoppedMu sync.RWMutex
- stopped bool
-}
-
-// ExportSpans writes spans in json format to stdout.
-func (e *stdoutExporter) ExportSpans(ctx context.Context, spans []trace.ReadOnlySpan) error {
- e.stoppedMu.RLock()
- stopped := e.stopped
- e.stoppedMu.RUnlock()
- if stopped {
- return nil
- }
-
- if len(spans) == 0 {
- return nil
- }
-
- stubs := tracetest.SpanStubsFromReadOnlySpans(spans)
-
- e.encoderMu.Lock()
- defer e.encoderMu.Unlock()
- for i := range stubs {
- stub := &stubs[i]
- // Encode span stubs, one by one
- if err := e.encoder.Encode(stub); err != nil {
- return err
- }
- }
- return nil
-}
-
-// Shutdown is called to stop the exporter, it preforms no action.
-func (e *stdoutExporter) Shutdown(ctx context.Context) error {
- e.stoppedMu.Lock()
- e.stopped = true
- e.stoppedMu.Unlock()
-
- select {
- case <-ctx.Done():
- return ctx.Err()
- default:
- }
- return nil
-}
-
-// MarshalLog is the marshaling function used by the logging system to represent this exporter.
-func (e *stdoutExporter) MarshalLog() interface{} {
- return struct {
- Type string
- }{
- Type: "stdout",
- }
+// newResource returns a resource describing this application.
+// Used for setting up tracer provider
+func newResource() *resource.Resource {
+ r, _ := resource.Merge(
+ resource.Default(),
+ resource.NewWithAttributes(
+ semconv.SchemaURL,
+ semconv.ServiceNameKey.String("{{.ServiceName}}"),
+ semconv.ServiceVersionKey.String("{{ .Version }}"),
+ ),
+ )
+ return r
}
-//End Basic SpanExporter to os.Stdout
-
-
-func newTracerProvider(exporter sdktrace.SpanExporter, samplingProbability float64, res *resource.Resource) *sdktrace.TracerProvider {
+func newTracerProvider(exporter sdktrace.SpanExporter, samplingProbability float64) *sdktrace.TracerProvider {
return sdktrace.NewTracerProvider(
// We use the default ID generator. In order for sampling to work (at least with this sampler)
// the ID generator must generate trace IDs uniformly at random from the entire space of uint64.
@@ -261,9 +194,10 @@ func newTracerProvider(exporter sdktrace.SpanExporter, samplingProbability float
//Batcher is more efficient, switch to it after testing
sdktrace.WithSyncer(exporter),
//sdktrace.WithBatcher(exporter),
- sdktrace.WithResource(res),
+ sdktrace.WithResource(newResource()),
)
}
+
func doNothing(baseTransport http.RoundTripper, spanNameCtxValue interface{}, tp sdktrace.TracerProvider) http.RoundTripper {
return baseTransport
}
@@ -321,13 +255,7 @@ func New(basePath string, opts ...Option) *WagClient {
samplingProbability := 1.0 // TODO: Put back logic to set this to 1 for local, 0.1 otherwise etc.
// samplingProbability := determineSampling()
- var res *resource.Resource
- if options.resourceMaker == nil {
- res = resource.Default()
- } else {
- res = options.resourceMaker("{{.ServiceName}}", "{{.Version}}")
- }
- tp := newTracerProvider(options.exporter, samplingProbability, res)
+ tp := newTracerProvider(options.exporter, samplingProbability)
options.transport = options.instrumentor(options.transport, context.TODO(), *tp)
circuit := &circuitBreakerDoer{


message: transfering over some manual changes

diff:
@@ -85,7 +85,7 @@ type WagClient struct {
// Keep the circuit doer around so that we can turn it on / off
circuitDoer *circuitBreakerDoer
defaultTimeout time.Duration
- logger waglogger.WagClientLogger
+ logger WagClientLogger
}
var _ Client = (*WagClient)(nil)
@@ -94,7 +94,7 @@ var _ Client = (*WagClient)(nil)
//This pattern is used instead of using closures for greater transparency and the ability to implement additional interfaces.
type options struct {
transport http.RoundTripper
- logger waglogger.WagClientLogger
+ logger WagClientLogger
instrumentor Instrumentor
exporter sdktrace.SpanExporter
}
@@ -105,12 +105,12 @@ type Option interface {
//WithLogger sets client logger option.
-func WithLogger(log waglogger.WagClientLogger) Option {
+func WithLogger(log WagClientLogger) Option {
return loggerOption{Log: log}
}
type loggerOption struct {
- Log waglogger.WagClientLogger
+ Log WagClientLogger
}
func (l loggerOption) apply(opts *options) {
@@ -281,7 +281,7 @@ func determineSampling() (samplingProbability float64, err error) {
func New(basePath string, opts ...Option) *WagClient {
defaultTransport := http.DefaultTransport
- defaultLogger := printlogger.NewLogger("{{.ServiceName}}-wagclient", "info")
+ defaultLogger := NewLogger("{{.ServiceName}}-wagclient", "info")
defaultExporter, err := stdouttrace.New(stdouttrace.WithPrettyPrint())
if err != nil {
fmt.Println(err)
@@ -360,7 +360,7 @@ func (c *WagClient) SetCircuitBreakerDebug(b bool) {
}
// SetLogger allows for setting a custom logger
-func (c *WagClient) SetLogger(l waglogger.WagClientLogger) {
+func (c *WagClient) SetLogger(l WagClientLogger) {
c.logger = l
c.circuitDoer.logger = l
}

original_message: transfering over some manual changes


message: removed unused consts from tracing

diff:
@@ -164,26 +164,39 @@ func (se exporterOption) apply(opts *options) {
//WagClientLogger provides a minimal interface for a Wag Client Logger
type WagClientLogger interface {
- Log(level string, message string, pairs map[string]interface{})
+ Log(level LogLevel, message string, pairs map[string]interface{})
}
//M is a convenience type to avoid having to type out map[string]interface{} everytime.
type M map[string]interface{}
+type LogLevel int
+
+// Constants used to define different LogLevels supported
+const (
+ Trace LogLevel = iota
+ Debug
+ Info
+ Warning
+ Error
+ Critical
+ FromEnv
+)
+
//NewLogger creates a logger for id that produces logs at and below the indicated level.
//Level indicated the level at and below which logs are created.
-func NewLogger(id string, level string) WagClientLogger {
+func NewLogger(id string, level LogLevel) WagClientLogger {
return PrintlnLogger{id: id, level: level}
}
type PrintlnLogger struct {
- level string
+ level LogLevel
id string
}
-func (w PrintlnLogger) Log(level string, message string, m map[string]interface{}) {
+func (w PrintlnLogger) Log(level LogLevel, message string, m map[string]interface{}) {
- if w.strLvlToInt(w.level) >= w.strLvlToInt(level) {
+ if level >= level {
m["id"] = w.id
jsonLog, err := json.Marshal(m)
if err != nil {
@@ -193,24 +206,6 @@ func (w PrintlnLogger) Log(level string, message string, m map[string]interface{
}
}
-func (w PrintlnLogger) strLvlToInt(s string) int {
- switch s {
- case "Critical":
- return 0
- case "Error":
- return 1
- case "Warning":
- return 2
- case "Info":
- return 3
- case "Debug":
- return 4
- case "Trace":
- return 5
- }
- return -1
-}
-
//----------------------END LOGGING RELATED FUNCTIONS------------------------
//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------

diff:
@@ -126,26 +126,39 @@ func (se exporterOption) apply(opts *options) {
//WagClientLogger provides a minimal interface for a Wag Client Logger
type WagClientLogger interface {
- Log(level string, message string, pairs map[string]interface{})
+ Log(level LogLevel, message string, pairs map[string]interface{})
}
//M is a convenience type to avoid having to type out map[string]interface{} everytime.
type M map[string]interface{}
+type LogLevel int
+
+// Constants used to define different LogLevels supported
+const (
+ Trace LogLevel = iota
+ Debug
+ Info
+ Warning
+ Error
+ Critical
+ FromEnv
+)
+
//NewLogger creates a logger for id that produces logs at and below the indicated level.
//Level indicated the level at and below which logs are created.
-func NewLogger(id string, level string) WagClientLogger {
+func NewLogger(id string, level LogLevel) WagClientLogger {
return PrintlnLogger{id: id, level: level}
}
type PrintlnLogger struct {
- level string
+ level LogLevel
id string
}
-func (w PrintlnLogger) Log(level string, message string, m map[string]interface{}) {
+func (w PrintlnLogger) Log(level LogLevel, message string, m map[string]interface{}) {
- if w.strLvlToInt(w.level) >= w.strLvlToInt(level) {
+ if level >= level {
m["id"] = w.id
jsonLog, err := json.Marshal(m)
if err != nil {
@@ -155,24 +168,6 @@ func (w PrintlnLogger) Log(level string, message string, m map[string]interface{
}
}
-func (w PrintlnLogger) strLvlToInt(s string) int {
- switch s {
- case "Critical":
- return 0
- case "Error":
- return 1
- case "Warning":
- return 2
- case "Info":
- return 3
- case "Debug":
- return 4
- case "Trace":
- return 5
- }
- return -1
-}
-
//----------------------END LOGGING RELATED FUNCTIONS------------------------
//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------

diff:
@@ -18,11 +18,6 @@ import (
"go.opentelemetry.io/otel/trace"
)
-const (
- instrumentationName = "github.com/Clever/wag/instrumentation"
- instrumentationVersion = "v0.1.0"
-)
-
//propagator to use
var propagator propagation.TextMapPropagator = propagation.TraceContext{} // traceparent header
type Option interface {

diff: Binary files a/wag and b/wag differ

original_message: removed unused consts from tracing


message: no need to leave removed code commented out

diff:
@@ -29,7 +29,6 @@ type baseDoer struct{}
func (d baseDoer) Do(c *http.Client, r *http.Request) (*http.Response, error) {
return c.Do(r)
- // return ctxhttp.Do(r.Context(), c, r)
}
// retryHandler retries 50X http requests


message: removed otel resource generator as it's no longer used

diff:
-module github.com/Clever/wag/otelresource1.10.0
-
-go 1.16
-
-require (
- go.opentelemetry.io/otel v1.8.0
- go.opentelemetry.io/otel/sdk v1.8.0
-)

diff:
-github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
-github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
-github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
-github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
-github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
-github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
-github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
-github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
-github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
-github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-go.opentelemetry.io/otel v1.8.0 h1:zcvBFizPbpa1q7FehvFiHbQwGzmPILebO0tyqIR5Djg=
-go.opentelemetry.io/otel v1.8.0/go.mod h1:2pkj+iMj0o03Y+cW6/m8Y4WkRdYN3AvCXCnzRMp9yvM=
-go.opentelemetry.io/otel/sdk v1.8.0 h1:xwu69/fNuwbSHWe/0PGS888RmjWY181OmcXDQKu7ZQk=
-go.opentelemetry.io/otel/sdk v1.8.0/go.mod h1:uPSfc+yfDH2StDM/Rm35WE8gXSNdvCg023J6HeGNO0c=
-go.opentelemetry.io/otel/trace v1.8.0 h1:cSy0DF9eGI5WIfNwZ1q2iUyGj00tGzP24dE1lOlHrfY=
-go.opentelemetry.io/otel/trace v1.8.0/go.mod h1:0Bt3PXY8w+3pheS3hQUt+wow8b1ojPaTBoTCh2zIFI4=
-golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw=
-golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

diff:
-package otelresource
-
-import (
- "go.opentelemetry.io/otel/sdk/resource"
- semconv "go.opentelemetry.io/otel/semconv/v1.10.0"
-)
-
-// NewResource generates a new otel resource with the service name and version passed into it.
-// Needed because semconv is part of the whole otel package.
-func NewResource(service, version string) *resource.Resource {
- r, _ := resource.Merge(
- resource.Default(),
- resource.NewWithAttributes(
- semconv.SchemaURL,
- semconv.ServiceNameKey.String(service),
- semconv.ServiceVersionKey.String(version),
- ),
- )
- return r
-}


message: tracing cleanup

diff:
@@ -7,7 +7,6 @@ import (
"net/http"
"time"
- "github.com/davecgh/go-spew/spew"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
@@ -66,8 +65,6 @@ func OtlpGrpcExporter(ctx context.Context, opts ...Option) sdktrace.SpanExporter
log.Fatal(err)
//Is doing a fatal error here too risky? No easy way to bubble up errors from here to the app using this.
//without making each of the WithXOption() takes an error as an arg as well.
-
- fmt.Println(err)
return nil
}
return spanExporter
@@ -118,8 +115,6 @@ func (rt roundTripperWithTracing) RoundTrip(r *http.Request) (*http.Response, er
otelhttp.WithSpanNameFormatter(func(method string, r *http.Request) string {
v, ok := r.Context().Value(rt.spanNameCtxValue).(string)
if ok {
- fmt.Println("---v---")
- spew.Dump(v)
return v
}
return r.Method // same as otelhttp's default span naming

original_message: tracing cleanup


message: removing spew

diff:
@@ -3,7 +3,6 @@ module github.com/Clever/wag/tracing
go 1.16
require (
- github.com/davecgh/go-spew v1.1.1
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.33.0
go.opentelemetry.io/otel v1.8.0

original_message: removing spew