Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broker Ingress Tracing #1290

Merged
merged 19 commits into from Jun 4, 2019
Merged

Conversation

Harwayne
Copy link
Contributor

Helps with #704.

Proposed Changes

  • Add dynamic tracing support to the Broker Ingress.

Release Note

The `eventing-broker-ingress` ClusterRole in `200-broker-clusterrole.yaml` needs to be re-applied.

@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 29, 2019
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label May 29, 2019
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 29, 2019
@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 29, 2019
@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/broker/broker.go Do not exist 87.6%

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/broker/broker.go Do not exist 87.6%

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/broker/broker.go Do not exist 87.6%

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/broker/broker.go Do not exist 87.6%

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/broker/broker.go Do not exist 87.6%

@Harwayne Harwayne marked this pull request as ready for review May 29, 2019 19:39
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 29, 2019
@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/broker/broker.go Do not exist 87.6%

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/broker/broker.go Do not exist 87.6%

@Harwayne
Copy link
Contributor Author

Ping.

cmd/broker/ingress/main.go Outdated Show resolved Hide resolved
cmd/broker/ingress/main.go Outdated Show resolved Hide resolved
pkg/configmap/store.go Show resolved Hide resolved
pkg/configmap/store.go Outdated Show resolved Hide resolved
@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/broker/broker.go Do not exist 87.6%

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/broker/broker.go Do not exist 87.6%

cmd/broker/ingress/main.go Outdated Show resolved Hide resolved
// func(*k8s.io/api/core/v1.ConfigMap) (... , error)
//
// These functions can return any type along with an error.
type DefaultConstructors map[*v1.ConfigMap]interface{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a map? What are the semantics of a map keyed by struct pointers?

I think this would make more sense to me as:

type DefaultConstructorFunc func() *v1.ConfigMap
type DefaultConstructors map[string]DefaultConstructorFunc

I think that would simplify this implementation since there's no need to store default configmaps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is based on knative/pkg's configmap.Constructor:

type Constructors map[string]interface{}

The suggestion drops the 'constructor' portion of this map. Essentially, what I am doing is changing the key from the name of the ConfigMap, to the entire ConfigMap.

As for pointer as key semantics, "Pointer values are comparable. Two pointer values are equal if they point to the same variable or if both have value nil. Pointers to distinct zero-size variables may or may not be equal.". So essentially, the pointer must be to the same place. The equality of what is being pointed at does not matter.

I tried to use non-pointers, but v1.ConfigMap's are "invalid map key type".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why this needs to be a map with a pointer key. This would be equivalent, right?

type DefaultConstructor struct {
  ConfigMap *v1.ConfigMap
  Constructor func(*v1.ConfigMap) (interface{}, error)
}

func NewDefaultUntypedStore(..., defaultConstructors []DefaultConstructor, ...)

I still like my version above better, but the array of structs makes more sense to me than the map.

WDYT @Harwayne? Do you like pkg's configmap.Constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to slice of structs.

The reason I was using a map to begin with was to protect against the same thing being registered twice. But that protection didn't actually occur. Both because it was a pointer and because I really wanted the key to just be the name of the ConfigMap, not its whole value.

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/broker/broker.go Do not exist 87.6%

@Harwayne
Copy link
Contributor Author

Harwayne commented Jun 3, 2019

Ping.

@nachocano
Copy link
Contributor

It looks good to me, but I'll let @grantr to lgtm as he had some comments.
I'm not very familiar with tracing. I guess if you can add a better description to the PR it would be great. But I'm OK if you don't.

kc := kubernetes.NewForConfigOrDie(mgr.GetConfig())
configMapWatcher := configmap.NewInformedWatcher(kc, env.Namespace)

zipkinServiceName := fmt.Sprintf("%s-broker-ingress.%s", env.Broker, env.Namespace)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd like this to be a function so it can be unit tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Even added a test :)

// func(*k8s.io/api/core/v1.ConfigMap) (... , error)
//
// These functions can return any type along with an error.
type DefaultConstructors map[*v1.ConfigMap]interface{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why this needs to be a map with a pointer key. This would be equivalent, right?

type DefaultConstructor struct {
  ConfigMap *v1.ConfigMap
  Constructor func(*v1.ConfigMap) (interface{}, error)
}

func NewDefaultUntypedStore(..., defaultConstructors []DefaultConstructor, ...)

I still like my version above better, but the array of structs makes more sense to me than the map.

WDYT @Harwayne? Do you like pkg's configmap.Constructor?

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/tracing/names.go Do not exist 100.0%
pkg/tracing/setup.go Do not exist 0.0%

Copy link
Contributor

@grantr grantr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm


import "fmt"

// BrokerIngressNameArgs are the arguments needed to generate the BrokerIngressName.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the reasoning for this struct is that it names the arguments so they can be passed in any order and are self documenting. I'd probably use positional parameters instead, but I'm fine with this too.

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 4, 2019
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: grantr, Harwayne

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot merged commit 62cb035 into knative:master Jun 4, 2019
@Harwayne Harwayne deleted the ingress-tracing branch June 4, 2019 20:04
@Harwayne Harwayne mentioned this pull request Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants